Apruve_B2B_Payment_Gateway - Version 1.0.6

Version Notes

Stable Version

Download this release

Release Info

Developer Magento Core Team
Extension Apruve_B2B_Payment_Gateway
Version 1.0.6
Comparing to
See all releases


Code changes from version 1.0.5 to 1.0.6

Files changed (29) hide show
  1. app/code/community/Apruve/ApruvePayment/Block/Admin/Webhook.php +39 -39
  2. app/code/community/Apruve/ApruvePayment/Block/Payment/Form.php +50 -50
  3. app/code/community/Apruve/ApruvePayment/Block/Review.php +0 -70
  4. app/code/community/Apruve/ApruvePayment/Block/Review/Billing.php +0 -47
  5. app/code/community/Apruve/ApruvePayment/Block/Review/Details.php +0 -51
  6. app/code/community/Apruve/ApruvePayment/Block/Review/Result.php +0 -25
  7. app/code/community/Apruve/ApruvePayment/Block/Review/Shipping.php +0 -41
  8. app/code/community/Apruve/ApruvePayment/Helper/Data.php +30 -40
  9. app/code/community/Apruve/ApruvePayment/Model/Api/Abstract.php +111 -111
  10. app/code/community/Apruve/ApruvePayment/Model/Api/PaymentRequest.php +272 -254
  11. app/code/community/Apruve/ApruvePayment/Model/Api/Rest.php +132 -132
  12. app/code/community/Apruve/ApruvePayment/Model/PaymentMethod.php +22 -33
  13. app/code/community/Apruve/ApruvePayment/Model/Session.php +0 -28
  14. app/code/community/Apruve/ApruvePayment/controllers/PaymentController.php +0 -173
  15. app/code/community/Apruve/ApruvePayment/controllers/WebhookController.php +111 -120
  16. app/code/community/Apruve/ApruvePayment/etc/config.xml +75 -74
  17. app/design/frontend/base/default/layout/apruvepayment.xml +7 -48
  18. app/design/frontend/base/default/template/apruvepayment/head.phtml +26 -26
  19. app/design/frontend/base/default/template/apruvepayment/payment/form.phtml +24 -24
  20. app/design/frontend/base/default/template/apruvepayment/payment/mark.phtml +32 -33
  21. app/design/frontend/base/default/template/apruvepayment/review.phtml +0 -96
  22. app/design/frontend/base/default/template/apruvepayment/review/address.phtml +0 -392
  23. app/design/frontend/base/default/template/apruvepayment/review/details.phtml +0 -54
  24. app/design/frontend/base/default/template/apruvepayment/review/result.phtml +0 -22
  25. app/design/frontend/base/default/template/apruvepayment/review/shipping/method.phtml +0 -48
  26. app/design/frontend/base/default/template/apruvepayment/review/shipping_method.phtml +0 -38
  27. app/etc/modules/Apruve_ApruvePayment.xml +7 -7
  28. js/Apruve/ApruvePayment.js +1 -32
  29. package.xml +4 -4
