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; ?>
106
- <li class="fields">
107
- <div class="field">
108
- <label for="<?php echo $prefix ?>:city"
109
- class="required"><em>*</em><?php echo $this->__('City') ?></label>
110
-
111
- <div class="input-box">
112
- <input type="text" title="<?php echo $this->__('City') ?>"
113
- name="<?php echo $prefix ?>[city]"
114
- value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>"
115
- class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>"
116
- id="<?php echo $prefix ?>:city"/>
117
- </div>
118
- </div>
119
- <div class="field">
120
- <label for="<?php echo $prefix ?>:region_id"
121
- class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
122
-
123
- <div class="input-box">
124
- <select id="<?php echo $prefix ?>:region_id" name="<?php echo $prefix ?>[region_id]"
125
- title="<?php echo $this->__('State/Province') ?>" class="validate-select"
126
- style="display:none;">
127
- <option
128
- value=""><?php echo $this->__('Please select region, state or province') ?></option>
129
- </select>
130
- <script type="text/javascript">
131
- //<![CDATA[
132
- $('<?php echo $prefix ?>:region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
133
- //]]>
134
- </script>
135
- <input type="text" id="<?php echo $prefix ?>:region"
136
- name="<?php echo $prefix ?>[region]"
137
- value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>"
138
- title="<?php echo $this->__('State/Province') ?>"
139
- class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>"
140
- style="display:none;"/>
141
- </div>
142
- </div>
143
- </li>
144
- <li class="fields">
145
- <div class="field">
146
- <label for="<?php echo $prefix ?>:postcode"
147
- class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
148
-
149
- <div class="input-box">
150
- <input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>"
151
- name="<?php echo $prefix ?>[postcode]" id="<?php echo $prefix ?>:postcode"
152
- value="<?php echo $this->escapeHtml($this->getAddress()->getPostcode()) ?>"
153
- class="input-text validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>"/>
154
- </div>
155
- </div>
156
- <div class="field">
157
- <label for="<?php echo $prefix ?>:country_id"
158
- class="required"><em>*</em><?php echo $this->__('Country') ?></label>
159
-
160
- <div class="input-box">
161
- <?php echo $this->getCountryHtmlSelect($prefix) ?>
162
- </div>
163
- </div>
164
- </li>
165
- <li class="fields">
166
- <div class="field">
167
- <label for="<?php echo $prefix ?>:telephone"
168
- class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
169
-
170
- <div class="input-box">
171
- <input type="text" name="<?php echo $prefix ?>[telephone]"
172
- value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>"
173
- title="<?php echo $this->__('Telephone') ?>"
174
- class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>"
175
- id="<?php echo $prefix ?>:telephone"/>
176
- </div>
177
- </div>
178
- <div class="field">
179
- <label for="<?php echo $prefix ?>:fax"><?php echo $this->__('Fax') ?></label>
180
-
181
- <div class="input-box">
182
- <input type="text" name="<?php echo $prefix ?>[fax]"
183
- value="<?php echo $this->escapeHtml($this->getAddress()->getFax()) ?>"
184
- title="<?php echo $this->__('Fax') ?>"
185
- class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('fax') ?>"
186
- id="<?php echo $prefix ?>:fax"/>
187
- </div>
188
- </div>
189
- </li>
190
- <?php echo $this->getChildHtml('form.additional.info'); ?>
191
- <?php if ($this->getShowAsShippingCheckbox()): ?>
192
- <li class="control">
193
- <div class="field">
194
- <div class="input-box">
195
- <input type="checkbox" name="<?php echo $prefix ?>[as_shipping]"
196
- class="checkbox" value="1"
197
- title="<?php echo $this->__('Same as shipping') ?>"
198
- id="<?php echo $prefix ?>:as_shipping"
199
- <?php if ($this->getAddress()->getSameAsBilling()): ?>checked="checked"<?php endif; ?>/>
200
- </div>
201
- <label
202
- for="<?php echo $prefix ?>:as_shipping"><?php echo $this->__('Same as shipping') ?></label>
203
- </div>
204
- </li>
205
- <?php endif; ?>
206
- </ul>
207
- </fieldset>
208
- </li>
209
- </ul>
210
-
211
- <button type="submit" class="button" style="float: left; margin-top: 10px;"><span><span>Update</span></span>
212
- </button>
213
- <button type="button" class="button" style="float: left; margin-top: 10px; margin-left: 10px;"
214
- onclick="switchAddressBlockView('<?php echo $prefix; ?>')"><span><span>Cancel</span></span></button>
215
- </form>
216
- <?php else : ?>
217
- <div class="<?php echo $prefix; ?>-address-info" id="<?php echo $prefix; ?>-address-info">
218
- <?php echo $this->getAddress()->getFormated(true); ?>
219
- <br/>
220
- <a href="#" title="Edit Billing Information" onclick="switchAddressBlockView('<?php echo $prefix; ?>')">Edit</a>
221
- </div>
222
-
223
- <form method="post" action="<?php echo $actionUrl; ?>" class="address-form" style="display: none;"
224
- id="<?php echo $prefix . '-address-form'; ?>">
225
- <ul class="form-list form-list-narrow">
226
- <li id="<?php echo $prefix ?>-address-form" class="address-form">
227
- <fieldset>
228
- <input type="hidden" name="<?php echo $prefix ?>[address_id]"
229
- value="<?php echo $this->getAddress()->getId() ?>" id="<?php echo $prefix ?>:address_id"/>
230
- <ul>
231
- <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>
232
- <li class="fields">
233
- <div class="field">
234
- <label for="<?php echo $prefix ?>:company"><?php echo $this->__('Company') ?></label>
235
-
236
- <div class="input-box">
237
- <input type="text" id="<?php echo $prefix ?>:company"
238
- name="<?php echo $prefix ?>[company]"
239
- value="<?php echo $this->escapeHtml($this->getAddress()->getCompany()) ?>"
240
- title="<?php echo $this->__('Company') ?>" class="input-text"/>
241
- </div>
242
- </div>
243
- <?php if (!$this->isCustomerLoggedIn() && !$this->getHideEmailAddress()): ?>
244
- <div class="field">
245
- <label for="<?php echo $prefix ?>:email"
246
- class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
247
-
248
- <div class="input-box">
249
- <input type="text" name="<?php echo $prefix ?>[email]"
250
- id="<?php echo $prefix ?>:email"
251
- value="<?php echo $this->escapeHtml($this->getAddress()->getEmail()) ?>"
252
- title="<?php echo $this->__('Email Address') ?>"
253
- class="input-text validate-email required-entry"/>
254
- </div>
255
- </div>
256
- <?php endif; ?>
257
- </li>
258
- <li class="field">
259
- <label for="<?php echo $prefix ?>:street1"
260
- class="required"><em>*</em><?php echo $this->__('Address') ?></label>
261
-
262
- <div class="input-box">
263
- <input type="text" title="<?php echo $this->__('Street Address') ?>"
264
- name="<?php echo $prefix ?>[street][]" id="<?php echo $prefix ?>:street1"
265
- value="<?php echo $this->escapeHtml($this->getAddress()->getStreet(1)) ?>"
266
- class="input-text required-entry"/>
267
- </div>
268
- </li>
269
- <?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
270
- <li class="add-field">
271
- <div class="input-box">
272
- <input type="text" title="<?php echo $this->__('Street Address %s', $_i) ?>"
273
- name="<?php echo $prefix ?>[street][]"
274
- id="<?php echo $prefix ?>:street<?php echo $_i ?>"
275
- value="<?php echo $this->escapeHtml($this->getAddress()->getStreet($_i)) ?>"
276
- class="input-text"/>
277
- </div>
278
- </li>
279
- <?php endfor; ?>
280
- <li class="fields">
281
- <div class="field">
282
- <label for="<?php echo $prefix ?>:city"
283
- class="required"><em>*</em><?php echo $this->__('City') ?></label>
284
-
285
- <div class="input-box">
286
- <input type="text" title="<?php echo $this->__('City') ?>"
287
- name="<?php echo $prefix ?>[city]"
288
- value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>"
289
- class="input-text required-entry" id="<?php echo $prefix ?>:city"/>
290
- </div>
291
- </div>
292
- <div class="field">
293
- <label for="<?php echo $prefix ?>:region_id"
294
- class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
295
-
296
- <div class="input-box">
297
- <select id="<?php echo $prefix ?>:region_id" name="<?php echo $prefix ?>[region_id]"
298
- title="<?php echo $this->__('State/Province') ?>" class="validate-select"
299
- style="display:none;">
300
- <option
301
- value=""><?php echo $this->__('Please select region, state or province') ?></option>
302
- </select>
303
- <script type="text/javascript">
304
- //<![CDATA[
305
- $('<?php echo $prefix ?>:region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
306
- //]]>
307
- </script>
308
- <input type="text" id="<?php echo $prefix ?>:region"
309
- name="<?php echo $prefix ?>[region]"
310
- value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>"
311
- title="<?php echo $this->__('State/Province') ?>" class="input-text"
312
- style="display:none;"/>
313
- </div>
314
- </div>
315
- </li>
316
- <li class="fields">
317
- <div class="field">
318
- <label for="<?php echo $prefix ?>:postcode"
319
- class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
320
-
321
- <div class="input-box">
322
- <input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>"
323
- name="<?php echo $prefix ?>[postcode]" id="<?php echo $prefix ?>:postcode"
324
- value="<?php echo $this->escapeHtml($this->getAddress()->getPostcode()) ?>"
325
- class="input-text validate-zip-international"/>
326
- </div>
327
- </div>
328
- <div class="field">
329
- <label for="<?php echo $prefix ?>:country_id"
330
- class="required"><em>*</em><?php echo $this->__('Country') ?></label>
331
-
332
- <div class="input-box">
333
- <?php echo $this->getCountryHtmlSelect($prefix) ?>
334
- </div>
335
- </div>
336
- </li>
337
- <li class="fields">
338
- <div class="field">
339
- <label for="<?php echo $prefix ?>:telephone"
340
- class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
341
-
342
- <div class="input-box">
343
- <input type="text" name="<?php echo $prefix ?>[telephone]"
344
- value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>"
345
- title="<?php echo $this->__('Telephone') ?>" class="input-text"
346
- id="<?php echo $prefix ?>:telephone"/>
347
- </div>
348
- </div>
349
- <div class="field">
350
- <label for="<?php echo $prefix ?>:fax"><?php echo $this->__('Fax') ?></label>
351
-
352
- <div class="input-box">
353
- <input type="text" name="<?php echo $prefix ?>[fax]"
354
- value="<?php echo $this->escapeHtml($this->getAddress()->getFax()) ?>"
355
- title="<?php echo $this->__('Fax') ?>" class="input-text"
356
- id="<?php echo $prefix ?>:fax"/>
357
- </div>
358
- </div>
359
- </li>
360
- <?php echo $this->getChildHtml('form.additional.info'); ?>
361
- <?php if ($this->getShowAsShippingCheckbox()): ?>
362
- <li class="control">
363
- <div class="field">
364
- <div class="input-box">
365
- <input type="checkbox" name="<?php echo $prefix ?>[as_shipping]"
366
- class="checkbox" value="1"
367
- title="<?php echo $this->__('Same as shipping') ?>"
368
- id="<?php echo $prefix ?>:as_shipping"
369
- <?php if ($this->getAddress()->getSameAsBilling()): ?>checked="checked"<?php endif; ?>/>
370
- </div>
371
- <label
372
- for="<?php echo $prefix ?>:as_shipping"><?php echo $this->__('Same as shipping') ?></label>
373
- </div>
374
- </li>
375
- <?php endif; ?>
376
- </ul>
377
- </fieldset>
378
- </li>
379
- </ul>
380
-
381
- <button type="submit" class="button" style="float: left; margin-top: 10px;"><span><span>Update</span></span>
382
- </button>
383
- <button type="button" class="button" style="float: left; margin-top: 10px; margin-left: 10px;"
384
- onclick="switchAddressBlockView('<?php echo $prefix; ?>')"><span><span>Cancel</span></span></button>
385
- </form>
386
- <?php endif; ?>
387
- <script type="text/javascript">
388
- //<![CDATA[
389
- var <?php echo $prefix ?>RegionUpdater = new RegionUpdater('<?php echo $prefix ?>:country_id', '<?php echo $prefix ?>:region', '<?php echo $prefix ?>:region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, '<?php echo $prefix ?>:postcode');
390
- <?php echo $prefix ?>RegionUpdater.update();
391
- //]]>
392
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/apruvepayment/review/details.phtml DELETED
@@ -1,54 +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
- <table id="details-table" class="data-table">
22
- <?php if ($this->helper('tax')->displayCartBothPrices()): $colspan = $rowspan = 2; else: $colspan = $rowspan = 1; endif; ?>
23
- <col />
24
- <col width="1" />
25
- <col width="1" />
26
- <col width="1" />
27
- <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
28
- <col width="1" />
29
- <col width="1" />
30
- <?php endif; ?>
31
- <thead>
32
- <tr>
33
- <th rowspan="<?php echo $rowspan ?>"><?php echo $this->__('Product Name') ?></th>
34
- <th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Price') ?></th>
35
- <th rowspan="<?php echo $rowspan ?>" class="a-center"><?php echo $this->__('Qty') ?></th>
36
- <th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Subtotal') ?></th>
37
- </tr>
38
- <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
39
- <tr>
40
- <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
41
- <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
42
- <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
43
- <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
44
- </tr>
45
- <?php endif; ?>
46
- </thead>
47
- <?php echo $this->getChildHtml('totals'); ?>
48
- <tbody>
49
- <?php foreach($this->getItems() as $_item): ?>
50
- <?php echo $this->getItemHtml($_item) ?>
51
- <?php endforeach ?>
52
- </tbody>
53
- </table>
54
- <script type="text/javascript">decorateTable('details-table');</script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/apruvepayment/review/result.phtml DELETED
@@ -1,22 +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
- Thank you for your order.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/apruvepayment/review/shipping/method.phtml DELETED
@@ -1,48 +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
- ?>
23
- <fieldset id="shipping-method-container">
24
- <?php if ($this->getCanEditShippingMethod() || !$this->getCurrentShippingRate()):?>
25
- <?php if ($groups = $this->getShippingRateGroups()):?>
26
- <?php $currentRate = $this->getCurrentShippingRate(); ?>
27
- <select name="shipping_method" id="shipping_method" style="width:250px;" class="required-entry">
28
- <?php if (!$currentRate):?>
29
- <option value=""><?php echo $this->__('Please select a shipping method...') ?></option>
30
- <?php endif;?>
31
- <?php foreach ($groups as $code => $rates):?>
32
- <optgroup label="<?php echo $this->escapeHtml($this->getCarrierName($code)) ?>" style="font-style:normal;">
33
- <?php foreach ($rates as $rate):?>
34
- <option value="<?php echo $this->renderShippingRateValue($rate)?>"<?php echo ($currentRate === $rate) ? ' selected="selected"' : '' ;?>>
35
- <?php echo $this->renderShippingRateOption($rate)?>
36
- </option>
37
- <?php endforeach;?>
38
- </optgroup>
39
- <?php endforeach;?>
40
- </select>
41
- <?php else: ?>
42
- <p><strong><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></strong></p>
43
- <?php endif;?>
44
- <?php else: ?>
45
- <p><strong><?php echo $this->renderShippingRateOption($this->getCurrentShippingRate())?></strong></p>
46
- <?php endif; ?>
47
- </fieldset>
48
- <div style="display:none" id="shipping_method_update"><p><?php echo $this->__('Please update order data to get shipping methods and rates') ?></p></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/apruvepayment/review/shipping_method.phtml DELETED
@@ -1,38 +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
- <div class="info-set">
23
- <h2 class="legend">Shipping Method</h2>
24
- <form method="post" action="<?php echo $this->getUrl('apruvepayment/payment/updateShippingMethod');?>">
25
- <div id="checkout-shipping-method-load">
26
- <?php echo $this->getChildHtml('available') ?>
27
- </div>
28
- <script type="text/javascript">
29
- //<![CDATA[
30
- //var shippingMethod = new ShippingMethod('co-shipping-method-form', "<?php echo $this->getUrl('checkout/onepage/saveShippingMethod') ?>");
31
- //]]>
32
- </script>
33
- <div id="onepage-checkout-shipping-method-additional-load">
34
- <?php echo $this->getChildHtml('additional') ?>
35
- </div>
36
- <button type="submit" class="button"><span><span>Update</span></span></button>
37
- </form>
38
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/etc/modules/Apruve_ApruvePayment.xml CHANGED
@@ -1,8 +1,8 @@
1
- <config>
2
- <modules>
3
- <Apruve_ApruvePayment>
4
- <active>true</active>
5
- <codePool>community</codePool>
6
- </Apruve_ApruvePayment>
7
- </modules>
8
  </config>
1
+ <config>
2
+ <modules>
3
+ <Apruve_ApruvePayment>
4
+ <active>true</active>
5
+ <codePool>community</codePool>
6
+ </Apruve_ApruvePayment>
7
+ </modules>
8
  </config>
js/Apruve/ApruvePayment.js CHANGED
@@ -1,13 +1,11 @@
1
  var ApruvePayment = Class.create();
2
 
3
  ApruvePayment.prototype = {
4
- initialize: function (hash, pr, updatedShippingUrl) {
5
  if (!apruve) {
6
  return false;
7
  }
8
 
9
- this._checkShipping(pr, updatedShippingUrl);
10
-
11
  apruve.logoSrc = '';
12
  apruve.secureHash = hash;
13
  apruve.paymentRequest = pr;
@@ -20,7 +18,6 @@ ApruvePayment.prototype = {
20
  this._resetApruveRadio();
21
  this._prepareApruve();
22
  this._registerCallbacks();
23
-
24
  }
25
  },
26
 
@@ -42,7 +39,6 @@ ApruvePayment.prototype = {
42
  });
43
  },
44
 
45
-
46
  _resetApruveRadio: function () {
47
  if (!apruve.paymentRequestId) {
48
  document.getElementById("p_method_apruvepayment").checked = false;
@@ -57,32 +53,5 @@ ApruvePayment.prototype = {
57
  document.getElementById("aprt").disabled = false;
58
  }
59
  }
60
- },
61
-
62
-
63
- _checkShipping: function (pr, updatedShippingUrl) {
64
- if (apruve.paymentRequestId && !(apruve.paymentRequest.shipping_cents == pr.shipping_cents)) {
65
- this._setShippingUpdated(updatedShippingUrl);
66
- }
67
- },
68
-
69
- _setShippingUpdated: function (updatedShippingUrl) {
70
- var self = this;
71
- new Ajax.Request(
72
- updatedShippingUrl,
73
- {
74
- method: 'post',
75
- onSuccess: function(response) {
76
- if (!response.responseText) {
77
- apruve.paymentRequestId = '';
78
- self._resetApruveRadio();
79
- alert('Failed to update shipping cost. Please try to resubmit your order with apruve');
80
- }
81
- },
82
- onFailure: function() {
83
- self._resetApruveRadio();
84
- }
85
- }
86
- )
87
  }
88
  };
1
  var ApruvePayment = Class.create();
2
 
3
  ApruvePayment.prototype = {
4
+ initialize: function (hash, pr) {
5
  if (!apruve) {
6
  return false;
7
  }
8
 
 
 
9
  apruve.logoSrc = '';
10
  apruve.secureHash = hash;
11
  apruve.paymentRequest = pr;
18
  this._resetApruveRadio();
19
  this._prepareApruve();
20
  this._registerCallbacks();
 
21
  }
22
  },
23
 
39
  });
