CoinJar_CJCheckout - Version 1.0.0

Version Notes

First release

Download this release

Release Info

Developer Mike Bywaters
Extension CoinJar_CJCheckout
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/CoinJar/.DS_Store ADDED
Binary file
app/code/community/CoinJar/CJCheckout/.DS_Store ADDED
Binary file
app/code/community/CoinJar/CJCheckout/Block/.DS_Store ADDED
Binary file
app/code/community/CoinJar/CJCheckout/Block/Standard/Form.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category CoinJar
22
+ * @package CoinJar_CJCheckout
23
+ * @copyright Copyright (c) 2014 CoinJar (http://coinjar.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class CoinJar_CJCheckout_Block_Standard_Form extends Mage_Payment_Block_Form
28
+ {
29
+ /**
30
+ * Payment method code
31
+ * @var string
32
+ */
33
+ protected $_methodCode = CoinJar_CJCheckout_Model_Config::METHOD_CJ_STANDARD;
34
+
35
+ /**
36
+ * Set template and redirect message
37
+ */
38
+ protected function _construct()
39
+ {
40
+ $result = parent::_construct();
41
+ $this->setTemplate('coinjar/payment/redirect.phtml')
42
+ ->setRedirectMessage('You will be redirected to a payment screen when you place your order.')
43
+ ;
44
+ return parent::_construct();
45
+ }
46
+
47
+ /**
48
+ * Payment method code getter
49
+ * @return string
50
+ */
51
+ public function getMethodCode()
52
+ {
53
+ return $this->_methodCode;
54
+ }
55
+
56
+ }
app/code/community/CoinJar/CJCheckout/Controller/Abstract.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category CoinJar
22
+ * @package CoinJar_CJCheckout
23
+ * @copyright Copyright (c) 2014 CoinJar (http://coinjar.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class CoinJar_CJCheckout_Controller_Abstract extends Mage_Core_Controller_Front_Action
28
+ {
29
+ protected $_config = null;
30
+ protected $_quote = null;
31
+ protected $_quoteId = null;
32
+ protected $_order = null;
33
+ protected $_checkout = null;
34
+ protected $_api = null;
35
+ protected $_ipn = null;
36
+
37
+ /**
38
+ * Instantiate checkout object
39
+ *
40
+ * @throws Mage_Core_Exception
41
+ */
42
+ protected function _getOnepage()
43
+ {
44
+ if (is_null($this->_checkout)) {
45
+ $this->_checkout = Mage::getSingleton('checkout/type_onepage');
46
+ $this->_checkout->initCheckout();
47
+ }
48
+ return $this->_checkout;
49
+ }
50
+
51
+ /**
52
+ * Return checkout session object
53
+ *
54
+ * @return Mage_Checkout_Model_Session
55
+ */
56
+ protected function _getCheckoutSession()
57
+ {
58
+ return Mage::getSingleton('checkout/session');
59
+ }
60
+
61
+ /**
62
+ * Return checkout quote object
63
+ *
64
+ * @return Mage_Sale_Model_Quote
65
+ */
66
+ protected function _getQuote()
67
+ {
68
+ if (is_null($this->_quote)) {
69
+ $this->_quote = $this->_getCheckoutSession()->getQuote();
70
+ }
71
+ return $this->_quote;
72
+ }
73
+
74
+ /**
75
+ * Protected getter for API model object
76
+ *
77
+ * @return CoinJar_CJCheckout_Model_Api
78
+ */
79
+ protected function _getApi()
80
+ {
81
+ if (is_null($this->_api)) {
82
+ $this->_api = Mage::getModel('cjcheckout/api', array('payment_method_code' => $this->_paymentMethodCode));
83
+ }
84
+ return $this->_api;
85
+ }
86
+
87
+ /**
88
+ * Protected getter for IPN model object
89
+ *
90
+ * @return CoinJar_CJCheckout_Model_Ipn
91
+ */
92
+ protected function _getIpn()
93
+ {
94
+ if (is_null($this->_ipn)) {
95
+ $this->_ipn = Mage::getModel('cjcheckout/ipn');
96
+ }
97
+ return $this->_ipn;
98
+ }
99
+
100
+ /**
101
+ * Protected getter for config model object
102
+ *
103
+ * @return CoinJar_CJCheckout_Model_Config
104
+ */
105
+ protected function _getConfig()
106
+ {
107
+ if (is_null($this->_config)) {
108
+ $this->_config = Mage::getModel('cjcheckout/config', array($this->_paymentMethodCode, Mage::app()->getStore()->getId()));
109
+ }
110
+ return $this->_config;
111
+ }
112
+
113
+ }
app/code/community/CoinJar/CJCheckout/Controller/Standard.php ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category CoinJar
22
+ * @package CoinJar_CJCheckout
23
+ * @copyright Copyright (c) 2014 CoinJar (http://coinjar.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class CoinJar_CJCheckout_Controller_Standard extends CoinJar_CJCheckout_Controller_Abstract
28
+ {
29
+ protected $_paymentMethodCode = CoinJar_CJCheckout_Model_Config::METHOD_CJ_STANDARD;
30
+
31
+ /**
32
+ * Create the order and redirect to the coinjar website for payment.
33
+ *
34
+ * @return void
35
+ */
36
+ public function redirectAction()
37
+ {
38
+ $client = $this->_getApi()->buildClient();
39
+ $orderId = $this->_getCheckoutSession()->getLastRealOrderId();
40
+ $postParams = $this->_getApi()->buildRequestParams($orderId, $orderId);
41
+ $client->setParameterPost('order', $postParams);
42
+
43
+ $errorMessage = "";
44
+
45
+ try{
46
+ $response = $client->request();
47
+ if ($response->isSuccessful()) {
48
+ $responseBody = $response->getBody();
49
+ $responseJson = Mage::helper('core')->jsonDecode($responseBody);
50
+
51
+ $uuid = $responseJson["order"]["uuid"];
52
+ $this->_getCheckoutSession()->setData('orderUuid', $uuid);
53
+ $url = $this->_getConfig()->getCoinjarOrderUrl() . '/' . $uuid;
54
+
55
+ Mage::getSingleton('core/cookie')->set('coinjarOrder', $url . '||' . (time()+900), 900, '/', null, null, false);
56
+
57
+ // Redirect to CoinJar
58
+ $this->_redirectUrl($url);
59
+ } else {
60
+ $errorMessage = 'CoinJar Server returned error with code ' . $response->getStatus();
61
+ if ($response->isSuccessful()) {
62
+ $errorMessage .= ', ' . $response.getRawBody();
63
+ }
64
+ throw new Exception($errorMessage);
65
+ }
66
+ } catch (Exception $e) {
67
+ $errorMessage = 'Exception: ' . $e->getMessage();
68
+ Mage::helper('cjcheckout')->log('Error occurred while accessing the CoinJar Order API: ' . $errorMessage);
69
+ Mage::getSingleton('checkout/session')->addError('An unrecoverable error occurred while processing your payment information. Please contact the site administrator. ' . $errorMessage);
70
+
71
+ $this->_redirect('checkout/cart');
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Notification point for the CoinJar IPN
77
+ *
78
+ * @return void
79
+ */
80
+ public function notifyAction()
81
+ {
82
+ if (Mage::helper('cjcheckout/checkout')->ipnEnabled()) {
83
+ $postData = $this->getRequest()->getPost();
84
+ if (!$postData && Mage::helper('cjcheckout/checkout')->debugIpn()) {
85
+ $postData = $this->getRequest()->getParams();
86
+ }
87
+ Mage::helper('cjcheckout')->log('IPN request: ' . http_build_query($postData));
88
+ $this->_getIpn()->setIpnData($postData);
89
+ if (!$this->_getIpn()->verify()) {
90
+ // Ignore invalid IPN
91
+ return;
92
+ }
93
+ $this->_getIpn()->processPayment();
94
+ Mage::helper('cjcheckout')->log('Successful IPN for order: ' . $postData['uuid']);
95
+ }
96
+ return $this;
97
+ }
98
+
99
+ /**
100
+ * When a customer cancels payment on the CoinJar site
101
+ *
102
+ * @return void
103
+ */
104
+ public function cancelAction()
105
+ {
106
+ Mage::helper('cjcheckout')->log('Controller load: cjcheckout/standard/cancel');
107
+ Mage::helper('cjcheckout')->log('POST data: ' . http_build_query($_POST));
108
+ $session = Mage::getSingleton('checkout/session');
109
+ $session->setQuoteId($session->getData('coinjar_quote_id', true));
110
+ if ($session->getLastRealOrderId()) {
111
+ Mage::getSingleton('core/cookie')->delete('coinjarOrder', '/', null, null, false);
112
+ $order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
113
+ if ($order->getId()) {
114
+ $order->cancel()->save();
115
+ }
116
+ Mage::helper('cjcheckout/checkout')->restoreQuote();
117
+ }
118
+ $this->_redirect('checkout/cart');
119
+ }
120
+
121
+ /**
122
+ * When customer returns from CoinJar, create the order if it doesn't already exist.
123
+ *
124
+ * @return void
125
+ */
126
+ public function successAction()
127
+ {
128
+ Mage::helper('cjcheckout')->log('Controller load: cjcheckout/standard/success');
129
+
130
+ if ($this->_getQuote()->getIsActive()) {
131
+ $this->_getQuote()->setTotalsCollectedFlag(false);
132
+ $this->_getQuote()->collectTotals();
133
+ $order = $this->_getOnepage()->saveOrder();
134
+ }
135
+
136
+ Mage::getSingleton('core/cookie')->delete('coinjarOrder', '/', null, null, false);
137
+ Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
138
+ $this->_redirect('checkout/onepage/success', array('_secure'=>true));
139
+ }
140
+
141
+ }
app/code/community/CoinJar/CJCheckout/Helper/Checkout.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category CoinJar
22
+ * @package CoinJar_CJCheckout
23
+ * @copyright Copyright (c) 2014 CoinJar (http://coinjar.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class CoinJar_CJCheckout_Helper_Checkout extends Mage_Core_Helper_Data
28
+ {
29
+ /**
30
+ * Used to determine if the IPN resonse should be verified
31
+ *
32
+ * @return bool
33
+ */
34
+ public function debugIpn()
35
+ {
36
+ return (bool) Mage::getStoreConfig('payment_services/coinjar/enableipndebug');
37
+ }
38
+
39
+ /**
40
+ * Used to determine if IPN is enabled in the System Configuration
41
+ *
42
+ * @return bool
43
+ */
44
+ public function ipnEnabled()
45
+ {
46
+ return (bool) Mage::getStoreConfig('payment_services/coinjar/ipn');
47
+ }
48
+
49
+ /**
50
+ * Restore last active quote based on checkout session
51
+ *
52
+ * @return bool True if quote restored successfully, false otherwise
53
+ */
54
+ public function restoreQuote()
55
+ {
56
+ $order = $this->_getCheckoutSession()->getLastRealOrder();
57
+ if ($order->getId()) {
58
+ $quote = $this->_getQuote($order->getQuoteId());
59
+ if ($quote->getId()) {
60
+ $quote->setIsActive(1)
61
+ ->setReservedOrderId(null)
62
+ ->save();
63
+ $this->_getCheckoutSession()
64
+ ->replaceQuote($quote)
65
+ ->unsLastRealOrderId();
66
+ return true;
67
+ }
68
+ }
69
+ return false;
70
+ }
71
+
72
+ /**
73
+ * Cancel last placed order with specified comment message
74
+ *
75
+ * @param string $comment Comment appended to order history
76
+ * @return bool True if order cancelled, false otherwise
77
+ */
78
+ public function cancelCurrentOrder($comment)
79
+ {
80
+ $order = $this->_getCheckoutSession()->getLastRealOrder();
81
+ if ($order->getId() && $order->getState() != Mage_Sales_Model_Order::STATE_CANCELED) {
82
+ $order->registerCancellation($comment)->save();
83
+ return true;
84
+ }
85
+ return false;
86
+ }
87
+
88
+ /**
89
+ * Return checkout session instance
90
+ *
91
+ * @return Mage_Checkout_Model_Session
92
+ */
93
+ protected function _getCheckoutSession()
94
+ {
95
+ return Mage::getSingleton('checkout/session');
96
+ }
97
+
98
+ /**
99
+ * Return sales quote instance for specified ID
100
+ *
101
+ * @param int $quoteId Quote identifier
102
+ * @return Mage_Sales_Model_Quote
103
+ */
104
+ protected function _getQuote($quoteId)
105
+ {
106
+ return Mage::getModel('sales/quote')->load($quoteId);
107
+ }
108
+ }
app/code/community/CoinJar/CJCheckout/Helper/Data.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category CoinJar
22
+ * @package CoinJar_CJCheckout
23
+ * @copyright Copyright (c) 2014 CoinJar (http://coinjar.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class CoinJar_CJCheckout_Helper_Data extends Mage_Payment_Helper_Data
28
+ {
29
+
30
+ /**
31
+ * Used only in development. Remove before production.
32
+ *
33
+ * @return array
34
+ */
35
+ public function getDebugBacktrace()
36
+ {
37
+ $stacks = debug_backtrace();
38
+ $result = array();
39
+ foreach ($stacks as $_stack) {
40
+ if (!isset($_stack['file'])) $_stack['file'] = '[PHP Kernel]';
41
+ if (!isset($_stack['line'])) $_stack['line'] = '';
42
+ $result[] = array(
43
+ 'file' => $_stack["file"],
44
+ 'line' => $_stack["line"],
45
+ 'function' => $_stack["function"]
46
+ );
47
+ }
48
+ return $result;
49
+ }
50
+
51
+ /**
52
+ * Used to determine if CoinJar debug mode is enabled in the System Configuration
53
+ *
54
+ * @return bool
55
+ */
56
+ public function debug()
57
+ {
58
+ return (bool) Mage::getStoreConfig('payment_services/coinjar/debuglog');
59
+ }
60
+
61
+ /**
62
+ * Log coinjar specific messages in the coinjar log only when in debug mode.
63
+ *
64
+ * @return CoinJar_CJCheckout_Helper_Data
65
+ */
66
+ public function log($message)
67
+ {
68
+ if (Mage::helper('cjcheckout')->debug()) {
69
+ Mage::log($message, null, 'coinjar.log');
70
+ }
71
+ return $this;
72
+ }
73
+ }
app/code/community/CoinJar/CJCheckout/Model/.DS_Store ADDED
Binary file
app/code/community/CoinJar/CJCheckout/Model/Abstract.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category CoinJar
22
+ * @package CoinJar_CJCheckout
23
+ * @copyright Copyright (c) 2014 CoinJar (http://coinjar.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class CoinJar_CJCheckout_Model_Abstract extends Mage_Payment_Model_Method_Abstract
28
+ {
29
+ protected $_code;
30
+ protected $_config = null;
31
+ protected $_formBlockType;
32
+
33
+ /**
34
+ * Availability options
35
+ */
36
+ protected $_isGateway = false;
37
+ protected $_canOrder = false;
38
+ protected $_canAuthorize = false;
39
+ protected $_canCapture = false;
40
+ protected $_canCapturePartial = false;
41
+ protected $_canRefund = false;
42
+ protected $_canRefundInvoicePartial = false;
43
+ protected $_canVoid = false;
44
+ protected $_canUseInternal = false;
45
+ protected $_canUseCheckout = false;
46
+ protected $_canUseForMultishipping = false;
47
+ protected $_canFetchTransactionInfo = false;
48
+ protected $_canCreateBillingAgreement = false;
49
+ protected $_canReviewPayment = false;
50
+ protected $_isInitializeNeeded = false;
51
+
52
+ public function _construct()
53
+ {
54
+ parent::_construct();
55
+ $this->_init('cjcheckout/abstract');
56
+ }
57
+
58
+ protected function _getConfig()
59
+ {
60
+ if (is_null($this->_config)) {
61
+ $this->_config = Mage::getModel('cjcheckout/config', array($this->_code, Mage::app()->getStore()->getId()));
62
+ }
63
+ return $this->_config;
64
+ }
65
+ }
app/code/community/CoinJar/CJCheckout/Model/Api.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category CoinJar
22
+ * @package CoinJar_CJCheckout
23
+ * @copyright Copyright (c) 2014 CoinJar (http://coinjar.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class CoinJar_CJCheckout_Model_Api
28
+ {
29
+ protected $_paymentMethodCode = null;
30
+ protected $_config = null;
31
+ protected $_quote = null;
32
+ protected $_quoteId = null;
33
+
34
+ public function __construct($params)
35
+ {
36
+ if ($params['payment_method_code']) {
37
+ $this->_paymentMethodCode = $params['payment_method_code'];
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Builds a HTTP Client for coinjar order API
43
+ *
44
+ * @return Varien_Http_Client
45
+ */
46
+ public function buildClient()
47
+ {
48
+ $clientUrl = $this->_getConfig()->getApiUrl();
49
+
50
+ $client = new Varien_Http_Client($clientUrl);
51
+ $client->setAuth($this->_getConfig()->getMerchantUuid(), $this->_getConfig()->getMerchantSecret());
52
+ $client->setMethod(Varien_Http_Client::POST);
53
+
54
+ return $client;
55
+ }
56
+
57
+ /**
58
+ * Builds POST parameters for use in a Varien_Http_Client request
59
+ *
60
+ * @return array
61
+ */
62
+ public function buildRequestParams($orderId = null, $reference = null)
63
+ {
64
+ $orderId = is_null($orderId) ? $this->_getCheckoutSession()->getLastRealOrderId() : $orderId;
65
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
66
+ $grandTotal = $order->getGrandTotal();
67
+ $subTotal = $order->getSubtotal();
68
+ $shippingHandling = $order->getShippingAmount();
69
+
70
+ $postParams = array();
71
+ $postParams['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
72
+ $postParams['merchant_invoice'] = $orderId;
73
+ $postParams['merchant_reference'] = is_null($reference) ? $orderId : $reference;
74
+ $postParams['return_url'] = Mage::getUrl('cjcheckout/standard/success');
75
+ $postParams['cancel_url'] = Mage::getUrl('cjcheckout/standard/cancel');
76
+ $postParams['notify_url'] = Mage::getUrl('cjcheckout/standard/notify');
77
+ $postParams['order_items_attributes'] = array();
78
+
79
+ foreach ($order->getItemsCollection()->getItems() as $item) {
80
+ $sku = $item->getSku();
81
+ $unitPrice = $item->getPrice();
82
+ $qty = $item->getQtyOrdered();
83
+ $desc = $item->getName();
84
+ array_push($postParams['order_items_attributes'], array(
85
+ 'name' => $desc,
86
+ 'quantity' => $qty,
87
+ 'amount' => $unitPrice
88
+ ));
89
+ }
90
+ array_push($postParams['order_items_attributes'], array(
91
+ 'name' => 'Shipping and handling',
92
+ 'quantity' => 1,
93
+ 'amount' => $shippingHandling
94
+ ));
95
+
96
+ Mage::helper('cjcheckout')->log('POST: ' . print_r($postParams, true));
97
+
98
+ return $postParams;
99
+ }
100
+
101
+ /**
102
+ * Return checkout quote object
103
+ *
104
+ * @return Mage_Sale_Model_Quote
105
+ */
106
+ protected function _getQuote()
107
+ {
108
+ if (!$this->_quote) {
109
+ $this->_getCheckoutSession()->setQuoteId($this->_getQuoteId());
110
+ $this->_quote = $this->_getCheckoutSession()->getQuote();
111
+ }
112
+ return $this->_quote;
113
+ }
114
+
115
+ /**
116
+ * Return quote ID
117
+ *
118
+ * @return Mage_Sale_Model_Quote
119
+ */
120
+ protected function _getQuoteId()
121
+ {
122
+ if (!$this->_quoteId) {
123
+ $this->_quoteId = $this->_getCheckoutSession()->getData('coinjar_quote_id', true);
124
+ }
125
+ return $this->_quoteId;
126
+ }
127
+
128
+ /**
129
+ * Return checkout session object
130
+ *
131
+ * @return Mage_Checkout_Model_Session
132
+ */
133
+ protected function _getCheckoutSession()
134
+ {
135
+ return Mage::getSingleton('checkout/session');
136
+ }
137
+
138
+ /**
139
+ * Protected getter for config model object
140
+ *
141
+ * @return CoinJar_CJCheckout_Model_Config
142
+ */
143
+ protected function _getConfig()
144
+ {
145
+ if (is_null($this->_config)) {
146
+ $this->_config = Mage::getModel('cjcheckout/config', array($this->_paymentMethodCode, Mage::app()->getStore()->getId()));
147
+ }
148
+ return $this->_config;
149
+ }
150
+ }
app/code/community/CoinJar/CJCheckout/Model/Config.php ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category CoinJar
22
+ * @package CoinJar_CJCheckout
23
+ * @copyright Copyright (c) 2014 CoinJar (http://coinjar.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class CoinJar_CJCheckout_Model_Config
28
+ {
29
+ /**
30
+ * CoinJar Standard
31
+ *
32
+ * @var string
33
+ */
34
+ const METHOD_CJ_STANDARD = 'cjcheckout_standard';
35
+
36
+ /**
37
+ * Refund types
38
+ *
39
+ * @var string
40
+ */
41
+ const REFUND_TYPE_FULL = 'Full';
42
+ const REFUND_TYPE_PARTIAL = 'Partial';
43
+
44
+ /**
45
+ * Current store id
46
+ *
47
+ * @var int
48
+ */
49
+ protected $_storeId = null;
50
+
51
+ /**
52
+ * Current store id
53
+ *
54
+ * @var bool
55
+ */
56
+ protected $_sandboxFlag = null;
57
+
58
+ /**
59
+ * Current method code
60
+ *
61
+ * @var bool
62
+ */
63
+ protected $_methodCode = null;
64
+
65
+ /**
66
+ * Currency codes supported by CoinJar Order API
67
+ *
68
+ * @var array
69
+ */
70
+ protected $_supportedCurrencyCodes = array('BTC', 'USD', 'AUD', 'NZD', 'CAD', 'EUR', 'GBP', 'SGD', 'HKD', 'CHF', 'JPY');
71
+
72
+ /**
73
+ * Set method and store id, if specified
74
+ *
75
+ * @param array $params
76
+ */
77
+ public function __construct($params = array())
78
+ {
79
+ if ($params) {
80
+ $method = array_shift($params);
81
+ $this->setMethod($method);
82
+ if ($params) {
83
+ $storeId = array_shift($params);
84
+ $this->setStoreId($storeId);
85
+ }
86
+ }
87
+ $this->setSandboxFlag($this->getConfigData('sandbox'));
88
+ }
89
+
90
+ /**
91
+ * Method code setter
92
+ *
93
+ * @param string|Mage_Payment_Model_Method_Abstract $method
94
+ * @return CoinJar_CJCheckout_Model_Config
95
+ */
96
+ public function setMethod($method)
97
+ {
98
+ if ($method instanceof Mage_Payment_Model_Method_Abstract) {
99
+ $this->_methodCode = $method->getCode();
100
+ } elseif (is_string($method)) {
101
+ $this->_methodCode = $method;
102
+ }
103
+ return $this;
104
+ }
105
+
106
+ /**
107
+ * Store ID setter
108
+ *
109
+ * @param int $storeId
110
+ * @return CoinJar_CJCheckout_Model_Config
111
+ */
112
+ public function setStoreId($storeId)
113
+ {
114
+ $this->_storeId = (int)$storeId;
115
+ return $this;
116
+ }
117
+
118
+ /**
119
+ * Sandbox Flag setter
120
+ *
121
+ * @param int $sandboxFlag
122
+ * @return CoinJar_CJCheckout_Model_Config
123
+ */
124
+ public function setSandboxFlag($sandboxFlag)
125
+ {
126
+ $this->_sandboxFlag = (bool)$sandboxFlag;
127
+ return $this;
128
+ }
129
+
130
+ /**
131
+ * CoinJar API URL generic getter
132
+ *
133
+ * @param array $params
134
+ * @return string
135
+ */
136
+ public function getApiUrl(array $params = array())
137
+ {
138
+ return sprintf('https://checkout.%scoinjar.io/api/v1/orders.json',
139
+ $this->_sandboxFlag ? 'sandbox.' : '',
140
+ $params ? '?' . http_build_query($params) : ''
141
+ );
142
+ }
143
+
144
+ /**
145
+ * CoinJar API URL generic getter
146
+ *
147
+ * @param array $params
148
+ * @return string
149
+ */
150
+ public function getCoinjarOrderUrl(array $params = array())
151
+ {
152
+ return sprintf('https://checkout.%scoinjar.io/orders',
153
+ $this->_sandboxFlag ? 'sandbox.' : '',
154
+ $params ? '?' . http_build_query($params) : ''
155
+ );
156
+ }
157
+
158
+ /**
159
+ * CoinJar Merchant UUID getter
160
+ *
161
+ * @param array $params
162
+ * @return string
163
+ */
164
+ public function getMerchantUuid()
165
+ {
166
+ return Mage::helper('core')->decrypt($this->getConfigData('merchantuuid'));
167
+ }
168
+
169
+ /**
170
+ * CoinJar Merchant Secret getter
171
+ *
172
+ * @param array $params
173
+ * @return string
174
+ */
175
+ public function getMerchantSecret()
176
+ {
177
+ return Mage::helper('core')->decrypt($this->getConfigData('merchantsecret'));
178
+ }
179
+
180
+ /**
181
+ * Check whether specified currency code is supported
182
+ *
183
+ * @param string $code
184
+ * @return bool
185
+ */
186
+ public function isCurrencyCodeSupported($code)
187
+ {
188
+ if (in_array($code, $this->_supportedCurrencyCodes)) {
189
+ return true;
190
+ }
191
+ return false;
192
+ }
193
+
194
+ /**
195
+ * Retrieve information from payment configuration
196
+ *
197
+ * @param string $field
198
+ * @return mixed
199
+ */
200
+ public function getConfigData($field)
201
+ {
202
+ $path = 'payment/'.$this->_methodCode.'/'.$field;
203
+ return Mage::getStoreConfig($path, $this->_storeId);
204
+ }
205
+
206
+ }
207
+
app/code/community/CoinJar/CJCheckout/Model/Ipn.php ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category CoinJar
22
+ * @package CoinJar_CJCheckout
23
+ * @copyright Copyright (c) 2014 CoinJar (http://coinjar.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class CoinJar_CJCheckout_Model_Ipn
28
+ {
29
+ protected $_ipnData = array();
30
+ protected $_paymentMethodCode = null;
31
+ protected $_config = null;
32
+
33
+ public function __construct($params)
34
+ {
35
+ if ($params['payment_method_code']) {
36
+ $this->_paymentMethodCode = $params['payment_method_code'];
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Setter for IPN data
42
+ *
43
+ * @param $data
44
+ * @return CoinJar_CJCheckout_Model_Ipn
45
+ */
46
+ public function setIpnData(Array $data)
47
+ {
48
+ $this->_ipnData = $data;
49
+ return $this;
50
+ }
51
+
52
+ /**
53
+ * Getter for IPN data
54
+ *
55
+ * @param $key
56
+ * @return mixed
57
+ */
58
+ public function getIpnData($key)
59
+ {
60
+ return $key ? $this->_ipnData[$key] : $this->_ipnData;
61
+ }
62
+
63
+ /**
64
+ * Return checkout quote object
65
+ *
66
+ * @return Mage_Sale_Model_Quote
67
+ */
68
+ public function verify()
69
+ {
70
+ if (!$this->_validateIpnData()) {
71
+ return false;
72
+ }
73
+
74
+ if (Mage::helper('cjcheckout/checkout')->debugIpn()) {
75
+ return true;
76
+ }
77
+
78
+ $merchantSecret = $this->_getConfig()->getMerchantSecret();
79
+ $combinedPost = $this->getIpnData('uuid')
80
+ . $this->getIpnData('amount')
81
+ . $this->getIpnData('currency')
82
+ . $this->getIpnData('status');
83
+
84
+ $hmac = hash_hmac(
85
+ 'sha256',
86
+ $combinedPost,
87
+ $merchantSecret,
88
+ FALSE
89
+ );
90
+
91
+ return $hmac == $this->getIpnData('ipn_digest');
92
+ }
93
+
94
+ /**
95
+ * Validate that all of the necessary stored IPN data is present.
96
+ *
97
+ * @return bool
98
+ */
99
+ protected function _validateIpnData()
100
+ {
101
+ return !(
102
+ is_null($this->getIpnData('ipn_digest'))
103
+ || is_null($this->getIpnData('uuid'))
104
+ || is_null($this->getIpnData('amount'))
105
+ || is_null($this->getIpnData('currency'))
106
+ || is_null($this->getIpnData('status'))
107
+ || is_null($this->getIpnData('merchant_invoice'))
108
+ );
109
+ }
110
+
111
+ /**
112
+ * Process payment, create and pay invoice
113
+ *
114
+ * @return bool
115
+ */
116
+ public function processPayment()
117
+ {
118
+ try {
119
+ $orderIncrementId = $this->getIpnData('merchant_invoice');
120
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
121
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
122
+ $invoice = $order->prepareInvoice()
123
+ ->setTransactionId(1)
124
+ ->addComment('Payment of ' . $this->getIpnData('amount') . ' received by CoinJar Checkout (' . $this->getIpnData('ipn_digest') . ')')
125
+ ->register()
126
+ ->pay();
127
+
128
+ $transactionSave = Mage::getModel('core/resource_transaction')
129
+ ->addObject($invoice)
130
+ ->addObject($invoice->getOrder());
131
+
132
+ $transactionSave->save();
133
+
134
+ return true;
135
+ } catch (Exception $e) {
136
+
137
+ }
138
+ }
139
+
140
+ /**
141
+ * Protected getter for config model object
142
+ *
143
+ * @return CoinJar_CJCheckout_Model_Config
144
+ */
145
+ protected function _getConfig()
146
+ {
147
+ if (is_null($this->_config)) {
148
+ $this->_config = Mage::getModel('cjcheckout/config', array($this->_paymentMethodCode, Mage::app()->getStore()->getId()));
149
+ }
150
+ return $this->_config;
151
+ }
152
+ }
app/code/community/CoinJar/CJCheckout/Model/Standard.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category CoinJar
22
+ * @package CoinJar_CJCheckout
23
+ * @copyright Copyright (c) 2014 CoinJar (http://coinjar.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class CoinJar_CJCheckout_Model_Standard extends CoinJar_CJCheckout_Model_Abstract
28
+ {
29
+ protected $_code = CoinJar_CJCheckout_Model_Config::METHOD_CJ_STANDARD;
30
+ protected $_orderUuid = null;
31
+ protected $_formBlockType = 'cjcheckout/standard_form';
32
+
33
+ /**
34
+ * Availability options
35
+ */
36
+ // protected $_isGateway = true;
37
+ // protected $_canOrder = true;
38
+ protected $_canAuthorize = true;
39
+ // protected $_canCapture = true;
40
+ // protected $_canCapturePartial = true;
41
+ // protected $_canRefund = true;
42
+ // protected $_canRefundInvoicePartial = true;
43
+ // protected $_canVoid = true;
44
+ protected $_canUseInternal = false;
45
+ protected $_canUseCheckout = true;
46
+ protected $_canUseForMultishipping = false;
47
+ // protected $_canFetchTransactionInfo = true;
48
+ protected $_canCreateBillingAgreement = false;
49
+ // protected $_canReviewPayment = true;
50
+ protected $_isInitializeNeeded = true;
51
+
52
+ public function _construct()
53
+ {
54
+ parent::_construct();
55
+ $this->_init('cjcheckout/standard');
56
+ }
57
+
58
+ /**
59
+ * Return Order place redirect url
60
+ *
61
+ * @return string
62
+ */
63
+ public function getOrderPlaceRedirectUrl()
64
+ {
65
+ return Mage::getUrl('cjcheckout/standard/redirect', array('_secure' => true));
66
+ }
67
+
68
+
69
+ public function authorize(Varien_Object $payment, $amount)
70
+ {
71
+ return $this;
72
+ }
73
+
74
+ /**
75
+ * Instantiate state and set it to state object
76
+ *
77
+ * @param string $paymentAction
78
+ * @param Varien_Object
79
+ */
80
+ public function initialize($paymentAction, $stateObject)
81
+ {
82
+ $state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
83
+ $stateObject->setState($state);
84
+ $stateObject->setStatus('pending_payment');
85
+ $stateObject->setIsNotified(false);
86
+ }
87
+
88
+ }
app/code/community/CoinJar/CJCheckout/controllers/StandardController.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category CoinJar
22
+ * @package CoinJar_CJCheckout
23
+ * @copyright Copyright (c) 2014 CoinJar (http://coinjar.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class CoinJar_CJCheckout_StandardController extends CoinJar_CJCheckout_Controller_Standard
28
+ {
29
+
30
+ }
app/code/community/CoinJar/CJCheckout/etc/.DS_Store ADDED
Binary file
app/code/community/CoinJar/CJCheckout/etc/config.xml ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <CoinJar_CJCheckout>
5
+ <version>0.1.0</version>
6
+ </CoinJar_CJCheckout>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <cjcheckout>
11
+ <class>CoinJar_CJCheckout_Block</class>
12
+ </cjcheckout>
13
+ </blocks>
14
+ <models>
15
+ <cjcheckout>
16
+ <class>CoinJar_CJCheckout_Model</class>
17
+ </cjcheckout>
18
+ </models>
19
+ <helpers>
20
+ <cjcheckout>
21
+ <class>CoinJar_CJCheckout_Helper</class>
22
+ </cjcheckout>
23
+ </helpers>
24
+ <payment>
25
+ <groups>
26
+ <cjcheckout>CJCheckout</cjcheckout>
27
+ </groups>
28
+ </payment>
29
+ </global>
30
+ <default>
31
+ <payment>
32
+ <cjcheckout_standard>
33
+ <model>cjcheckout/standard</model>
34
+ <group>cjcheckout</group>
35
+ <active>1</active>
36
+ <title>Bitcoin (via CoinJar)</title>
37
+ <payment_action>authorize</payment_action>
38
+ <allowspecific>0</allowspecific>
39
+ </cjcheckout_standard>
40
+ </payment>
41
+ <payment_services>
42
+ <coinjar>
43
+ <displaynotice>1</displaynotice>
44
+ <ipn>1</ipn>
45
+ <debuglog>0</debuglog>
46
+ <enableipndebug>0</enableipndebug>
47
+ </coinjar>
48
+ </payment_services>
49
+ <cjcheckout>
50
+ <settings>
51
+ <activationstatus>0</activationstatus>
52
+ </settings>
53
+ </cjcheckout>
54
+ </default>
55
+ <frontend>
56
+ <secure_url>
57
+ <cjcheckout_processing>/cjcheckout/standard</cjcheckout_processing>
58
+ </secure_url>
59
+ <routers>
60
+ <cjcheckout>
61
+ <use>standard</use>
62
+ <args>
63
+ <module>CoinJar_CJCheckout</module>
64
+ <frontName>cjcheckout</frontName>
65
+ </args>
66
+ </cjcheckout>
67
+ </routers>
68
+ <layout>
69
+ <updates>
70
+ <coinjar>
71
+ <file>coinjar.xml</file>
72
+ </coinjar>
73
+ </updates>
74
+ </layout>
75
+ </frontend>
76
+ </config>
app/code/community/CoinJar/CJCheckout/etc/system.xml ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <payment_services>
5
+ <groups>
6
+ <coinjar translate="label" module="cjcheckout">
7
+ <label>CoinJar</label>
8
+ <sort_order>700</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>0</show_in_website>
11
+ <show_in_store>0</show_in_store>
12
+ <fields>
13
+ <displaynotice translate="label">
14
+ <label>Enable "Incomplete Order" Notice</label>
15
+ <comment><![CDATA[Displays a sitewide notice and timer to any customer with an incomplete CoinJar Order. ]]></comment>
16
+ <frontend_type>select</frontend_type>
17
+ <source_model>adminhtml/system_config_source_yesno</source_model>
18
+ <sort_order>1</sort_order>
19
+ <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>
21
+ <show_in_store>1</show_in_store>
22
+ </displaynotice>
23
+ <ipn translate="label">
24
+ <label>Enable IPN?</label>
25
+ <comment><![CDATA[Set to 'Yes' to allow CoinJar to send payment confirmations to your server via IPN. ]]></comment>
26
+ <frontend_type>select</frontend_type>
27
+ <source_model>adminhtml/system_config_source_yesno</source_model>
28
+ <sort_order>3</sort_order>
29
+ <show_in_default>1</show_in_default>
30
+ <show_in_website>0</show_in_website>
31
+ <show_in_store>0</show_in_store>
32
+ </ipn>
33
+ <debuglog translate="label">
34
+ <label>Enable CoinJar Magento Logging</label>
35
+ <frontend_type>select</frontend_type>
36
+ <source_model>adminhtml/system_config_source_yesno</source_model>
37
+ <sort_order>1</sort_order>
38
+ <show_in_default>1</show_in_default>
39
+ <show_in_website>0</show_in_website>
40
+ <show_in_store>0</show_in_store>
41
+ </debuglog>
42
+ <enableipndebug translate="label">
43
+ <label>Enable IPN debug mode?</label>
44
+ <comment><![CDATA[Removes hmac checks on IPN source and allows $_GET parameters on IPN controller. Used for testing/debugging. Always set to 'No' in production. ]]></comment>
45
+ <frontend_type>select</frontend_type>
46
+ <source_model>adminhtml/system_config_source_yesno</source_model>
47
+ <sort_order>3</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>0</show_in_website>
50
+ <show_in_store>0</show_in_store>
51
+ </enableipndebug>
52
+ </fields>
53
+ </coinjar>
54
+ </groups>
55
+ </payment_services>
56
+ <payment>
57
+ <groups>
58
+ <cjcheckout_standard translate="label" module="cjcheckout">
59
+ <label>Bitcoin via CoinJar Checkout</label>
60
+ <comment><![CDATA[Accept Bitcoins on your website via CoinJar Checkout. Get your account at <a href="https://coinjar.io">https://coinjar.io</a>.]]></comment>
61
+ <sort_order>700</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>0</show_in_store>
65
+ <fields>
66
+ <active translate="label">
67
+ <label>Enabled</label>
68
+ <frontend_type>select</frontend_type>
69
+ <source_model>adminhtml/system_config_source_yesno</source_model>
70
+ <sort_order>1</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ <show_in_store>0</show_in_store>
74
+ </active>
75
+ <title translate="label">
76
+ <label>Title</label>
77
+ <frontend_type>text</frontend_type>
78
+ <sort_order>2</sort_order>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>1</show_in_website>
81
+ <show_in_store>0</show_in_store>
82
+ </title>
83
+ <sandbox translate="label">
84
+ <label>Sandbox mode?</label>
85
+ <comment><![CDATA[If set to 'Yes' will use CoinJar Checkout in sandbox mode. Please set to 'No' for production. ]]></comment>
86
+ <frontend_type>select</frontend_type>
87
+ <source_model>adminhtml/system_config_source_yesno</source_model>
88
+ <sort_order>3</sort_order>
89
+ <show_in_default>1</show_in_default>
90
+ <show_in_website>1</show_in_website>
91
+ <show_in_store>0</show_in_store>
92
+ </sandbox>
93
+ <merchantuuid translate="label">
94
+ <label>Merchant UUID</label>
95
+ <comment><![CDATA[Your merchant UUID at CoinJar Checkout <a href="https://checkout.coinjar.io/merchant/credentials">https://checkout.coinjar.io/merchant/credentials</a>.]]></comment>
96
+ <frontend_type>text</frontend_type>
97
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
98
+ <sort_order>4</sort_order>
99
+ <show_in_default>1</show_in_default>
100
+ <show_in_website>1</show_in_website>
101
+ <show_in_store>0</show_in_store>
102
+ </merchantuuid>
103
+ <merchantsecret translate="label">
104
+ <label>Merchant Secret</label>
105
+ <comment><![CDATA[Your merchant secret at CoinJar Checkout <a href="https://checkout.coinjar.io/merchant/credentials">https://checkout.coinjar.io/merchant/credentials</a>.]]></comment>
106
+ <frontend_type>text</frontend_type>
107
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
108
+ <sort_order>5</sort_order>
109
+ <show_in_default>1</show_in_default>
110
+ <show_in_website>1</show_in_website>
111
+ <show_in_store>0</show_in_store>
112
+ </merchantsecret>
113
+ <allowspecific translate="label">
114
+ <label>Payment from Applicable Countries</label>
115
+ <frontend_type>allowspecific</frontend_type>
116
+ <config_path>payment/cjcheckout_standard/allowspecific</config_path>
117
+ <sort_order>6</sort_order>
118
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
119
+ <show_in_default>1</show_in_default>
120
+ <show_in_website>1</show_in_website>
121
+ <show_in_store>1</show_in_store>
122
+ </allowspecific>
123
+ <specificcountry translate="label">
124
+ <label>Payment from Specific Countries</label>
125
+ <frontend_type>multiselect</frontend_type>
126
+ <config_path>payment/cjcheckout_standard/specificcountry</config_path>
127
+ <sort_order>7</sort_order>
128
+ <source_model>adminhtml/system_config_source_country</source_model>
129
+ <show_in_default>1</show_in_default>
130
+ <show_in_website>1</show_in_website>
131
+ <show_in_store>1</show_in_store>
132
+ <can_be_empty>1</can_be_empty>
133
+ </specificcountry>
134
+ </fields>
135
+ </cjcheckout_standard>
136
+ </groups>
137
+ </payment>
138
+ </sections>
139
+ </config>
app/design/frontend/base/default/layout/coinjar.xml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * @category design
23
+ * @package base_default
24
+ * @copyright Copyright (c) 2014 CoinJar (http://coinjar.com)
25
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
+ */
27
+
28
+ -->
29
+ <layout version="0.1.0">
30
+ <default>
31
+ <reference name="global_notices">
32
+ <action method="setTemplate">
33
+ <template>coinjar/notices.phtml</template>
34
+ </action>
35
+ </reference>
36
+ <reference name="head">
37
+ <action method="addItem"><type>skin_css</type><file>css/coinjar.css</file></action>
38
+ </reference>
39
+ </default>
40
+ </layout>
app/etc/modules/CoinJar_CJCheckout.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <CoinJar_CJCheckout>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </CoinJar_CJCheckout>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>CoinJar_CJCheckout</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/GPL-3.0">GNU General Public License (GPL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Accept Bitcoin on your Magento Store with CoinJar</summary>
10
+ <description>This plugin will allow you to integrate CoinJar checkout into your website. CoinJar Checkout allows you to accept bitcoin and receive the Australian dollar amount of the product to your bank account. Learn more about CoinJar For Business here - https://www.coinjar.com/business. </description>
11
+ <notes>First release</notes>
12
+ <authors><author><name>Mike Bywaters</name><user>mbywaters</user><email>mbywaters@internode.on.net</email></author></authors>
13
+ <date>2014-08-27</date>
14
+ <time>12:37:00</time>
15
+ <contents><target name="magecommunity"><dir name="CoinJar"><dir name="CJCheckout"><dir name="Block"><dir name="Standard"><file name="Form.php" hash="ab5474dcfabf4733adad44202a34b2cf"/></dir><file name=".DS_Store" hash="2bf4f1e140aa33dae2095a3e3aadf8f9"/></dir><dir name="Controller"><file name="Abstract.php" hash="be4e139e510d69c6ecfab21e11a85c5e"/><file name="Standard.php" hash="d9de025b1571ce1e964c6a61a0aee5d2"/></dir><dir name="Helper"><file name="Checkout.php" hash="fab8aef2aec1f4bad07a38453cfa7bbf"/><file name="Data.php" hash="d3b8793c420df2e620c1df6dcf3b1fb5"/></dir><dir name="Model"><file name="Abstract.php" hash="98ef9da9e194cc6492f019cfa7ddd0cc"/><file name="Api.php" hash="71794a054a5231e1fee57e6ffd6be26f"/><file name="Config.php" hash="641a37f18882b6309f3c8531a719ef77"/><file name="Ipn.php" hash="37c4d1b0c6a22c0e3e7d97534678455f"/><file name="Standard.php" hash="8f92c7c1c89b6691b8c9365ba1664a67"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="controllers"><file name="StandardController.php" hash="c33bebab08572f28b2dbd07ceab31851"/></dir><dir name="etc"><file name="config.xml" hash="f6a1eb3e0675151051c612a48a8da92a"/><file name="system.xml" hash="a5a1846e932a7b7ac4d99fbba6ec7149"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="241729b9fbe086abddd0d2f6c2e4d616"/></dir><file name=".DS_Store" hash="9f39bc15796e1e92c73ac7c77064c629"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="coinjar.css" hash="3a22b515357c167a88b27ac3a5cc345f"/></dir><dir name="images"><file name="coinjar_logo.svg" hash="0a2a01bc3365755598f3e98a3004ee80"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="CoinJar_CJCheckout.xml" hash="6b2c5bbaefd6923e878794f7bf0e9a3c"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="coinjar.xml" hash="02360172288e8ca0ecdc3d7562c19240"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/frontend/base/default/css/coinjar.css ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* CoinJar Notice */
2
+ #coinjar-order-notice {
3
+ margin: 0;
4
+ border: 0;
5
+ background-color: #1F3852;
6
+ font-family: Avenir, 'Helvetica Neue', Helvetica, Arial, sans-serif;
7
+ font-weight: lighter;
8
+ font-size: 14px;
9
+ color: #FAA628;
10
+ }
11
+ #coinjar-order-notice .logo {
12
+ width: 54px;
13
+ height: 41px;
14
+ margin-top: -1px;
15
+ margin-right: 20px;
16
+ background-image: url('../images/coinjar_logo.svg');
17
+ }
18
+ #coinjar-order-notice .notice-inner {
19
+ padding: 25px 0;
20
+ line-height: 1.15;
21
+ background: none;
22
+ }
23
+ #coinjar-order-notice .notice-inner p {
24
+ padding: 0;
25
+ border: 0;
26
+ line-height: 38px;
27
+ }
28
+ #coinjar-order-notice .notice-inner p a.btn:hover {
29
+ background: #A9D7F7;
30
+ border: 1px solid #7AC3F3;
31
+ color: #1F3852;
32
+ }
33
+ #coinjar-order-notice .notice-inner p a.btn {
34
+ border: 1px solid #7AC3F3;
35
+ background: none;
36
+ color: #7AC3F3;
37
+ padding: 9px 12px 10px;
38
+ line-height: 22px;
39
+ text-decoration: none;
40
+ text-shadow: none;
41
+ -webkit-border-radius: 24px;
42
+ -moz-border-radius: 24px;
43
+ border-radius: 24px;
44
+ -webkit-box-shadow: none;
45
+ -moz-box-shadow: none;
46
+ box-shadow: none;
47
+ -webkit-transition: 0.15s;
48
+ -moz-transition: 0.15s;
49
+ -o-transition: 0.15s;
50
+ transition: 0.15s;
51
+ -webkit-backface-visibility: hidden;
52
+ font-size: 14px;
53
+ font-weight: 500;
54
+ display: inline-block;
55
+ margin: -2px 0 0 10px;
56
+ text-align: center;
57
+ vertical-align: middle;
58
+ cursor: pointer;
59
+ float: right;
60
+ }
61
+
62
+ @media only screen and (max-width: 767px) {
63
+ #coinjar-order-notice .logo {
64
+ display: inline-block;
65
+ float: none;
66
+ vertical-align: middle;
67
+ margin-right: 40px;
68
+ }
69
+ #coinjar-order-notice span.message {
70
+ display: block;
71
+ margin-top: 14px;
72
+ }
73
+ #coinjar-order-notice .notice-inner {
74
+ text-align: center;
75
+ width: auto;
76
+ padding: 22px 0 18px 0;
77
+ }
78
+ #coinjar-order-notice .notice-inner p {
79
+ line-height: 20px;
80
+ }
81
+ #coinjar-order-notice .notice-inner p a.btn {
82
+ float: none;
83
+ }
84
+ }
skin/frontend/base/default/images/coinjar_logo.svg ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
4
+ <svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ viewBox="0 0 72 54.4" enable-background="new 0 0 72 54.4" xml:space="preserve">
6
+ <g>
7
+ <path fill="#F69325" d="M12.6,40.7c4.7,8,13.4,13.5,23.3,13.5c10,0,18.7-5.4,23.3-13.5H12.6z"/>
8
+ <path opacity="0.2" d="M71.9,40.7l-4.5-9h-4.9c-0.5,3.2-1.7,6.2-3.2,9H71.9z"/>
9
+ <path opacity="0.2" d="M4.6,31.7l-4.5,9h12.6c-1.6-2.7-2.7-5.7-3.2-9H4.6z"/>
10
+ <path fill="#FAA526" d="M36,0.3c-14.9,0-27,12-27,26.9c0,1.5,0.1,3,0.4,4.5c0.5,3.2,1.7,6.2,3.2,9h46.7c1.6-2.7,2.7-5.7,3.2-9
11
+ c0.2-1.5,0.4-3,0.4-4.5C62.9,12.4,50.9,0.3,36,0.3z"/>
12
+ </g>
13
+ </svg>