app/code/community/Apruve/ApruvePayment/Block/Admin/Webhook.php CHANGED
@@ -1,40 +1,40 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Apache License, Version 2.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/Apache-2.0
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@apruve.com so we can send you a copy immediately.
14
- *
15
- * @category Apruve
16
- * @package Apruve_Payment
17
- * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
18
- * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
19
- */
20
-
21
- class Apruve_ApruvePayment_Block_Admin_Webhook extends Mage_Adminhtml_Block_System_Config_Form_Field
22
- {
23
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
24
- {
25
- $merchantKey = Mage::getStoreConfig('payment/apruvepayment/merchant');
26
- $apiKey = Mage::getStoreConfig('payment/apruvepayment/api');
27
- $baseFrontUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
28
- $moduleControllerAction = 'apruvepayment/webhook/updateOrderStatus?';
29
- if(!is_null($merchantKey) && !is_null($apiKey)) {
30
- $data = $apiKey.$merchantKey;
31
- $q = hash('sha256', $data);
32
- $url = $baseFrontUrl.$moduleControllerAction.$q;
33
- return $url;
34
- } else {
35
-
36
- $message = 'Please, specify merchant and api key';
37
- return $message;
38
- }
39
- }
40
}
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Apache License, Version 2.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/Apache-2.0
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@apruve.com so we can send you a copy immediately.
14
+ *
15
+ * @category Apruve
16
+ * @package Apruve_Payment
17
+ * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
18
+ * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
19
+ */
20
+
21
+ class Apruve_ApruvePayment_Block_Admin_Webhook extends Mage_Adminhtml_Block_System_Config_Form_Field
22
+ {
23
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
24
+ {
25
+ $merchantKey = Mage::getStoreConfig('payment/apruvepayment/merchant');
26
+ $apiKey = Mage::getStoreConfig('payment/apruvepayment/api');
27
+ $baseFrontUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
28
+ $moduleControllerAction = 'apruvepayment/webhook/updateOrderStatus?';
29
+ if(!is_null($merchantKey) && !is_null($apiKey)) {
30
+ $data = $apiKey.$merchantKey;
31
+ $q = hash('sha256', $data);
32
+ $url = $baseFrontUrl.$moduleControllerAction.$q;
33
+ return $url;
34
+ } else {
35
+
36
+ $message = 'Please, specify merchant and api key';
37
+ return $message;
38
+ }
39
+ }
40
}
app/code/community/Apruve/ApruvePayment/Block/Payment/Form.php CHANGED
@@ -1,51 +1,51 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Apache License, Version 2.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/Apache-2.0
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@apruve.com so we can send you a copy immediately.
14
- *
15
- * @category Apruve
16
- * @package Apruve_Payment
17
- * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
18
- * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
19
- */
20
-
21
- class Apruve_ApruvePayment_Block_Payment_Form extends Mage_Payment_Block_Form
22
- {
23
- protected function _construct()
24
- {
25
- parent::_construct();
26
- $this->setTemplate('apruvepayment/payment/form.phtml');
27
- }
28
-
29
- /**
30
- * Check if payment method has title
31
- * @return bool
32
- */
33
- public function hasMethodTitle()
34
- {
35
- return true;
36
- }
37
-
38
- /**
39
- * Set Mark template
40
- */
41
- public function getMethodTitle()
42
- {
43
- $title = $this->getMethod()->getTitle(); //title set in admin area
44
-
45
- $mark = Mage::getConfig()->getBlockClassName('core/template');
46
- $mark = new $mark;
47
- $mark->setTemplate('apruvepayment/payment/mark.phtml');
48
-
49
- $this->setMethodLabelAfterHtml($title.$mark->toHtml());
50
- }
51
}
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Apache License, Version 2.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/Apache-2.0
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@apruve.com so we can send you a copy immediately.
14
+ *
15
+ * @category Apruve
16
+ * @package Apruve_Payment
17
+ * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
18
+ * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
19
+ */
20
+
21
+ class Apruve_ApruvePayment_Block_Payment_Form extends Mage_Payment_Block_Form
22
+ {
23
+ protected function _construct()
24
+ {
25
+ parent::_construct();
26
+ $this->setTemplate('apruvepayment/payment/form.phtml');
27
+ }
28
+
29
+ /**
30
+ * Check if payment method has title
31
+ * @return bool
32
+ */
33
+ public function hasMethodTitle()
34
+ {
35
+ return true;
36
+ }
37
+
38
+ /**
39
+ * Set Mark template
40
+ */
41
+ public function getMethodTitle()
42
+ {
43
+ $title = $this->getMethod()->getTitle(); //title set in admin area
44
+
45
+ $mark = Mage::getConfig()->getBlockClassName('core/template');
46
+ $mark = new $mark;
47
+ $mark->setTemplate('apruvepayment/payment/mark.phtml');
48
+
49
+ $this->setMethodLabelAfterHtml($title.$mark->toHtml());
50
+ }
51
}
app/code/community/Apruve/ApruvePayment/Block/Review.php DELETED
@@ -1,70 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Magento
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Apache License, Version 2.0
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/Apache-2.0
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@apruve.com so we can send you a copy immediately.
15
- *
16
- * @category Apruve
17
- * @package Apruve_Payment
18
- * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
19
- * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
20
- */
21
-
22
- class Apruve_ApruvePayment_Block_Review extends Mage_Core_Block_Template
23
- {
24
- /**
25
- * Get url for place order action
26
- * @return string
27
- */
28
- public function getPlaceOrderUrl()
29
- {
30
- return $this->getUrl('apruvepayment/payment/placeOrder');
31
- }
32
-
33
-
34
- private function _getCheckoutSession()
35
- {
36
- return Mage::getSingleton('checkout/session');
37
- }
38
-
39
- /**
40
- * Get error
41
- * @return mixed
42
- */
43
- public function getErrors()
44
- {
45
- $errors = $this->getApruveSession()->getErrors();
46
- $this->getApruveSession()->unsetData('errors');
47
- return $errors;
48
- }
49
-
50
-
51
- /**
52
- * @return Apruve_ApruvePayment_Model_Session
53
- */
54
- public function getApruveSession()
55
- {
56
- return Mage::getSingleton('apruvepayment/session');
57
- }
58
-
59
- /**
60
- * Check if quote contain only virtual products
61
- * @return bool
62
- */
63
- public function getQuoteIsVirtual()
64
- {
65
- $quote = Mage::getSingleton('checkout/session')->getQuote();
66
- return $quote->getIsVirtual();
67
- }
68
-
69
-
70
- }
app/code/community/Apruve/ApruvePayment/Block/Review/Billing.php DELETED
@@ -1,47 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Magento
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Apache License, Version 2.0
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/Apache-2.0
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@apruve.com so we can send you a copy immediately.
15
- *
16
- * @category Apruve
17
- * @package Apruve_Payment
18
- * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
19
- * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
20
- */
21
-
22
- class Apruve_ApruvePayment_Block_Review_Billing extends Mage_Checkout_Block_Onepage_Billing
23
- {
24
- /**
25
- * Return Sales Quote Address model
26
- *
27
- * @return Mage_Sales_Model_Quote_Address
28
- */
29
- public function getAddress()
30
- {
31
- if (is_null($this->_address)) {
32
- if ($this->isCustomerLoggedIn() || $this->getQuote()->getBillingAddress()) {
33
- $this->_address = $this->getQuote()->getBillingAddress();
34
- if (!$this->_address->getFirstname()) {
35
- $this->_address->setFirstname($this->getQuote()->getCustomer()->getFirstname());
36
- }
37
- if (!$this->_address->getLastname()) {
38
- $this->_address->setLastname($this->getQuote()->getCustomer()->getLastname());
39
- }
40
- } else {
41
- $this->_address = Mage::getModel('sales/quote_address');
42
- }
43
- }
44
-
45
- return $this->_address;
46
- }
47
- }
app/code/community/Apruve/ApruvePayment/Block/Review/Details.php DELETED
@@ -1,51 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Magento
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Apache License, Version 2.0
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/Apache-2.0
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@apruve.com so we can send you a copy immediately.
15
- *
16
- * @category Apruve
17
- * @package Apruve_Payment
18
- * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
19
- * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
20
- */
21
-
22
- class Apruve_ApruvePayment_Block_Review_Details extends Mage_Checkout_Block_Cart_Totals
23
- {
24
- /**
25
- * @var Mage_Sales_Model_Order_Address
26
- */
27
- protected $_address;
28
-
29
- /**
30
- * Return review shipping address
31
- *
32
- * @return Mage_Sales_Model_Order_Address
33
- */
34
- public function getAddress()
35
- {
36
- if (empty($this->_address)) {
37
- $this->_address = $this->getQuote()->getShippingAddress();
38
- }
39
- return $this->_address;
40
- }
41
-
42
- /**
43
- * Return review quote totals
44
- *
45
- * @return array
46
- */
47
- public function getTotals()
48
- {
49
- return $this->getQuote()->getTotals();
50
- }
51
- }
app/code/community/Apruve/ApruvePayment/Block/Review/Result.php DELETED
@@ -1,25 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Magento
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Apache License, Version 2.0
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/Apache-2.0
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@apruve.com so we can send you a copy immediately.
15
- *
16
- * @category Apruve
17
- * @package Apruve_Payment
18
- * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
19
- * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
20
- */
21
-
22
- class Apruve_ApruvePayment_Block_Review_Result extends Mage_Core_Block_Template
23
- {
24
-
25
- }
app/code/community/Apruve/ApruvePayment/Block/Review/Shipping.php DELETED
@@ -1,41 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Magento
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Apache License, Version 2.0
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/Apache-2.0
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@apruve.com so we can send you a copy immediately.
15
- *
16
- * @category Apruve
17
- * @package Apruve_Payment
18
- * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
19
- * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
20
- */
21
-
22
- class Apruve_ApruvePayment_Block_Review_Shipping extends Mage_Checkout_Block_Onepage_Shipping
23
- {
24
- /**
25
- * Return Sales Quote Address model (shipping address)
26
- *
27
- * @return Mage_Sales_Model_Quote_Address
28
- */
29
- public function getAddress()
30
- {
31
- if (is_null($this->_address)) {
32
- if ($this->isCustomerLoggedIn() || $this->getQuote()->getShippingAddress()) {
33
- $this->_address = $this->getQuote()->getShippingAddress();
34
- } else {
35
- $this->_address = Mage::getModel('sales/quote_address');
36
- }
37
- }
38
-
39
- return $this->_address;
40
- }
41
- }
app/code/community/Apruve/ApruvePayment/Helper/Data.php CHANGED
@@ -1,41 +1,31 @@
1
- <?php
2
-
3
- /**
4
- * Magento
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Apache License, Version 2.0
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/Apache-2.0
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@apruve.com so we can send you a copy immediately.
15
- *
16
- * @category Apruve
17
- * @package Apruve_Payment
18
- * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
19
- * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
20
- */
21
-
22
- class Apruve_ApruvePayment_Helper_Data extends Mage_Core_Helper_Abstract
23
- {
24
- /**
25
- * @return Apruve_ApruvePayment_Model_Api_PaymentRequest
26
- */
27
- public function getPaymentRequestApiModel()
28
- {
29
- return Mage::getModel('apruvepayment/api_PaymentRequest');
30
- }
31
-
32
-
33
- /**
34
- * @return string url
35
- */
36
- public function getAjaxAddressUpdatedUrl()
37
- {
38
- $secure = Mage::app()->getStore()->isCurrentlySecure() ? true : false;
39
- return Mage::getUrl('apruvepayment/payment/ajaxSetAddressUpdated', array('_secure' => $secure));
40
- }
41
}
1
+ <?php
2
+
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Apache License, Version 2.0
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/Apache-2.0
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@apruve.com so we can send you a copy immediately.
15
+ *
16
+ * @category Apruve
17
+ * @package Apruve_Payment
18
+ * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
19
+ * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
20
+ */
21
+
22
+ class Apruve_ApruvePayment_Helper_Data extends Mage_Core_Helper_Abstract
23
+ {
24
+ /**
25
+ * @return Apruve_ApruvePayment_Model_Api_PaymentRequest
26
+ */
27
+ public function getPaymentRequestApiModel()
28
+ {
29
+ return Mage::getModel('apruvepayment/api_PaymentRequest');
30
+ }
31
}
app/code/community/Apruve/ApruvePayment/Model/Api/Abstract.php CHANGED
@@ -1,112 +1,112 @@
1
- <?php
2
-
3
- /**
4
- * Magento
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Apache License, Version 2.0
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/Apache-2.0
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@apruve.com so we can send you a copy immediately.
15
- *
16
- * @category Apruve
17
- * @package Apruve_Payment
18
- * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
19
- * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
20
- */
21
-
22
- abstract class Apruve_ApruvePayment_Model_Api_Abstract
23
- {
24
- /**
25
- * @var string
26
- */
27
- protected $_version = 'v3';
28
- //protected $_testMode;
29
-
30
-
31
- /**
32
- * Generate headers for rest request
33
- * @return array
34
- */
35
- protected function _getHeaders()
36
- {
37
- return array(
38
- 'Content-type: application/json',
39
- 'Apruve-Api-Key: ' . $this->_getApiKey(),
40
- );
41
- }
42
-
43
- /**
44
- * Get Merchant key from module configuration
45
- * @return string|null
46
- */
47
- protected function _getMerchantKey()
48
- {
49
- $id = Mage::getStoreConfig('payment/apruvepayment/merchant');
50
- return $id ? $id : null;
51
- }
52
-
53
- /**
54
- * Get Api key from module configuration
55
- * @return string|null
56
- */
57
- protected function _getApiKey()
58
- {
59
- $api = Mage::getStoreConfig('payment/apruvepayment/api');
60
- return $api ? $api : null;
61
-
62
- }
63
-
64
-
65
- /**
66
- * Check whether payment works in test mode
67
- * @return bool
68
- */
69
- protected function _getIsTestMode()
70
- {
71
- return Mage::getStoreConfig('payment/apruvepayment/testmode');
72
- }
73
-
74
-
75
- /**
76
- * Get Apruve base url based on mode
77
- * @param bool $secure
78
- * @return string
79
- */
80
- public function getBaseUrl($secure = false)
81
- {
82
- $http = $secure ? 'https://' : 'http://';
83
- if($this->_getIsTestMode()) {
84
- return $http.'test.apruve.com/';
85
- } else {
86
- return $http.'www.apruve.com/';
87
- }
88
- }
89
-
90
-
91
- /**
92
- * Get api url part based on version
93
- * @return string
94
- */
95
- protected function _getApiUrl()
96
- {
97
- return 'api/'.$this->_version.'/';
98
- }
99
-
100
-
101
- /**
102
- * Convert price to needed value
103
- * As current version supports only USD, convert price to cents
104
- * @param float $price
105
- * @return float
106
- */
107
- protected function _convertPrice($price)
108
- {
109
- return $price * 100;
110
- }
111
-
112
}
1
+ <?php
2
+
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Apache License, Version 2.0
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/Apache-2.0
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@apruve.com so we can send you a copy immediately.
15
+ *
16
+ * @category Apruve
17
+ * @package Apruve_Payment
18
+ * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
19
+ * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
20
+ */
21
+
22
+ abstract class Apruve_ApruvePayment_Model_Api_Abstract
23
+ {
24
+ /**
25
+ * @var string
26
+ */
27
+ protected $_version = 'v3';
28
+ //protected $_testMode;
29
+
30
+
31
+ /**
32
+ * Generate headers for rest request
33
+ * @return array
34
+ */
35
+ protected function _getHeaders()
36
+ {
37
+ return array(
38
+ 'Content-type: application/json',
39
+ 'Apruve-Api-Key: ' . $this->_getApiKey(),
40
+ );
41
+ }
42
+
43
+ /**
44
+ * Get Merchant key from module configuration
45
+ * @return string|null
46
+ */
47
+ protected function _getMerchantKey()
48
+ {
49
+ $id = Mage::getStoreConfig('payment/apruvepayment/merchant');
50
+ return $id ? $id : null;
51
+ }
52
+
53
+ /**
54
+ * Get Api key from module configuration
55
+ * @return string|null
56
+ */
57
+ protected function _getApiKey()
58
+ {
59
+ $api = Mage::getStoreConfig('payment/apruvepayment/api');
60
+ return $api ? $api : null;
61
+
62
+ }
63
+
64
+
65
+ /**
66
+ * Check whether payment works in test mode
67
+ * @return bool
68
+ */
69
+ protected function _getIsTestMode()
70
+ {
71
+ return Mage::getStoreConfig('payment/apruvepayment/testmode');
72
+ }
73
+
74
+
75
+ /**
76
+ * Get Apruve base url based on mode
77
+ * @param bool $secure
78
+ * @return string
79
+ */
80
+ public function getBaseUrl($secure = false)
81
+ {
82
+ $http = $secure ? 'https://' : 'http://';
83
+ if($this->_getIsTestMode()) {
84
+ return $http.'test.apruve.com/';
85
+ } else {
86
+ return $http.'www.apruve.com/';
87
+ }
88
+ }
89
+
90
+
91
+ /**
92
+ * Get api url part based on version
93
+ * @return string
94
+ */
95
+ protected function _getApiUrl()
96
+ {
97
+ return 'api/'.$this->_version.'/';
98
+ }
99
+
100
+
101
+ /**
102
+ * Convert price to needed value
103
+ * As current version supports only USD, convert price to cents
104
+ * @param float $price
105
+ * @return float
106
+ */
107
+ protected function _convertPrice($price)
108
+ {
109
+ return $price * 100;
110
+ }
111
+
112
}
app/code/community/Apruve/ApruvePayment/Model/Api/PaymentRequest.php CHANGED
@@ -1,254 +1,272 @@
1
- <?php
2
-
3
- /**
4
- * Magento
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Apache License, Version 2.0
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/Apache-2.0
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@apruve.com so we can send you a copy immediately.
15
- *
16
- * @category Apruve
17
- * @package Apruve_Payment
18
- * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
19
- * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
20
- */
21
-
22
-
23
- /**
24
- * Class Apruve_ApruvePayment_Model_Api_PaymentRequest
25
- * Provide methods to build paymentRequest
26
- * @see https://apruvit.atlassian.net/wiki/display/DOCCO/payment_request
27
- */
28
- class Apruve_ApruvePayment_Model_Api_PaymentRequest extends Apruve_ApruvePayment_Model_Api_Abstract
29
- {
30
- /**
31
- * Post request general fields
32
- * @var array
33
- */
34
- protected $_postFields = array(
35
- //required
36
- 'merchant_id',
37
- 'amount_cents',
38
- 'line_items' => array(),
39
- //optional
40
- 'tax_cents',
41
- 'shipping_cents',
42
- 'currency', // current only USD
43
- );
44
-
45
- /**
46
- * Line Items Fields
47
- * @var array
48
- */
49
- protected $_lineItemFields = array(
50
- //required
51
- 'title',
52
- 'amount_cents', // if qty -> should chanfe
53
- 'description',
54
- 'variant_info',
55
- 'sku',
56
- 'vendor',
57
- 'price_ea_cents',
58
- 'view_product_url',
59
- );
60
-
61
- /**
62
- * @var array
63
- */
64
- protected $_paymentRequest;
65
-
66
-
67
- public function __construct()
68
- {
69
- $this->_paymentRequest = $this->_setPaymentRequest();
70
- }
71
-
72
- /**
73
- * Get json encoded payment request
74
- * @return string
75
- */
76
- public function getPaymentRequestJSON()
77
- {
78
- return json_encode($this->_paymentRequest);
79
- }
80
-
81
- /**
82
- * Get secure hash
83
- * @see https://apruvit.atlassian.net/wiki/display/DOCCO/Checkout+Page+Tutorial#CheckoutPageTutorial-1b:CreatingaSecureHash
84
- * @return string
85
- */
86
- public function getSecureHash()
87
- {
88
- $concatString = $this->_getApiKey();
89
-
90
- foreach ($this->_paymentRequest as $val) {
91
- if(!is_array($val)) {
92
- $concatString .= $val;
93
- } else {
94
- foreach($val as $v) {
95
- foreach ($v as $s) {
96
- $concatString .= $s;
97
- }
98
-
99
- }
100
- }
101
- }
102
-
103
- return hash('sha256', $concatString);
104
- }
105
-
106
-
107
- /**
108
- * Build Payment Request Array
109
- * @return array
110
- */
111
- protected function _setPaymentRequest()
112
- {
113
- $quote = Mage::getSingleton('checkout/session')->getQuote();
114
- $paymentRequest = array(
115
- 'merchant_id' => $this->_getMerchantKey(),
116
- 'amount_cents' => $this->_convertPrice($quote->getGrandTotal()),
117
- 'currency' => 'USD',
118
- 'tax_cents' => $this->_convertPrice($quote->getShippingAddress()->getTaxAmount()),
119
- 'shipping_cents' => $this->_convertPrice($quote->getShippingAddress()->getShippingAmount()),
120
- 'line_items' => $this->_getLineItems($quote),
121
- );
122
-
123
- return $paymentRequest;
124
- }
125
-
126
- /**
127
- * Build Line items array
128
- * @param Mage_Sales_Model_Quote $quote
129
- * @return array
130
- */
131
- protected function _getLineItems($quote)
132
- {
133
- $line_items = array();
134
- foreach ($quote->getAllVisibleItems() as $item) {
135
- $qty = $item->getQty();
136
- $title = $item->getName();
137
- $amount_cents = $this->_convertPrice($item->getPrice()) * $qty;
138
- $shortDescription = $item->getShortDescription();
139
- $viewUrl = $item->getProduct()->getProductUrl(false);
140
- $priceEaCents = $this->_convertPrice($item->getPrice());
141
-
142
- $line_item = array(
143
- 'title' => $title,
144
- 'amount_cents' => $amount_cents,
145
- 'description' => $shortDescription,
146
- 'view_product_url' => $viewUrl,
147
- 'price_ea_cents' => $priceEaCents,
148
- 'quantity' => $qty,
149
-
150
- );
151
-
152
- $variantInfo = $this->_getVariantInfo($item);
153
- if($variantInfo) {
154
- $line_item['variant_info'] = $variantInfo;
155
- }
156
-
157
- $line_items[] = $line_item;
158
- }
159
-
160
- return $line_items;
161
- }
162
-
163
-
164
- /**
165
- * Get Product configuration if exits
166
- * @param Mage_Sales_Model_Quote_Item $item
167
- * @return string
168
- */
169
- protected function _getVariantInfo($item)
170
- {
171
- $result = '';
172
- $variantInfo = array();
173
- $options = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct());
174
- if(isset($options['options'])) {
175
- $opt = $this->_getProductCustomOptions($options['options']);
176
- $variantInfo = array_merge($variantInfo, $opt);
177
- }
178
- if(isset($options['attributes_info'])) {
179
- $opt = $this->_getConfigurableOptions($options['attributes_info']);
180
- $variantInfo = array_merge($variantInfo, $opt);
181
- }
182
-
183
- if(isset($options['bundle_options'])) {
184
- $opt = $this->_getBundleOptions($options['bundle_options']);
185
- $variantInfo = array_merge($variantInfo, $opt);
186
- }
187
-
188
- if(!empty($variantInfo)) {
189
- $result = $this->_getFormatedVariantInfo($variantInfo);
190
- }
191
-
192
- return $result;
193
-
194
- }
195
-
196
- /**
197
- * @param array $options
198
- * @return array
199
- */
200
- protected function _getProductCustomOptions($options)
201
- {
202
- $arr = array();
203
- foreach ($options as $option) {
204
- $arr[] = $option['label'].': '.$option['value'];
205
- }
206
-
207
- return $arr;
208
- }
209
-
210
- /**
211
- * @param array $attributesInfo
212
- * @return array
213
- */
214
- protected function _getConfigurableOptions($attributesInfo)
215
- {
216
- $arr = array();
217
- foreach ($attributesInfo as $option) {
218
- $arr[] = $option['label'].': '.$option['value'];
219
- }
220
- return $arr;
221
- }
222
-
223
- /**
224
- * @param array $bundleOptions
225
- * @return array
226
- */
227
- protected function _getBundleOptions($bundleOptions)
228
- {
229
- $arr = array();
230
- foreach($bundleOptions as $option) {
231
- $arr[] = $option['label'].': '.$option['value'][0]['title'];
232
- }
233
- return $arr;
234
- }
235
-
236
- /**
237
- * Concatenate all options to string
238
- * @param array $arr
239
- * @return string
240
- */
241
- //todo: new line symbol
242
- protected function _getFormatedVariantInfo($arr)
243
- {
244
- if(count($arr) == 1) {
245
- $result = $arr[0];
246
- } else {
247
- $result = implode(', ', $arr);
248
- }
249
-
250
- return $result;
251
- }
252
-
253
- }
254
-
1
+ <?php
2
+
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Apache License, Version 2.0
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/Apache-2.0
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@apruve.com so we can send you a copy immediately.
15
+ *
16
+ * @category Apruve
17
+ * @package Apruve_Payment
18
+ * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
19
+ * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
20
+ */
21
+
22
+
23
+ /**
24
+ * Class Apruve_ApruvePayment_Model_Api_PaymentRequest
25
+ * Provide methods to build paymentRequest
26
+ * @see https://apruvit.atlassian.net/wiki/display/DOCCO/payment_request
27
+ */
28
+ class Apruve_ApruvePayment_Model_Api_PaymentRequest extends Apruve_ApruvePayment_Model_Api_Abstract
29
+ {
30
+ /**
31
+ * Post request general fields
32
+ * @var array
33
+ */
34
+ protected $_postFields = array(
35
+ //required
36
+ 'merchant_id',
37
+ 'amount_cents',
38
+ 'line_items' => array(),
39
+ //optional
40
+ 'tax_cents',
41
+ 'shipping_cents',
42
+ 'currency', // current only USD
43
+ 'shopperName',
44
+ 'shopperEmail'
45
+ );
46
+
47
+ /**
48
+ * Line Items Fields
49
+ * @var array
50
+ */
51
+ protected $_lineItemFields = array(
52
+ //required
53
+ 'title',
54
+ 'amount_cents', // if qty -> should chanfe
55
+ 'description',
56
+ 'variant_info',
57
+ 'sku',
58
+ 'vendor',
59
+ 'price_ea_cents',
60
+ 'view_product_url',
61
+ );
62
+
63
+ /**
64
+ * @var array
65
+ */
66
+ protected $_paymentRequest;
67
+
68
+
69
+ public function __construct()
70
+ {
71
+ $this->_paymentRequest = $this->_setPaymentRequest();
72
+ }
73
+
74
+ /**
75
+ * Get json encoded payment request
76
+ * @return string
77
+ */
78
+ public function getPaymentRequestJSON()
79
+ {
80
+ return json_encode($this->_paymentRequest);
81
+ }
82
+
83
+ /**
84
+ * Get secure hash
85
+ * @see https://apruvit.atlassian.net/wiki/display/DOCCO/Checkout+Page+Tutorial#CheckoutPageTutorial-1b:CreatingaSecureHash
86
+ * @return string
87
+ */
88
+ public function getSecureHash()
89
+ {
90
+ $concatString = $this->_getApiKey();
91
+
92
+ foreach ($this->_paymentRequest as $val) {
93
+ if(!is_array($val)) {
94
+ $concatString .= $val;
95
+ } else {
96
+ foreach($val as $v) {
97
+ foreach ($v as $s) {
98
+ $concatString .= $s;
99
+ }
100
+
101
+ }
102
+ }
103
+ }
104
+
105
+ return hash('sha256', $concatString);
106
+ }
107
+
108
+
109
+ /**
110
+ * Build Payment Request Array
111
+ * @return array
112
+ */
113
+ protected function _setPaymentRequest()
114
+ {
115
+ /** @var Mage_Sales_Model_Quote $quote */
116
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
117
+ $paymentRequest = array(
118
+ 'merchant_id' => $this->_getMerchantKey(),
119
+ 'amount_cents' => $this->_convertPrice($quote->getGrandTotal()),
120
+ 'currency' => 'USD',
121
+ 'tax_cents' => $this->_convertPrice($quote->getShippingAddress()->getTaxAmount()),
122
+ 'shipping_cents' => $this->_convertPrice($quote->getShippingAddress()->getShippingAmount()),
123
+ 'line_items' => $this->_getLineItems($quote),
124
+ 'shopperName' => $this->_getShopperInfo($quote, 'name'),
125
+ 'shopperEmail' => $this->_getShopperInfo($quote, 'email')
126
+ );
127
+
128
+ return $paymentRequest;
129
+ }
130
+
131
+ /**
132
+ * @param Mage_Sales_Model_Quote $quote
133
+ */
134
+ function _getShopperInfo($quote, $attrName)
135
+ {
136
+ $method = 'get'.ucfirst($attrName);
137
+ if ($quote->getCustomerIsGuest()) {
138
+ return $quote->getBillingAddress()->$method();
139
+ }
140
+
141
+ return $quote->getCustomer()->$method();
142
+ }
143
+
144
+ /**
145
+ * Build Line items array
146
+ * @param Mage_Sales_Model_Quote $quote
147
+ * @return array
148
+ */
149
+ protected function _getLineItems($quote)
150
+ {
151
+ $line_items = array();
152
+ foreach ($quote->getAllVisibleItems() as $item) {
153
+ $qty = $item->getQty();
154
+ $title = $item->getName();
155
+ $amount_cents = $this->_convertPrice($item->getPrice()) * $qty;
156
+ $shortDescription = $item->getShortDescription();
157
+ $viewUrl = $item->getProduct()->getProductUrl(false);
158
+ $priceEaCents = $this->_convertPrice($item->getPrice());
159
+
160
+ $line_item = array(
161
+ 'title' => $title,
162
+ 'amount_cents' => $amount_cents,
163
+ 'description' => $shortDescription,
164
+ 'view_product_url' => $viewUrl,
165
+ 'price_ea_cents' => $priceEaCents,
166
+ 'quantity' => $qty,
167
+
168
+ );
169
+
170
+ $variantInfo = $this->_getVariantInfo($item);
171
+ if($variantInfo) {
172
+ $line_item['variant_info'] = $variantInfo;
173
+ }
174
+
175
+ $line_items[] = $line_item;
176
+ }
177
+
178
+ return $line_items;
179
+ }
180
+
181
+
182
+ /**
183
+ * Get Product configuration if exits
184
+ * @param Mage_Sales_Model_Quote_Item $item
185
+ * @return string
186
+ */
187
+ protected function _getVariantInfo($item)
188
+ {
189
+ $result = '';
190
+ $variantInfo = array();
191
+ $options = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct());
192
+ if(isset($options['options'])) {
193
+ $opt = $this->_getProductCustomOptions($options['options']);
194
+ $variantInfo = array_merge($variantInfo, $opt);
195
+ }
196
+ if(isset($options['attributes_info'])) {
197
+ $opt = $this->_getConfigurableOptions($options['attributes_info']);
198
+ $variantInfo = array_merge($variantInfo, $opt);
199
+ }
200
+
201
+ if(isset($options['bundle_options'])) {
202
+ $opt = $this->_getBundleOptions($options['bundle_options']);
203
+ $variantInfo = array_merge($variantInfo, $opt);
204
+ }
205
+
206
+ if(!empty($variantInfo)) {
207
+ $result = $this->_getFormatedVariantInfo($variantInfo);
208
+ }
209
+
210
+ return $result;
211
+
212
+ }
213
+
214
+ /**
215
+ * @param array $options
216
+ * @return array
217
+ */
218
+ protected function _getProductCustomOptions($options)
219
+ {
220
+ $arr = array();
221
+ foreach ($options as $option) {
222
+ $arr[] = $option['label'].': '.$option['value'];
223
+ }
224
+
225
+ return $arr;
226
+ }
227
+
228
+ /**
229
+ * @param array $attributesInfo
230
+ * @return array
231
+ */
232
+ protected function _getConfigurableOptions($attributesInfo)
233
+ {
234
+ $arr = array();
235
+ foreach ($attributesInfo as $option) {
236
+ $arr[] = $option['label'].': '.$option['value'];
237
+ }
238
+ return $arr;
239
+ }
240
+
241
+ /**
242
+ * @param array $bundleOptions
243
+ * @return array
244
+ */
245
+ protected function _getBundleOptions($bundleOptions)
246
+ {
247
+ $arr = array();
248
+ foreach($bundleOptions as $option) {
249
+ $arr[] = $option['label'].': '.$option['value'][0]['title'];
250
+ }
251
+ return $arr;
252
+ }
253
+
254
+ /**
255
+ * Concatenate all options to string
256
+ * @param array $arr
257
+ * @return string
258
+ */
259
+ //todo: new line symbol
260
+ protected function _getFormatedVariantInfo($arr)
261
+ {
262
+ if(count($arr) == 1) {
263
+ $result = $arr[0];
264
+ } else {
265
+ $result = implode(', ', $arr);
266
+ }
267
+
268
+ return $result;
269
+ }
270
+
271
+ }
272
+
app/code/community/Apruve/ApruvePayment/Model/Api/Rest.php CHANGED
@@ -1,133 +1,133 @@
1
- <?php
2
-
3
- /**
4
- * Magento
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Apache License, Version 2.0
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/Apache-2.0
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@apruve.com so we can send you a copy immediately.
15
- *
16
- * @category Apruve
17
- * @package Apruve_Payment
18
- * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
19
- * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
20
- */
21
-
22
- /**
23
- * Class Apruve_ApruvePayment_Model_Api_Rest
24
- *
25
- * Provide rest methods to communicate with apruve
26
- */
27
-
28
- class Apruve_ApruvePayment_Model_Api_Rest extends Apruve_ApruvePayment_Model_Api_Abstract
29
- {
30
- /**
31
- * Send Payment object
32
- * @param string $paymentRequestId
33
- * @param float $amount
34
- * @return bool
35
- */
36
- public function postPayment($paymentRequestId, $amount)
37
- {
38
- $data = json_encode(array('amount_cents' => $this->_convertPrice($amount)));
39
-
40
- $c = curl_init($this->_getPaymentUrl($paymentRequestId));
41
-
42
- curl_setopt($c, CURLOPT_HTTPHEADER, $this->_getHeaders());
43
- curl_setopt($c, CURLOPT_POST, true);
44
- curl_setopt($c, CURLOPT_RETURNTRANSFER, true );
45
- curl_setopt($c, CURLOPT_HEADER, true);
46
- curl_setopt($c, CURLOPT_POSTFIELDS, $data );
47
- $response = curl_exec($c);
48
- $http_status = curl_getinfo($c, CURLINFO_HTTP_CODE);
49
- curl_close($c);
50
-
51
- if($http_status == '201') {
52
- return true;
53
- } else {
54
- return false;
55
- }
56
-
57
- }
58
-
59
- /**
60
- * Update paymentRequest object
61
- * Availible fields to update are: amount_cents, shipping_cents, tax_cents
62
- * @param string $paymentRequestId
63
- * @param float $amount
64
- * @param float $shipping
65
- * @param float $tax
66
- * @return bool
67
- */
68
- public function updatePaymentRequest($paymentRequestId, $amount, $shipping, $tax)
69
- {
70
- $data = json_encode(array(
71
- 'amount_cents' => $this->_convertPrice($amount),
72
- 'shipping_cents' => $this->_convertPrice($shipping),
73
- 'tax_cents' => $this->_convertPrice($tax),
74
- ));
75
-
76
- $c = curl_init($this->_getUpdatePaymentRequestUrl($paymentRequestId));
77
-
78
- curl_setopt($c, CURLOPT_HTTPHEADER, $this->_getHeaders());
79
- curl_setopt($c, CURLOPT_CUSTOMREQUEST, "PUT");
80
- curl_setopt($c, CURLOPT_RETURNTRANSFER, true );
81
- curl_setopt($c, CURLOPT_HEADER, true);
82
- curl_setopt($c, CURLOPT_POSTFIELDS, $data );
83
- $response = curl_exec($c);
84
- $http_status = curl_getinfo($c, CURLINFO_HTTP_CODE);
85
- curl_close($c);
86
-
87
-
88
- if($http_status == '200') {
89
- return true;
90
- } else {
91
- return false;
92
- }
93
- }
94
-
95
- /**
96
- * GET Apruve Payment Status
97
- * Check whether given status is same as in Apruve.com
98
- * @param $status
99
- * @param $apiUrl
100
- * @return bool
101
- */
102
- public function getApruveOrderStatus($apiUrl, $status)
103
- {
104
- $c = curl_init($apiUrl);
105
- curl_setopt($c, CURLOPT_HTTPHEADER, $this->_getHeaders());
106
- curl_setopt($c, CURLOPT_CUSTOMREQUEST, "GET");
107
- curl_setopt($c, CURLOPT_RETURNTRANSFER, true );
108
- curl_setopt($c, CURLOPT_HEADER, true);
109
-
110
-
111
- }
112
-
113
- /**
114
- * Get url for send payment
115
- * @param string $paymentRequestId
116
- * @return string
117
- */
118
- protected function _getPaymentUrl($paymentRequestId)
119
- {
120
- return $this->getBaseUrl(true).$this->_getApiUrl().'payment_requests/'.$paymentRequestId.'/payments';
121
- }
122
-
123
-
124
- /**
125
- * Get url for update paymentRequest
126
- * @param string $paymentRequestId
127
- * @return string
128
- */
129
- protected function _getUpdatePaymentRequestUrl($paymentRequestId)
130
- {
131
- return $this->getBaseUrl(true).$this->_getApiUrl().'payment_requests/'.$paymentRequestId;
132
- }
133
}
1
+ <?php
2
+
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Apache License, Version 2.0
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/Apache-2.0
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@apruve.com so we can send you a copy immediately.
15
+ *
16
+ * @category Apruve
17
+ * @package Apruve_Payment
18
+ * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
19
+ * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
20
+ */
21
+
22
+ /**
23
+ * Class Apruve_ApruvePayment_Model_Api_Rest
24
+ *
25
+ * Provide rest methods to communicate with apruve
26
+ */
27
+
28
+ class Apruve_ApruvePayment_Model_Api_Rest extends Apruve_ApruvePayment_Model_Api_Abstract
29
+ {
30
+ /**
31
+ * Send Payment object
32
+ * @param string $paymentRequestId
33
+ * @param float $amount
34
+ * @return bool
35
+ */
36
+ public function postPayment($paymentRequestId, $amount)
37
+ {
38
+ $data = json_encode(array('amount_cents' => $this->_convertPrice($amount)));
39
+
40
+ $c = curl_init($this->_getPaymentUrl($paymentRequestId));
41
+
42
+ curl_setopt($c, CURLOPT_HTTPHEADER, $this->_getHeaders());
43
+ curl_setopt($c, CURLOPT_POST, true);
44
+ curl_setopt($c, CURLOPT_RETURNTRANSFER, true );
45
+ curl_setopt($c, CURLOPT_HEADER, true);
46
+ curl_setopt($c, CURLOPT_POSTFIELDS, $data );
47
+ $response = curl_exec($c);
48
+ $http_status = curl_getinfo($c, CURLINFO_HTTP_CODE);
49
+ curl_close($c);
50
+
51
+ if($http_status == '201') {
52
+ return true;
53
+ } else {
54
+ return false;
55
+ }
56
+
57
+ }
58
+
59
+ /**
60
+ * Update paymentRequest object
61
+ * Availible fields to update are: amount_cents, shipping_cents, tax_cents
62
+ * @param string $paymentRequestId
63
+ * @param float $amount
64
+ * @param float $shipping
65
+ * @param float $tax
66
+ * @return bool
67
+ */
68
+ public function updatePaymentRequest($paymentRequestId, $amount, $shipping, $tax)
69
+ {
70
+ $data = json_encode(array(
71
+ 'amount_cents' => $this->_convertPrice($amount),
72
+ 'shipping_cents' => $this->_convertPrice($shipping),
73
+ 'tax_cents' => $this->_convertPrice($tax),
74
+ ));
75
+
76
+ $c = curl_init($this->_getUpdatePaymentRequestUrl($paymentRequestId));
77
+
78
+ curl_setopt($c, CURLOPT_HTTPHEADER, $this->_getHeaders());
79
+ curl_setopt($c, CURLOPT_CUSTOMREQUEST, "PUT");
80
+ curl_setopt($c, CURLOPT_RETURNTRANSFER, true );
81
+ curl_setopt($c, CURLOPT_HEADER, true);
82
+ curl_setopt($c, CURLOPT_POSTFIELDS, $data );
83
+ $response = curl_exec($c);
84
+ $http_status = curl_getinfo($c, CURLINFO_HTTP_CODE);
85
+ curl_close($c);
86
+
87
+
88
+ if($http_status == '200') {
89
+ return true;
90
+ } else {
91
+ return false;
92
+ }
93
+ }
94
+
95
+ /**
96
+ * GET Apruve Payment Status
97
+ * Check whether given status is same as in Apruve.com
98
+ * @param $status
99
+ * @param $apiUrl
100
+ * @return bool
101
+ */
102
+ public function getApruveOrderStatus($apiUrl, $status)
103
+ {
104
+ $c = curl_init($apiUrl);
105
+ curl_setopt($c, CURLOPT_HTTPHEADER, $this->_getHeaders());
106
+ curl_setopt($c, CURLOPT_CUSTOMREQUEST, "GET");
107
+ curl_setopt($c, CURLOPT_RETURNTRANSFER, true );
108
+ curl_setopt($c, CURLOPT_HEADER, true);
109
+
110
+
111
+ }
112
+
113
+ /**
114
+ * Get url for send payment
115
+ * @param string $paymentRequestId
116
+ * @return string
117
+ */
118
+ protected function _getPaymentUrl($paymentRequestId)
119
+ {
120
+ return $this->getBaseUrl(true).$this->_getApiUrl().'payment_requests/'.$paymentRequestId.'/payments';
121
+ }
122
+
123
+
124
+ /**
125
+ * Get url for update paymentRequest
126
+ * @param string $paymentRequestId
127
+ * @return string
128
+ */
129
+ protected function _getUpdatePaymentRequestUrl($paymentRequestId)
130
+ {
131
+ return $this->getBaseUrl(true).$this->_getApiUrl().'payment_requests/'.$paymentRequestId;
132
+ }
133
}
app/code/community/Apruve/ApruvePayment/Model/PaymentMethod.php CHANGED
@@ -24,26 +24,11 @@ class Apruve_ApruvePayment_Model_PaymentMethod extends Mage_Payment_Model_Method
24
protected $_code = 'apruvepayment';
25
protected $_formBlockType = 'apruvepayment/payment_form';
26
27
- protected $_isGateway = false;
28
- protected $_canOrder = true;
29
protected $_canAuthorize = true;
30
protected $_canCapture = true;
31
- protected $_canCapturePartial = false;
32
- protected $_canRefund = false;
33
- protected $_canRefundInvoicePartial = false;
34
protected $_canVoid = true;
35
- protected $_canUseInternal = false;
36
protected $_canUseCheckout = true;
37
- protected $_canUseForMultishipping = false;
38
- protected $_canFetchTransactionInfo = true;
39
protected $_canCreateBillingAgreement = true;
40
- protected $_canReviewPayment = true;
41
-
42
- public function getCheckoutRedirectUrl()
43
- {
44
- return Mage::getUrl('apruvepayment/payment/review');
45
- }
46
-
47
48
/**
49
* Assign data to info model instance
@@ -75,39 +60,43 @@ class Apruve_ApruvePayment_Model_PaymentMethod extends Mage_Payment_Model_Method
75
}
76
}
77
78
- /**
79
- * @return string
80
- */
81
- public function getConfigPaymentAction()
82
- {
83
- return 'order';
84
- }
85
-
86
/**
87
* Get token and create transaction
88
* @param Varien_Object $payment
89
* @param float $amount
90
* @return Mage_Payment_Model_Abstract|void
91
*/
92
- public function order(Varien_Object $payment, $amount)
93
{
94
$additionalInformation = $payment->getAdditionalInformation();
95
$token = $additionalInformation['aprt'];
96
97
- //$amount = $payment->getBaseAmountOrdered() * 100; //cents
98
- //$rest = Mage::getModel('apruvepayment/api_rest');
99
- //$rest->postPayment($token, $amount); //return true or false
100
- //$payment->setSkipOrderProcessing(true);
101
- //echo 1;exit;
102
103
- $payment->setTransactionId($token);
104
- $payment->setIsTransactionClosed(0);
105
- $payment->resetTransactionAdditionalInfo();
106
- }
107
108
109
public function capture(Varien_Object $payment, $amount)
110
{
111
112
}
113
}
24
protected $_code = 'apruvepayment';
25
protected $_formBlockType = 'apruvepayment/payment_form';
26
27
protected $_canAuthorize = true;
28
protected $_canCapture = true;
29
protected $_canVoid = true;
30
protected $_canUseCheckout = true;
31
protected $_canCreateBillingAgreement = true;
32
33
/**
34
* Assign data to info model instance
60
}
61
}
62
63
/**
64
* Get token and create transaction
65
* @param Varien_Object $payment
66
* @param float $amount
67
* @return Mage_Payment_Model_Abstract|void
68
*/
69
+ public function authorize(Varien_Object $payment, $amount)
70
{
71
$additionalInformation = $payment->getAdditionalInformation();
72
$token = $additionalInformation['aprt'];
73
+ $rest = Mage::getModel('apruvepayment/api_rest');
74
+ $order = $payment->getOrder();
75
76
+ $tax = $order->getBaseTaxAmount();
77
+ $shipping = $order->getBaseShippingAmount();
78
+ if(!$rest->updatePaymentRequest($token, $amount, $shipping, $tax))
79
+ {
80
+ Mage::throwException('Couldn\'t update order totals to Apruve');
81
+ }
82
83
+ if(!$rest->postPayment($token, $amount)) {
84
+ Mage::throwException('Apruve couldn\'t process order information');
85
+ }
86
87
+ $payment->setTransactionId($token)
88
+ ->setIsTransactionClosed(0);
89
+ return $this;
90
+ }
91
92
public function capture(Varien_Object $payment, $amount)
93
{
94
+ if ($amount <= 0) {
95
+ Mage::throwException(Mage::helper('paygate')->__('Invalid amount for capture.'));
96
+ }
97
98
+ $payment->setAmount($amount)
99
+ ->setTransactionId($payment->getParentTransactionId() . '_capture');
100
+ return $this;
101
}
102
}
app/code/community/Apruve/ApruvePayment/Model/Session.php DELETED
@@ -1,28 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Magento
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Apache License, Version 2.0
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/Apache-2.0
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@apruve.com so we can send you a copy immediately.
15
- *
16
- * @category Apruve
17
- * @package Apruve_Payment
18
- * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
19
- * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
20
- */
21
-
22
- class Apruve_ApruvePayment_Model_Session extends Mage_Core_Model_Session_Abstract
23
- {
24
- public function __construct()
25
- {
26
- $this->init('apruvepayment');
27
- }
28
- }
app/code/community/Apruve/ApruvePayment/controllers/PaymentController.php DELETED
@@ -1,173 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Magento
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Apache License, Version 2.0
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/Apache-2.0
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@apruve.com so we can send you a copy immediately.
15
- *
16
- * @category Apruve
17
- * @package Apruve_Payment
18
- * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
19
- * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
20
- */
21
-
22
- class Apruve_ApruvePayment_PaymentController extends Mage_Core_Controller_Front_Action
23
- {
24
- public function reviewAction()
25
- {
26
- $this->loadLayout();
27
- $this->renderLayout();
28
- }
29
-
30
- /**
31
- * Return checkout session object
32
- *
33
- * @return Mage_Checkout_Model_Session
34
- */
35
- private function _getCheckoutSession()
36
- {
37
- return Mage::getSingleton('checkout/session');
38
- }
39
-
40
-
41
- public function placeOrderAction()
42
- {
43
- $checkoutSession = $this->_getCheckoutSession();
44
- $errors = array();
45
- //call rest api and get result if its ok, proceed
46
- $quote = $checkoutSession->getQuote();
47
-
48
- $payment = $quote->getPayment();
49
- $method = $payment->getMethodInstance();
50
- $infoIstance = $method->getInfoInstance();
51
-
52
- $token = $infoIstance->getAdditionalInformation('aprt');
53
- $amount = $quote->getBaseGrandTotal();
54
-
55
- $rest = Mage::getModel('apruvepayment/api_rest');
56
-
57
- $session = Mage::getSingleton('apruvepayment/session');
58
-
59
- if($session->getAddressUpdated() && !$quote->getIsVirtual()) {
60
- $tax = $quote->getShippingAddress()->getTaxAmount();
61
- $shipping = $quote->getShippingAddress()->getShippingAmount();
62
- if(!$rest->updatePaymentRequest($token, $amount, $shipping, $tax))
63
- {
64
- //show errors
65
- $errors['couldnt_update'] = 'Couldn\'t update order totals to Apruve';
66
- $session->setErrors($errors);
67
- return $this->_redirect("*/*/review");
68
- }
69
- }
70
-
71
-
72
- if(!$rest->postPayment($token, $amount)) {
73
- //show errors
74
- $errors['couldnt_rest_payment'] = 'Apruve couldn\'t process order information';
75
- $session->setErrors($errors);
76
- return $this->_redirect("*/*/review");
77
- }
78
-
79
- $quote = $checkoutSession->getQuote();
80
- $quote->collectTotals();
81
-
82
- $service = Mage::getModel('sales/service_quote', $quote);
83
- $service->submitAll();
84
-
85
- $quote->save();
86
-
87
- $checkoutSession->clearHelperData();
88
-
89
- // last successful quote
90
- $quoteId = $quote->getId();
91
-
92
- $checkoutSession->setLastQuoteId($quoteId)->setLastSuccessQuoteId($quoteId);
93
-
94
- $order = $service->getOrder();
95
- if ($order) {
96
- $checkoutSession->setLastOrderId($order->getId())
97
- ->setLastRealOrderId($order->getIncrementId());
98
- } else {
99
- //error
100
- }
101
-
102
- $session->unsetData('address_updated');
103
- return $this->_redirect('checkout/onepage/success');
104
- }
105
-
106
-
107
- public function updateBillingAddressAction()
108
- {
109
- $data = $this->getRequest()->getPost('billing', array());
110
- $customerAddressId = '';//$data['address_id'];
111
-
112
- if (isset($data['email'])) {
113
- $data['email'] = trim($data['email']);
114
- }
115
- $onePage = Mage::getSingleton('checkout/type_onepage');
116
- $result = $onePage->saveBilling($data, $customerAddressId);
117
-
118
- if(!empty($result)) {
119
- Mage::getSingleton('apruvepayment/session')->setErrors($result['message']);
120
- } else {
121
- $this->_setAddressUpdated();
122
- }
123
-
124
- $this->_redirect('*/*/review');
125
- }
126
-
127
- public function updateShippingAddressAction()
128
- {
129
- $data = $this->getRequest()->getPost('shipping', array());
130
- $customerAddressId = '';//$data['address_id'];
131
- $onePage = Mage::getSingleton('checkout/type_onepage');
132
-
133
- $result = $onePage->saveShipping($data, $customerAddressId);
134
-
135
- if(!empty($result)) {
136
- Mage::getSingleton('apruvepayment/session')->setErrors($result['message']);
137
- } else {
138
- $this->_setAddressUpdated();
139
- }
140
-
141
-
142
- $this->_redirect('*/*/review');
143
- }
144
-
145
-
146
- public function updateShippingMethodAction()
147
- {
148
- if ($this->getRequest()->isPost()) {
149
- $data = $this->getRequest()->getPost('shipping_method', '');
150
- $onePage = Mage::getSingleton('checkout/type_onepage');
151
- $result = $onePage->saveShippingMethod($data);
152
- $onePage->getQuote()->collectTotals()->save();
153
- }
154
-
155
- $this->_setAddressUpdated();
156
- $this->_redirect('*/*/review');
157
- }
158
-
159
-
160
- private function _setAddressUpdated()
161
- {
162
- $session = Mage::getSingleton('apruvepayment/session');
163
- $session->setAddressUpdated(1);
164
- }
165
-
166
-
167
- public function ajaxSetAddressUpdatedAction()
168
- {
169
- $this->_setAddressUpdated();
170
- die(true);
171
- }
172
- }
173
-
app/code/community/Apruve/ApruvePayment/controllers/WebhookController.php CHANGED
@@ -1,120 +1,111 @@
1
- <?php
2
-
3
- /**
4
- * Magento
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Apache License, Version 2.0
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/Apache-2.0
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@apruve.com so we can send you a copy immediately.
15
- *
16
- * @category Apruve
17
- * @package Apruve_Payment
18
- * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
19
- * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
20
- */
21
-
22
- class Apruve_ApruvePayment_WebhookController extends Mage_Core_Controller_Front_Action
23
- {
24
- public function updateOrderStatusAction()
25
- {
26
- $q = $this->_getHashedQueryString();
27
-
28
- if(!isset($_GET[$q])) {
29
- //do nothing
30
- header("HTTP/1.1 404 Not Found");
31
- exit;
32
- }
33
-
34
- $input = file_get_contents('php://input');
35
- $data = json_decode($input);
36
-
37
- $status = $data->status;
38
- $paymentRequestId = $data->payment_request_id; //transaciton id
39
-
40
- //todo: compare status by rest request
41
- if($status == 'rejected') {
42
- if(!$this->_cancelOrder($paymentRequestId)) {
43
- header("HTTP/1.1 404 Not Found");
44
- exit;
45
- };
46
- } elseif($status == 'captured' ) {
47
- if(!$this->_addPayed($paymentRequestId)) {
48
- header("HTTP/1.1 404 Not Found");
49
- exit;
50
- };
51
- }
52
-
53
-
54
- header("HTTP/1.1 200");
55
- exit;
56
- }
57
-
58
-
59
- protected function _addPayed($paymentRequestId)
60
- {
61
- $transaction = Mage::getModel('sales/order_payment_transaction')->getCollection()
62
- ->addAttributeToFilter('txn_id', array('eq' => $paymentRequestId))
63
- ->getFirstItem();
64
- if(!$transaction->getId()) {
65
- return false;
66
- }
67
-
68
- $order = $transaction->getOrder();
69
- if(!$order->getId()) {
70
- return false;
71
- }
72
-
73
- $payment = $transaction->getOrder()->getPayment();
74
- if(!$payment->getId()) {
75
- exit;
76
- }
77
- $payment->capture(null);
78
- $order->save();
79
-
80
- $transaction->setOrderPaymentObject($payment);
81
- $transaction->setIsClosed(true);
82
- $transaction->save();
83
- return true;
84
- }
85
-
86
-
87
- protected function _cancelOrder($paymentRequestId)
88
- {
89
- $transaction = Mage::getModel('sales/order_payment_transaction')->getCollection()
90
- ->addAttributeToFilter('txn_id', array('eq' => $paymentRequestId))
91
- ->getFirstItem();
92
- if(!$transaction->getId()) {
93
- return false;
94
- }
95
-
96
- //todo: add customer notification
97
- $order = $transaction->getOrder();
98
- if(!$order->getId()) {
99
- return false;
100
- }
101
- $order->cancel();
102
- $order->save();
103
-
104
- $payment = $transaction->getOrder()->getPayment();
105
- $transaction->setOrderPaymentObject($payment);
106
- $transaction->setIsClosed(true);
107
- $transaction->save();
108
- return true;
109
- }
110
-
111
-
112
- protected function _getHashedQueryString()
113
- {
114
- $merchantKey = Mage::getStoreConfig('payment/apruvepayment/merchant');
115
- $apiKey = Mage::getStoreConfig('payment/apruvepayment/api');
116
- $data = $apiKey.$merchantKey;
117
- $q = hash('sha256', $data);
118
- return $q;
119
- }
120
- }
1
+ <?php
2
+
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Apache License, Version 2.0
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/Apache-2.0
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@apruve.com so we can send you a copy immediately.
15
+ *
16
+ * @category Apruve
17
+ * @package Apruve_Payment
18
+ * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
19
+ * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
20
+ */
21
+
22
+ class Apruve_ApruvePayment_WebhookController extends Mage_Core_Controller_Front_Action
23
+ {
24
+ public function updateOrderStatusAction()
25
+ {
26
+ $q = $this->_getHashedQueryString();
27
+
28
+ if(!isset($_GET[$q])) {
29
+ //do nothing
30
+ header("HTTP/1.1 404 Not Found");
31
+ exit;
32
+ }
33
+
34
+ $input = file_get_contents('php://input');
35
+ $data = json_decode($input);
36
+
37
+ $status = $data->status;
38
+ $paymentRequestId = $data->payment_request_id; //transaciton id
39
+
40
+ //todo: compare status by rest request
41
+ if($status == 'rejected') {
42
+ if(!$this->_cancelOrder($paymentRequestId)) {
43
+ header("HTTP/1.1 404 Not Found");
44
+ exit;
45
+ };
46
+ } elseif($status == 'captured' ) {
47
+ if(!$this->_addPayed($paymentRequestId)) {
48
+ header("HTTP/1.1 404 Not Found");
49
+ exit;
50
+ };
51
+ }
52
+
53
+
54
+ header("HTTP/1.1 200");
55
+ exit;
56
+ }
57
+
58
+
59
+ protected function _addPayed($paymentRequestId)
60
+ {
61
+ $transaction = Mage::getModel('sales/order_payment_transaction')->getCollection()
62
+ ->addAttributeToFilter('txn_id', array('eq' => $paymentRequestId))
63
+ ->getFirstItem();
64
+ if($transaction->getId()) {
65
+ $order = $transaction->getOrder();
66
+ if($order->getId()) {
67
+ $iApi = Mage::getModel('sales/order_invoice_api');
68
+ $invoiceId = $iApi->create($order->getIncrementId(), array());
69
+ $iApi->capture($invoiceId);
70
+ return true;
71
+ }
72
+ }
73
+
74
+ return false;
75
+ }
76
+
77
+
78
+ protected function _cancelOrder($paymentRequestId)
79
+ {
80
+ $transaction = Mage::getModel('sales/order_payment_transaction')->getCollection()
81
+ ->addAttributeToFilter('txn_id', array('eq' => $paymentRequestId))
82
+ ->getFirstItem();
83
+ if(!$transaction->getId()) {
84
+ return false;
85
+ }
86
+
87
+ //todo: add customer notification
88
+ $order = $transaction->getOrder();
89
+ if(!$order->getId()) {
90
+ return false;
91
+ }
92
+ $order->cancel();
93
+ $order->save();
94
+
95
+ $payment = $transaction->getOrder()->getPayment();
96
+ $transaction->setOrderPaymentObject($payment);
97
+ $transaction->setIsClosed(true);
98
+ $transaction->save();
99
+ return true;
100
+ }
101
+
102
+
103
+ protected function _getHashedQueryString()
104
+ {
105
+ $merchantKey = Mage::getStoreConfig('payment/apruvepayment/merchant');
106
+ $apiKey = Mage::getStoreConfig('payment/apruvepayment/api');
107
+ $data = $apiKey.$merchantKey;
108
+ $q = hash('sha256', $data);
109
+ return $q;
110
+ }
111
+ }
app/code/community/Apruve/ApruvePayment/etc/config.xml CHANGED
@@ -1,74 +1,75 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Apruve_ApruvePayment>
5
- <version>1.0.5</version>
6
- </Apruve_ApruvePayment>
7
- </modules>
8
- <frontend>
9
- <routers>
10
- <apruvepayment>
11
- <use>standard</use>
12
- <args>
13
- <module>Apruve_ApruvePayment</module>
14
- <frontName>apruvepayment</frontName>
15
- </args>
16
- </apruvepayment>
17
- </routers>
18
- <layout>
19
- <updates>
20
- <apruvepayment>
21
- <file>apruvepayment.xml</file>
22
- </apruvepayment>
23
- </updates>
24
- </layout>
25
- </frontend>
26
- <global>
27
- <blocks>
28
- <apruvepayment>
29
- <class>Apruve_ApruvePayment_Block</class>
30
- </apruvepayment>
31
- </blocks>
32
- <models>
33
- <apruvepayment>
34
- <class>Apruve_ApruvePayment_Model</class>
35
- </apruvepayment>
36
- </models>
37
- <resources>
38
- <apruvepayment_setup>
39
- <setup>
40
- <module>Apruve_ApruvePayment</module>
41
- <class>Apruve_ApruvePayment_Model_Mysql4_Setup</class>
42
- </setup>
43
- <connection>
44
- <use>core_setup</use>
45
- </connection>
46
- </apruvepayment_setup>
47
- <apruvepayment_write>
48
- <connection>
49
- <use>core_write</use>
50
- </connection>
51
- </apruvepayment_write>
52
- <apruvepayment_read>
53
- <connection>
54
- <use>core_read</use>
55
- </connection>
56
- </apruvepayment_read>
57
- </resources>
58
- <helpers>
59
- <apruvepayment>
60
- <class>Apruve_ApruvePayment_Helper</class>
61
- </apruvepayment>
62
- </helpers>
63
- </global>
64
- <default>
65
- <payment>
66
- <apruvepayment>
67
- <active>1</active>
68
- <model>apruvepayment/paymentMethod</model>
69
- <order_status>pending_payment</order_status>
70
- <title>Pay with Apruve</title>
71
- </apruvepayment>
72
- </payment>
73
- </default>
74
- </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Apruve_ApruvePayment>
5
+ <version>1.0.6</version>
6
+ </Apruve_ApruvePayment>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <apruvepayment>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Apruve_ApruvePayment</module>
14
+ <frontName>apruvepayment</frontName>
15
+ </args>
16
+ </apruvepayment>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <apruvepayment>
21
+ <file>apruvepayment.xml</file>
22
+ </apruvepayment>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <global>
27
+ <blocks>
28
+ <apruvepayment>
29
+ <class>Apruve_ApruvePayment_Block</class>
30
+ </apruvepayment>
31
+ </blocks>
32
+ <models>
33
+ <apruvepayment>
34
+ <class>Apruve_ApruvePayment_Model</class>
35
+ </apruvepayment>
36
+ </models>
37
+ <resources>
38
+ <apruvepayment_setup>
39
+ <setup>
40
+ <module>Apruve_ApruvePayment</module>
41
+ <class>Apruve_ApruvePayment_Model_Mysql4_Setup</class>
42
+ </setup>
43
+ <connection>
44
+ <use>core_setup</use>
45
+ </connection>
46
+ </apruvepayment_setup>
47
+ <apruvepayment_write>
48
+ <connection>
49
+ <use>core_write</use>
50
+ </connection>
51
+ </apruvepayment_write>
52
+ <apruvepayment_read>
53
+ <connection>
54
+ <use>core_read</use>
55
+ </connection>
56
+ </apruvepayment_read>
57
+ </resources>
58
+ <helpers>
59
+ <apruvepayment>
60
+ <class>Apruve_ApruvePayment_Helper</class>
61
+ </apruvepayment>
62
+ </helpers>
63
+ </global>
64
+ <default>
65
+ <payment>
66
+ <apruvepayment>
67
+ <active>1</active>
68
+ <model>apruvepayment/paymentMethod</model>
69
+ <order_status>pending_payment</order_status>
70
+ <title>Pay with Apruve</title>
71
+ <payment_action>authorize</payment_action>
72
+ </apruvepayment>
73
+ </payment>
74
+ </default>
75
+ </config>
app/design/frontend/base/default/layout/apruvepayment.xml CHANGED
@@ -1,48 +1,7 @@
1
- <layout version="0.1.0">
2
- <default>
3
- <reference name="head">
4
- <block type="core/template" name="apruve_js" template="apruvepayment/head.phtml" output="toHtml" />
5
- </reference>
6
- </default>
7
-
8
- <apruvepayment_payment_review translate="label">
9
- <label>Apruve Express Order Review Form</label>
10
- <remove name="right"/>
11
- <remove name="left"/>
12
-
13
- <reference name="root">
14
- <action method="setTemplate"><template>page/1column.phtml</template></action>
15
- </reference>
16
-
17
- <reference name="content">
18
- <block type="apruvepayment/review" name="apruvepayment.review" template="apruvepayment/review.phtml">
19
- <block type="apruvepayment/review_billing" name="apruve.review.billing" as="billing" template="apruvepayment/review/address.phtml"/>
20
- <block type="apruvepayment/review_shipping" name="apruve.review.shipping" as="shipping" template="apruvepayment/review/address.phtml"/>
21
- <!--<block type="paypal/express_review_shipping" name="express.review.shipping" as="shipping" template="paypal/express/review/address.phtml"/>-->
22
- <block type="checkout/onepage_shipping_method" name="checkout.onepage.shipping_method" as="shipping_method" template="apruvepayment/review/shipping_method.phtml">
23
- <block type="checkout/onepage_shipping_method_available" name="checkout.onepage.shipping_method.available" as="available" template="checkout/onepage/shipping_method/available.phtml"/>
24
- <block type="checkout/onepage_shipping_method_additional" name="checkout.onepage.shipping_method.additional" as="additional" template="checkout/onepage/shipping_method/additional.phtml"/>
25
- </block>
26
- <block type="apruvepayment/review_details" name="apruvepayment.review.details" as="details" template="apruvepayment/review/details.phtml">
27
- <action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action>
28
- <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/onepage/review/item.phtml</template></action>
29
- <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/onepage/review/item.phtml</template></action>
30
- <block type="checkout/cart_totals" name="apruvepayment.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/>
31
- </block>
32
- <block type="checkout/agreements" name="apruvepayment.review.details.agreements" as="agreements" template="checkout/onepage/agreements.phtml"/>
33
- </block>
34
- </reference>
35
- </apruvepayment_payment_review>
36
-
37
- <apruvepayment_payment_details>
38
- <label>One Page Checkout Success</label>
39
- <reference name="root">
40
- <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
41
- </reference>
42
- <reference name="content">
43
- <block type="checkout/onepage_success" name="checkout.success" template="checkout/success.phtml"/>
44
- </reference>
45
- </apruvepayment_payment_details>
46
-
47
-
48
- </layout>
1
+ <layout version="0.1.0">
2
+ <default>
3
+ <reference name="head">
4
+ <block type="core/template" name="apruve_js" template="apruvepayment/head.phtml" output="toHtml" />
5
+ </reference>
6
+ </default>
7
+ </layout>
app/design/frontend/base/default/template/apruvepayment/head.phtml CHANGED
@@ -1,27 +1,27 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Apache License, Version 2.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/Apache-2.0
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@apruve.com so we can send you a copy immediately.
14
- *
15
- * @category Apruve
16
- * @package Apruve_Payment
17
- * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
18
- * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
19
- */
20
- ?>
21
-
22
- <?php if(Mage::getStoreConfig('payment/apruvepayment/testmode')):?>
23
- <script type="text/javascript" src="https://test.apruve.com/js/apruve.js?display=compact"></script>
24
- <?php else: ?>
25
- <script type="text/javascript" src="https://www.apruve.com/js/apruve.js?display=compact"></script>
26
- <?php endif; ?>
27
<script type="text/javascript" src="/js/Apruve/ApruvePayment.js"></script>
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Apache License, Version 2.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/Apache-2.0
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@apruve.com so we can send you a copy immediately.
14
+ *
15
+ * @category Apruve
16
+ * @package Apruve_Payment
17
+ * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
18
+ * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
19
+ */
20
+ ?>
21
+
22
+ <?php if(Mage::getStoreConfig('payment/apruvepayment/testmode')):?>
23
+ <script type="text/javascript" src="https://test.apruve.com/js/apruve.js?display=compact"></script>
24
+ <?php else: ?>
25
+ <script type="text/javascript" src="https://www.apruve.com/js/apruve.js?display=compact"></script>
26
+ <?php endif; ?>
27
<script type="text/javascript" src="/js/Apruve/ApruvePayment.js"></script>
app/design/frontend/base/default/template/apruvepayment/payment/form.phtml CHANGED
@@ -1,25 +1,25 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Apache License, Version 2.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/Apache-2.0
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@apruve.com so we can send you a copy immediately.
14
- *
15
- * @category Apruve
16
- * @package Apruve_Payment
17
- * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
18
- * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
19
- */
20
- ?>
21
-
22
- <div id="payment_form_apruvepayment">
23
- Press continue to review order.
24
- <input type="hidden" id="aprt" value="" name="payment[aprt]"/>
25
</div>
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Apache License, Version 2.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/Apache-2.0
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@apruve.com so we can send you a copy immediately.
14
+ *
15
+ * @category Apruve
16
+ * @package Apruve_Payment
17
+ * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
18
+ * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
19
+ */
20
+ ?>
21
+
22
+ <div id="payment_form_apruvepayment">
23
+ Press continue to review order.
24
+ <input type="hidden" id="aprt" value="" name="payment[aprt]"/>
25
</div>
app/design/frontend/base/default/template/apruvepayment/payment/mark.phtml CHANGED
@@ -1,34 +1,33 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Apache License, Version 2.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/Apache-2.0
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@apruve.com so we can send you a copy immediately.
14
- *
15
- * @category Apruve
16
- * @package Apruve_Payment
17
- * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
18
- * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
19
- */
20
- ?>
21
-
22
- <?php
23
- $helper = Mage::helper('apruvepayment');
24
- $paymentRequestModel = $helper->getPaymentRequestApiModel();
25
- ?>
26
-
27
- <div id="apruveDiv" style="display: inline-block; position: absolute; margin-top: -3px; margin-left: 7px;"></div>
28
-
29
- <script type="test/javascript">
30
- var sh = '<?php echo $paymentRequestModel->getSecureHash();?>';
31
- var pr = <?php echo $paymentRequestModel->getPaymentRequestJSON();?>;
32
- var updatedShippingUrl = '<?php echo $helper->getAjaxAddressUpdatedUrl() ?>'
33
- var oApruvePayment = new ApruvePayment(sh, pr, updatedShippingUrl);
34
</script>
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Apache License, Version 2.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/Apache-2.0
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@apruve.com so we can send you a copy immediately.
14
+ *
15
+ * @category Apruve
16
+ * @package Apruve_Payment
17
+ * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
18
+ * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
19
+ */
20
+ ?>
21
+
22
+ <?php
23
+ $helper = Mage::helper('apruvepayment');
24
+ $paymentRequestModel = $helper->getPaymentRequestApiModel();
25
+ ?>
26
+
27
+ <div id="apruveDiv" style="display: inline-block; position: absolute; margin-top: -3px; margin-left: 7px;"></div>
28
+
29
+ <script type="test/javascript">
30
+ var sh = '<?php echo $paymentRequestModel->getSecureHash();?>';
31
+ var pr = <?php echo $paymentRequestModel->getPaymentRequestJSON();?>;
32
+ var oApruvePayment = new ApruvePayment(sh, pr);
33
</script>
app/design/frontend/base/default/template/apruvepayment/review.phtml DELETED
@@ -1,96 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Apache License, Version 2.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/Apache-2.0
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@apruve.com so we can send you a copy immediately.
14
- *
15
- * @category Apruve
16
- * @package Apruve_Payment
17
- * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
18
- * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
19
- */
20
- ?>
21
-
22
- <?php $errors = $this->getErrors();
23
- $this->getQuoteIsVirtual();
24
- ?>
25
- <div class="page-title">
26
- <h1><?php echo $this->__('Review Order') ?></h1>
27
- </div>
28
- <?php if($errors): ?>
29
- <div class="error-msg">
30
- <?php foreach($errors as $error) {
31
- echo $error.'<br/>';
32
- }
33
- ?>
34
-
35
- </div>
36
- <br/>
37
- <?php endif;?>
38
- <script type="text/javascript">
39
- var form = new VarienForm('order_review_form');
40
- </script>
41
-
42
- <div class="addresses" style="width: 100%; text-align: left;">
43
- <div class="col-1 info-set" style="width:45%; display: inline-block; float: left;">
44
- <h2 class="legend"> Billing Info</h2>
45
- <?php echo $this->getChild('billing')->setFieldNamePrefix('billing')->toHtml(); ?>
46
- </div>
47
- <?php if(!$this->getQuoteIsVirtual()) :?>
48
- <div class="col-2 info-set" style="width:45%; display: inline-block; float: right;">
49
- <h2 class="legend"> Shipping Info</h2>
50
- <?php echo $this->getChild('shipping')->setFieldNamePrefix('shipping')->toHtml(); ?>
51
- </div>
52
- <?php endif;?>
53
- </div>
54
- <div style="clear: both;"></div>
55
-
56
-
57
- <?php if(!$this->getQuoteIsVirtual()) :?>
58
- <div><?php echo $this->getChildHtml('shipping_method'); ?></div>
59
- <?php endif;?>
60
-
61
- <div class="apruve-review-order">
62
- <form method="post" id="order_review_form" action="<?php echo $this->getPlaceOrderUrl() ?>">
63
- <div class="info-set">
64
- <h2 class="legend"><?php echo $this->__('Items in Your Shopping Cart') ?><span class="separator"> | </span><a href="<?php echo $this->getUrl('checkout/cart') ?>"><?php echo $this->__('Edit Shopping Cart') ?></a></h2>
65
- <div id="details-reload">
66
- <?php echo $this->getChildHtml('details') ?>
67
- </div>
68
- </div>
69
- <?php echo $this->getChildHtml('agreements'); ?>
70
- <div class="buttons-set buttons-set-order" id="review-buttons-container">
71
- <button type="button" id="review_button" value="<?php echo $this->__('Place Order') ?>" class="button btn-checkout" onclick="form.submit();"><span><span><?php echo $this->__('Place Order') ?></span></span></button>
72
- <span class="please-wait" id="review-please-wait" style="display:none;">
73
- <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Submitting order information...') ?>" title="<?php echo $this->__('Submitting order information...') ?>" class="v-middle" /> <?php echo $this->__('Submitting order information...') ?>
74
- </span>
75
- </div>
76
- </form>
77
- </div>
78
-
79
- <script type="text/javascript">
80
- //<![CDATA[
81
- function switchAddressBlockView(prefix) {
82
- var idAddressForm = prefix+'-address-form';
83
- var idAddressInfo = prefix+'-address-info';
84
- var form = $(idAddressForm);
85
-
86
- if(!form.visible()) {
87
- form.show();
88
- $(idAddressInfo).hide();
89
- } else {
90
- form.hide();
91
- $(idAddressInfo).show();
92
- }
93
- }
94
-
95
- //]]>
96
- </script>
app/design/frontend/base/default/template/apruvepayment/review/address.phtml DELETED
@@ -1,392 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Apache License, Version 2.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/Apache-2.0
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@apruve.com so we can send you a copy immediately.
14
- *
15
- * @category Apruve
16
- * @package Apruve_Payment
17
- * @copyright Copyright (coffee) 2014 Apruve, Inc. (http://www.apruve.com).
18
- * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
19
- */
20
- ?>
21
- <?php
22
- $prefix = $this->getFieldNamePrefix();
23
- $actionUrl = $this->getUrl('apruvepayment/payment/update' . $prefix . 'address');
24
-
25
- ?>
26
- <?php if (Mage::getVersion() >= '1.7.0.0') : ?>
27
- <div class="<?php echo $prefix; ?>-address-info" id="<?php echo $prefix; ?>-address-info">
28
- <?php echo $this->getAddress()->getFormated(true); ?>
29
- <br/>
30
- <a href="#" title="Edit Billing Information" onclick="switchAddressBlockView('<?php echo $prefix; ?>')">Edit</a>
31
- </div>
32
-
33
- <form method="post" action="<?php echo $actionUrl; ?>" class="address-form" style="display: none;"
34
- id="<?php echo $prefix . '-address-form'; ?>">
35
- <ul class="form-list form-list-narrow">
36
- <li id="<?php echo $prefix ?>-address-form" class="address-form">
37
- <fieldset>
38
- <input type="hidden" name="<?php echo $prefix ?>[address_id]"
39
- value="<?php echo $this->getAddress()->getId() ?>" id="<?php echo $prefix ?>:address_id"/>
40
- <ul>
41
- <li class="fields"><?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getQuote()->getCustomer())->setForceUseCustomerRequiredAttributes(!$this->isCustomerLoggedIn())->setFieldIdFormat($prefix . ':%s')->setFieldNameFormat($prefix . '[%s]')->toHtml() ?></li>
42
- <li class="fields">
43
- <div class="field">
44
- <label for="<?php echo $prefix ?>:company"><?php echo $this->__('Company') ?></label>
45
-
46
- <div class="input-box">
47
- <input type="text" id="<?php echo $prefix ?>:company"
48
- name="<?php echo $prefix ?>[company]"
49
- value="<?php echo $this->escapeHtml($this->getAddress()->getCompany()) ?>"
50
- title="<?php echo $this->__('Company') ?>"
51
- class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>"/>
52
- </div>
53
- </div>
54
- <?php if (!$this->isCustomerLoggedIn() && !$this->getHideEmailAddress()): ?>
55
- <div class="field">
56
- <label for="<?php echo $prefix ?>:email"
57
- class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
58
-
59
- <div class="input-box">
60
- <input type="text" name="<?php echo $prefix ?>[email]"
61
- id="<?php echo $prefix ?>:email"
62
- value="<?php echo $this->escapeHtml($this->getAddress()->getEmail()) ?>"
63
- title="<?php echo $this->__('Email Address') ?>"
64
- class="input-text validate-email required-entry"/>
65
- </div>
66
- </div>
67
- <?php endif; ?>
68
- </li>
69
- <?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
70
- <li class="wide">
71
- <label for="<?php echo $prefix ?>:street1"
72
- class="required"><em>*</em><?php echo $this->__('Address') ?></label>
73
-
74
- <div class="input-box">
75
- <input type="text" title="<?php echo $this->__('Street Address') ?>"
76
- name="<?php echo $prefix ?>[street][]" id="<?php echo $prefix ?>:street1"
77
- value="<?php echo $this->escapeHtml($this->getAddress()->getStreet(1)) ?>"
78
- class="input-text <?php echo $_streetValidationClass ?>"/>
79
- </div>
80
- </li>
81
- <?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
82
- <?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
83
- <li class="add-field">
84
- <div class="input-box">
85
- <input type="text" title="<?php echo $this->__('Street Address %s', $_i) ?>"
86
- name="<?php echo $prefix ?>[street][]"
87
- id="<?php echo $prefix ?>:street<?php echo $_i ?>"
88
- value="<?php echo $this->escapeHtml($this->getAddress()->getStreet($_i)) ?>"
89
- class="input-text <?php echo $_streetValidationClass ?>"/>
90
- </div>
91
- </li>
92
- <?php endfor; ?>
93
- <?php if ($this->helper('customer/address')->isVatAttributeVisible()) : ?>
94
- <li class="wide">
95
- <label for="<?php echo $prefix ?>:vat_id"><?php echo $this->__('VAT Number') ?></label>
96
-
97
- <div class="input-box">
98
- <input type="text" id="<?php echo $prefix ?>:vat_id"
99
- name="<?php echo $prefix ?>[vat_id]"
100
- value="<?php echo $this->escapeHtml($this->getAddress()->getVatId()) ?>"
101
- title="<?php echo $this->__('VAT Number') ?>"
102
- class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('vat_id') ?>"/>
103
- </div>
104
- </li>
105
- <?php endif; ?>