40
  },
41
 
 
42
  _resetApruveRadio: function () {
43
  if (!apruve.paymentRequestId) {
44
  document.getElementById("p_method_apruvepayment").checked = false;
53
  document.getElementById("aprt").disabled = false;
54
  }
55
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  }
57
  };
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Apruve_B2B_Payment_Gateway</name>
4
- <version>1.0.5</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.apache.org/licenses/LICENSE-2.0">Apache License, 2.0</license>
7
  <channel>community</channel>
@@ -10,9 +10,9 @@
10
  <description>Payments designed for business spending. Increase sales and reduce cart abandonment by allowing your shoppers to send purchases directly to their company or client for payment, simply by using an email address instead of a credit card. Learn more and sign up for a free merchant account at http://www.apruve.com.</description>
11
  <notes>Stable Version</notes>
12
  <authors><author><name>Apruve</name><user>auto-converted</user><email>magento@apruve.com</email></author></authors>
13
- <date>2014-02-21</date>
14
- <time>15:09:45</time>
15
- <contents><target name="magecommunity"><dir name="Apruve"><dir name="ApruvePayment"><dir name="Block"><dir name="Admin"><file name="Webhook.php" hash="9d4bdae192f68d18b90ba7758d65413a"/></dir><dir name="Payment"><file name="Form.php" hash="0e9788976c4fa4380ad6f76ca8e656d8"/></dir><dir name="Review"><file name="Billing.php" hash="ef25b3b421753e850492230121ba123d"/><file name="Details.php" hash="630be5289ef8190c50932195e78d6f2f"/><file name="Result.php" hash="c04da45eabf6a68111f212ed3f9f1a85"/><file name="Shipping.php" hash="6996af1a1165e1652327b596f7300625"/></dir><file name="Review.php" hash="3899d8ba1c67c9bddbcc1aedf20edea2"/></dir><dir name="Helper"><file name="Data.php" hash="4e541255b94d18f3ee058044810cade2"/></dir><dir name="Model"><dir name="Api"><file name="Abstract.php" hash="ff5ba985c0be19fbc494dff8b72fd0d7"/><file name="PaymentRequest.php" hash="20642627cc3ae5c3fd3551ee7d545350"/><file name="Rest.php" hash="24594a585e77d39141e481cd33817b3d"/></dir><dir name="Mysql4"><file name="Setup.php" hash="8b3e5b033dac91b47e59c024e16c04ec"/></dir><file name="PaymentMethod.php" hash="e59fa770e455f1bf19ccd2fc66d21386"/><file name="Session.php" hash="2f7d9205490a8c0a053c1898a8e01cc4"/></dir><dir name="controllers"><file name="PaymentController.php" hash="1235ea5891fb38639c0d21317b9560f4"/><file name="WebhookController.php" hash="f326a073653658b3844ee925fd20a4d8"/></dir><dir name="etc"><file name="config.xml" hash="f5ddfd89da4225dda4b878b1fe52d62e"/><file name="system.xml" hash="0bede58fc1882493df6710fd0d981d2f"/></dir><file name="LICENSE.txt" hash="9b76dd4b62de4f9840b5d462fcb25e39"/></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="apruvepayment.xml" hash="1d52df076454609594100f4f34410335"/></dir><dir name="template"><dir name="apruvepayment"><dir name="payment"><file name="form.phtml" hash="f5bb213aa629bed02b7c83c3e7512bbc"/><file name="mark.phtml" hash="c55da5ae5c0fb45c2433b9ac865bcd0d"/></dir><dir name="review"><dir name="shipping"><file name="method.phtml" hash="5d35b4f1f35d264bcd01864855da8db5"/></dir><file name="address.phtml" hash="6b9847fc1c92a1751de58691d6757313"/><file name="details.phtml" hash="603681f92d1683bf8edce9ac5bce7d2f"/><file name="result.phtml" hash="2b7438c88e2248f7591d600592210519"/><file name="shipping_method.phtml" hash="a8291b340315ca485c6a298eb86b3a0c"/></dir><file name="head.phtml" hash="34585fced2912e86978ab3253791c5a2"/><file name="review.phtml" hash="1c8f884b991d8842fbf9469d857ccb4a"/><file name="shortcut.phtml" hash="cfb4ddcaa286b8b5fd1dc32dcdcde77d"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Apruve_ApruvePayment.xml" hash="68277872189de89c07b32651805c0cfd"/></dir></target><target name="mageweb"><dir name="js"><dir name="Apruve"><file name="ApruvePayment.js" hash="e6f1716e3e0668963dffff0d1ab04fb1"/></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Apruve_B2B_Payment_Gateway</name>
4
+ <version>1.0.6</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.apache.org/licenses/LICENSE-2.0">Apache License, 2.0</license>
7
  <channel>community</channel>
10
  <description>Payments designed for business spending. Increase sales and reduce cart abandonment by allowing your shoppers to send purchases directly to their company or client for payment, simply by using an email address instead of a credit card. Learn more and sign up for a free merchant account at http://www.apruve.com.</description>
11
  <notes>Stable Version</notes>
12
  <authors><author><name>Apruve</name><user>auto-converted</user><email>magento@apruve.com</email></author></authors>
13
+ <date>2015-03-24</date>
14
+ <time>15:29:13</time>
15
+ <contents><target name="magecommunity"><dir name="Apruve"><dir name="ApruvePayment"><dir name="Block"><dir name="Admin"><file name="Webhook.php" hash="339e11982444fd861a8ab3ee78e81f6e"/></dir><dir name="Payment"><file name="Form.php" hash="6f87836d8901ed48438ba9bf7265c08d"/></dir></dir><dir name="Helper"><file name="Data.php" hash="a7915dbc3cd65f391233f23e9c5546cb"/></dir><dir name="Model"><dir name="Api"><file name="Abstract.php" hash="fb656371f8dd58ba56683e010d12face"/><file name="PaymentRequest.php" hash="1ff00368a158504e66003af1ce1c5a0a"/><file name="Rest.php" hash="e980c17639c4887d1b81336fbe5152ce"/></dir><dir name="Mysql4"><file name="Setup.php" hash="8b3e5b033dac91b47e59c024e16c04ec"/></dir><file name="PaymentMethod.php" hash="f7786b7d11f58a0b2234f5eac83752da"/></dir><dir name="controllers"><file name="WebhookController.php" hash="1e0af0e2ce12ef3719553f9d47532ad1"/></dir><dir name="etc"><file name="config.xml" hash="8434518c099578d8671fc61bcbff873e"/><file name="system.xml" hash="0bede58fc1882493df6710fd0d981d2f"/></dir><file name="LICENSE.txt" hash="9b76dd4b62de4f9840b5d462fcb25e39"/></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="apruvepayment.xml" hash="a5f41c280270a5fa44212c9d4cfe043a"/></dir><dir name="template"><dir name="apruvepayment"><dir name="payment"><file name="form.phtml" hash="79412de39f6470ddcbcd4011806b14da"/><file name="mark.phtml" hash="b4fa42f75f07e634f3f373ff08943276"/></dir><file name="head.phtml" hash="cd3f0d94fcfa901684a46f498e3425a1"/><file name="shortcut.phtml" hash="cfb4ddcaa286b8b5fd1dc32dcdcde77d"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Apruve_ApruvePayment.xml" hash="b9d4a9486387dce0b7911d46f1ab81c7"/></dir></target><target name="mage"><dir name="js"><dir name="Apruve"><file name="ApruvePayment.js" hash="d248d818f3e94ddf231f6002a8bc8bed"/></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>