Apruve_B2B_Payment_Gateway - Version 1.0.11

Version Notes

Stable Version

Download this release

Release Info

Developer Apruve
Extension Apruve_B2B_Payment_Gateway
Version 1.0.11
Comparing to
See all releases


Code changes from version 1.0.10 to 1.0.11

app/code/community/Apruve/ApruvePayment/Helper/Data.php CHANGED
@@ -35,6 +35,11 @@ class Apruve_ApruvePayment_Helper_Data extends Mage_Core_Helper_Abstract
35
  return $sourceArray[Mage::getStoreConfig('payment/apruvepayment/mode')];
36
  }
37
 
 
 
 
 
 
38
  public function getSrc()
39
  {
40
  $sourceModel = Mage::getModel('apruvepayment/mode');
35
  return $sourceArray[Mage::getStoreConfig('payment/apruvepayment/mode')];
36
  }
37
 
38
+ public function isAutoSubmit()
39
+ {
40
+ return Mage::getStoreConfig('payment/apruvepayment/autosubmit');
41
+ }
42
+
43
  public function getSrc()
44
  {
45
  $sourceModel = Mage::getModel('apruvepayment/mode');
app/code/community/Apruve/ApruvePayment/Model/Api/PaymentRequest.php CHANGED
@@ -88,10 +88,10 @@ class Apruve_ApruvePayment_Model_Api_PaymentRequest extends Apruve_ApruvePayment
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
  }
@@ -112,11 +112,7 @@ class Apruve_ApruvePayment_Model_Api_PaymentRequest extends Apruve_ApruvePayment
112
  {
113
  /** @var Mage_Sales_Model_Quote $quote */
114
  $quote = Mage::getSingleton('checkout/session')->getQuote();
115
- $amounts = Mage::getSingleton('checkout/session')->getApruveAmounts();
116
- if (!$amounts) {
117
- $amounts = Mage::helper('apruvepayment')->getAmountsFromQuote($quote);
118
- Mage::getSingleton('checkout/session')->setApruveAmounts($amounts);
119
- }
120
 
121
  $paymentRequest = array(
122
  'merchant_id' => $this->_getMerchantKey(),
@@ -131,14 +127,13 @@ class Apruve_ApruvePayment_Model_Api_PaymentRequest extends Apruve_ApruvePayment
131
  }
132
 
133
 
134
-
135
  /**
136
  * @param Mage_Sales_Model_Quote $quote
137
  */
138
  public function getShopperInfo($attrName)
139
  {
140
  $quote = Mage::getSingleton('checkout/session')->getQuote();
141
- $method = 'get'.ucfirst($attrName);
142
  if ($quote->getCustomerIsGuest()) {
143
  return $quote->getBillingAddress()->$method();
144
  }
@@ -163,6 +158,14 @@ class Apruve_ApruvePayment_Model_Api_PaymentRequest extends Apruve_ApruvePayment
163
  $viewUrl = $item->getProduct()->getProductUrl(false);
164
  $priceEaCents = $this->_convertPrice($item->getPrice());
165
 
 
 
 
 
 
 
 
 
166
  $line_item = array(
167
  'title' => $title,
168
  'amount_cents' => $amount_cents,
@@ -190,26 +193,25 @@ class Apruve_ApruvePayment_Model_Api_PaymentRequest extends Apruve_ApruvePayment
190
  $result = '';
191
  $variantInfo = array();
192
  $options = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct());
193
- if(isset($options['options'])) {
194
  $opt = $this->_getProductCustomOptions($options['options']);
195
- $variantInfo = array_merge($variantInfo, $opt);
196
  }
197
- if(isset($options['attributes_info'])) {
198
  $opt = $this->_getConfigurableOptions($options['attributes_info']);
199
- $variantInfo = array_merge($variantInfo, $opt);
200
  }
201
 
202
- if(isset($options['bundle_options'])) {
203
  $opt = $this->_getBundleOptions($options['bundle_options']);
204
- $variantInfo = array_merge($variantInfo, $opt);
205
  }
206
 
207
- if(!empty($variantInfo)) {
208
  $result = $this->_getFormatedVariantInfo($variantInfo);
209
  }
210
 
211
  return $result;
212
-
213
  }
214
 
215
  /**
@@ -220,7 +222,7 @@ class Apruve_ApruvePayment_Model_Api_PaymentRequest extends Apruve_ApruvePayment
220
  {
221
  $arr = array();
222
  foreach ($options as $option) {
223
- $arr[] = $option['label'].': '.$option['value'];
224
  }
225
 
226
  return $arr;
@@ -234,7 +236,7 @@ class Apruve_ApruvePayment_Model_Api_PaymentRequest extends Apruve_ApruvePayment
234
  {
235
  $arr = array();
236
  foreach ($attributesInfo as $option) {
237
- $arr[] = $option['label'].': '.$option['value'];
238
  }
239
  return $arr;
240
  }
@@ -246,8 +248,8 @@ class Apruve_ApruvePayment_Model_Api_PaymentRequest extends Apruve_ApruvePayment
246
  protected function _getBundleOptions($bundleOptions)
247
  {
248
  $arr = array();
249
- foreach($bundleOptions as $option) {
250
- $arr[] = $option['label'].': '.$option['value'][0]['title'];
251
  }
252
  return $arr;
253
  }
@@ -260,7 +262,7 @@ class Apruve_ApruvePayment_Model_Api_PaymentRequest extends Apruve_ApruvePayment
260
  //todo: new line symbol
261
  protected function _getFormatedVariantInfo($arr)
262
  {
263
- if(count($arr) == 1) {
264
  $result = $arr[0];
265
  } else {
266
  $result = implode(', ', $arr);
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
  }
112
  {
113
  /** @var Mage_Sales_Model_Quote $quote */
114
  $quote = Mage::getSingleton('checkout/session')->getQuote();
115
+ $amounts = Mage::helper('apruvepayment')->getAmountsFromQuote($quote);
 
 
 
 
116
 
117
  $paymentRequest = array(
118
  'merchant_id' => $this->_getMerchantKey(),
127
  }
128
 
129
 
 
130
  /**
131
  * @param Mage_Sales_Model_Quote $quote
132
  */
133
  public function getShopperInfo($attrName)
134
  {
135
  $quote = Mage::getSingleton('checkout/session')->getQuote();
136
+ $method = 'get' . ucfirst($attrName);
137
  if ($quote->getCustomerIsGuest()) {
138
  return $quote->getBillingAddress()->$method();
139
  }
158
  $viewUrl = $item->getProduct()->getProductUrl(false);
159
  $priceEaCents = $this->_convertPrice($item->getPrice());
160
 
161
+ if (isset($shortDescription) && strlen($shortDescription) > 3500) {
162
+ $shortDescription = substr($shortDescription, 0, 3500);
163
+ }
164
+
165
+ if (isset($variantInfo) && strlen($variantInfo) > 255) {
166
+ $variantInfo = substr($variantInfo, 0, 255);
167
+ }
168
+
169
  $line_item = array(
170
  'title' => $title,
171
  'amount_cents' => $amount_cents,
193
  $result = '';
194
  $variantInfo = array();
195
  $options = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct());
196
+ if (isset($options['options'])) {
197
  $opt = $this->_getProductCustomOptions($options['options']);
198
+ $variantInfo = array_merge($variantInfo, $opt);
199
  }
200
+ if (isset($options['attributes_info'])) {
201
  $opt = $this->_getConfigurableOptions($options['attributes_info']);
202
+ $variantInfo = array_merge($variantInfo, $opt);
203
  }
204
 
205
+ if (isset($options['bundle_options'])) {
206
  $opt = $this->_getBundleOptions($options['bundle_options']);
207
+ $variantInfo = array_merge($variantInfo, $opt);
208
  }
209
 
210
+ if (!empty($variantInfo)) {
211
  $result = $this->_getFormatedVariantInfo($variantInfo);
212
  }
213
 
214
  return $result;
 
215
  }
216
 
217
  /**
222
  {
223
  $arr = array();
224
  foreach ($options as $option) {
225
+ $arr[] = $option['label'] . ': ' . $option['value'];
226
  }
227
 
228
  return $arr;
236
  {
237
  $arr = array();
238
  foreach ($attributesInfo as $option) {
239
+ $arr[] = $option['label'] . ': ' . $option['value'];
240
  }
241
  return $arr;
242
  }
248
  protected function _getBundleOptions($bundleOptions)
249
  {
250
  $arr = array();
251
+ foreach ($bundleOptions as $option) {
252
+ $arr[] = $option['label'] . ': ' . $option['value'][0]['title'];
253
  }
254
  return $arr;
255
  }
262
  //todo: new line symbol
263
  protected function _getFormatedVariantInfo($arr)
264
  {
265
+ if (count($arr) == 1) {
266
  $result = $arr[0];
267
  } else {
268
  $result = implode(', ', $arr);
app/code/community/Apruve/ApruvePayment/Model/Api/Rest.php CHANGED
@@ -64,9 +64,10 @@ class Apruve_ApruvePayment_Model_Api_Rest extends Apruve_ApruvePayment_Model_Api
64
  * @param float $tax
65
  * @return bool
66
  */
67
- public function updatePaymentRequest($paymentRequestId, $amount, $shipping, $tax)
68
  {
69
  $data = json_encode(array(
 
70
  'amount_cents' => $this->_convertPrice($amount),
71
  'shipping_cents' => $this->_convertPrice($shipping),
72
  'tax_cents' => $this->_convertPrice($tax),
64
  * @param float $tax
65
  * @return bool
66
  */
67
+ public function updatePaymentRequest($paymentRequestId, $amount, $shipping, $tax, $orderIncrementId)
68
  {
69
  $data = json_encode(array(
70
+ 'merchant_order_id' => $orderIncrementId,
71
  'amount_cents' => $this->_convertPrice($amount),
72
  'shipping_cents' => $this->_convertPrice($shipping),
73
  'tax_cents' => $this->_convertPrice($tax),
app/code/community/Apruve/ApruvePayment/Model/PaymentMethod.php CHANGED
@@ -72,19 +72,19 @@ class Apruve_ApruvePayment_Model_PaymentMethod extends Mage_Payment_Model_Method
72
  $rest = Mage::getModel('apruvepayment/api_rest');
73
  /** @var Mage_Sales_Model_Order $order */
74
  $order = $payment->getOrder();
 
75
  $amounts = Mage::helper('apruvepayment')->getAmountsFromQuote($order->getQuote());
76
- $oldAmounts = Mage::getSingleton('checkout/session')->getApruveAmounts();
77
- if ($oldAmounts != $amounts) {
78
- $updateResult = $rest->updatePaymentRequest(
79
- $token,
80
- $amounts['amount_cents'],
81
- $amounts['tax_cents'],
82
- $amounts['shipping_cents']
83
- );
84
- Mage::getSingleton('checkout/session')->setApruveAmounts($amounts);
85
- if (!$updateResult) {
86
- Mage::throwException('Couldn\'t update order totals to Apruve');
87
- }
88
  }
89
 
90
  $apruvePayment = $rest->postPayment($token, $amount);
72
  $rest = Mage::getModel('apruvepayment/api_rest');
73
  /** @var Mage_Sales_Model_Order $order */
74
  $order = $payment->getOrder();
75
+
76
  $amounts = Mage::helper('apruvepayment')->getAmountsFromQuote($order->getQuote());
77
+
78
+ $updateResult = $rest->updatePaymentRequest(
79
+ $token,
80
+ $amounts['amount_cents'],
81
+ $amounts['tax_cents'],
82
+ $amounts['shipping_cents'],
83
+ $order->getIncrementId()
84
+ );
85
+
86
+ if (!$updateResult) {
87
+ Mage::throwException('Couldn\'t update order totals to Apruve');
 
88
  }
89
 
90
  $apruvePayment = $rest->postPayment($token, $amount);
app/code/community/Apruve/ApruvePayment/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Apruve_ApruvePayment>
5
- <version>1.0.10</version>
6
  </Apruve_ApruvePayment>
7
  </modules>
8
  <frontend>
@@ -65,6 +65,7 @@
65
  <payment>
66
  <apruvepayment>
67
  <mode>1</mode>
 
68
  <active>1</active>
69
  <model>apruvepayment/paymentMethod</model>
70
  <order_status>pending_payment</order_status>
2
  <config>
3
  <modules>
4
  <Apruve_ApruvePayment>
5
+ <version>1.0.11</version>
6
  </Apruve_ApruvePayment>
7
  </modules>
8
  <frontend>
65
  <payment>
66
  <apruvepayment>
67
  <mode>1</mode>
68
+ <autosubmit>1</autosubmit>
69
  <active>1</active>
70
  <model>apruvepayment/paymentMethod</model>
71
  <order_status>pending_payment</order_status>
app/code/community/Apruve/ApruvePayment/etc/system.xml CHANGED
@@ -28,6 +28,16 @@
28
  <show_in_website>1</show_in_website>
29
  <show_in_store>0</show_in_store>
30
  </mode>
 
 
 
 
 
 
 
 
 
 
31
  <order_status translate="label">
32
  <label>New order status</label>
33
  <frontend_type>select</frontend_type>
28
  <show_in_website>1</show_in_website>
29
  <show_in_store>0</show_in_store>
30
  </mode>
31
+ <autosubmit translate="label">
32
+ <label>Jump to next step of checkout when Apruve modal window closes</label>
33
+ <comment>disabling this option recommended only in case of compatibility issues</comment>
34
+ <frontend_type>select</frontend_type>
35
+ <source_model>adminhtml/system_config_source_yesno</source_model>
36
+ <sort_order>3</sort_order>
37
+ <show_in_default>1</show_in_default>
38
+ <show_in_website>1</show_in_website>
39
+ <show_in_store>0</show_in_store>
40
+ </autosubmit>
41
  <order_status translate="label">
42
  <label>New order status</label>
43
  <frontend_type>select</frontend_type>
app/design/frontend/base/default/layout/apruvepayment.xml DELETED
@@ -1,7 +0,0 @@
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/payment/form.phtml CHANGED
@@ -35,6 +35,7 @@ $paymentRequestModel = $helper->getPaymentRequestApiModel();
35
  var pr = <?php echo $paymentRequestModel->getPaymentRequestJSON();?>;
36
  var shopperName = '<?php echo $paymentRequestModel->getShopperInfo('name');?>';
37
  var shopperEmail = '<?php echo $paymentRequestModel->getShopperInfo('email');?>';
38
- var oApruvePayment = new ApruvePayment(sh, pr, shopperName, shopperEmail);
 
39
  </script>
40
 
35
  var pr = <?php echo $paymentRequestModel->getPaymentRequestJSON();?>;
36
  var shopperName = '<?php echo $paymentRequestModel->getShopperInfo('name');?>';
37
  var shopperEmail = '<?php echo $paymentRequestModel->getShopperInfo('email');?>';
38
+ var autoSubmit = '<?php echo $helper->isAutoSubmit();?>';
39
+ var oApruvePayment = new ApruvePayment(sh, pr, shopperName, shopperEmail, autoSubmit);
40
  </script>
41
 
js/Apruve/ApruvePayment.js CHANGED
@@ -1,7 +1,7 @@
1
  var ApruvePayment = Class.create();
2
 
3
  ApruvePayment.prototype = {
4
- initialize: function (hash, pr, shopperName, shopperEmail) {
5
  if (!apruve) {
6
  return false;
7
  }
@@ -11,6 +11,7 @@ ApruvePayment.prototype = {
11
  apruve.paymentRequest = pr;
12
  apruve.shopperName = shopperName;
13
  apruve.shopperEmail = shopperEmail;
 
14
  this._onLoad();
15
  },
16
 
@@ -34,6 +35,13 @@ ApruvePayment.prototype = {
34
  var self = this;
35
  apruve.registerApruveCallback(apruve.APRUVE_COMPLETE_EVENT, function () {
36
  self._resetApruveRadio();
 
 
 
 
 
 
 
37
  });
38
 
39
  apruve.registerApruveCallback(apruve.APRUVE_CLOSED_EVENT, function () {
1
  var ApruvePayment = Class.create();
2
 
3
  ApruvePayment.prototype = {
4
+ initialize: function (hash, pr, shopperName, shopperEmail, autoSubmit) {
5
  if (!apruve) {
6
  return false;
7
  }
11
  apruve.paymentRequest = pr;
12
  apruve.shopperName = shopperName;
13
  apruve.shopperEmail = shopperEmail;
14
+ this.autoSubmit = autoSubmit;
15
  this._onLoad();
16
  },
17
 
35
  var self = this;
36
  apruve.registerApruveCallback(apruve.APRUVE_COMPLETE_EVENT, function () {
37
  self._resetApruveRadio();
38
+ if (self.autoSubmit == true) {
39
+ if (typeof payment !== "undefined" && typeof payment.save === "function") {
40
+ payment.save();
41
+ } else if (typeof payment !== "undefined" && typeof payment.formId !== "undefined") {
42
+ $(payment.formId).submit();
43
+ }
44
+ }
45
  });
46
 
47
  apruve.registerApruveCallback(apruve.APRUVE_CLOSED_EVENT, function () {
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.10</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>Apruve</user><email>magento@apruve.com</email></author></authors>
13
- <date>2015-09-24</date>
14
- <time>14:16:57</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="c84481487b8a831fc382d90c76eeb962"/></dir></dir><dir name="Helper"><file name="Data.php" hash="c9ccc4476aadaa87db245e0ee0e29243"/></dir><file name="LICENSE.txt" hash="9b76dd4b62de4f9840b5d462fcb25e39"/><dir name="Model"><dir name="Api"><file name="Abstract.php" hash="a72657b7fd5a6ec061d73df511ecdb3e"/><file name="PaymentRequest.php" hash="03d01ce2331baa581175cad124ccb8cb"/><file name="Rest.php" hash="862b5c60f01975db7d37ffcea5e53443"/></dir><file name="Mode.php" hash="680b0b1bbcece8ac6d6606b80e4669df"/><dir name="Mysql4"><file name="Setup.php" hash="8b3e5b033dac91b47e59c024e16c04ec"/></dir><file name="PaymentMethod.php" hash="a3584c00f1e8e1bdf063c495dbb462b4"/></dir><dir name="controllers"><file name="WebhookController.php" hash="185f4757d5d289982f55d551d1b4d5ae"/></dir><dir name="etc"><file name="config.xml" hash="6d6201a0656cd00ccadcbc64d4460c82"/><file name="system.xml" hash="b2761cff5a27a724bdd165c816e3f092"/></dir></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"><file name="head.phtml" hash="36809c6a8fa5aad587b03e2107482bdf"/><dir name="payment"><file name="form.phtml" hash="d81bd872b9b6c9808e038a8972b99c94"/></dir></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="a359d9f296b87bf2c2ac3a75bf30b640"/></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Apruve_B2B_Payment_Gateway</name>
4
+ <version>1.0.11</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>Apruve</user><email>magento@apruve.com</email></author></authors>
13
+ <date>2015-11-03</date>
14
+ <time>10:52:36</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="c84481487b8a831fc382d90c76eeb962"/></dir></dir><dir name="Helper"><file name="Data.php" hash="5c90b28c85b736a9c42f3b3ac0625b3f"/></dir><file name="LICENSE.txt" hash="9b76dd4b62de4f9840b5d462fcb25e39"/><dir name="Model"><dir name="Api"><file name="Abstract.php" hash="a72657b7fd5a6ec061d73df511ecdb3e"/><file name="PaymentRequest.php" hash="44d1ac8d843467ea01b4876d53516550"/><file name="Rest.php" hash="29d9c63bb3545cc7d6383582ff41e466"/></dir><file name="Mode.php" hash="680b0b1bbcece8ac6d6606b80e4669df"/><dir name="Mysql4"><file name="Setup.php" hash="8b3e5b033dac91b47e59c024e16c04ec"/></dir><file name="PaymentMethod.php" hash="0f88915299a9b27ccb204c1f9f4c6d31"/></dir><dir name="controllers"><file name="WebhookController.php" hash="185f4757d5d289982f55d551d1b4d5ae"/></dir><dir name="etc"><file name="config.xml" hash="017ec63d4403c6cff56e1ade84435f54"/><file name="system.xml" hash="065fd7d1ced76bb5fb2ba4bcb779efb3"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="apruvepayment"><file name="head.phtml" hash="36809c6a8fa5aad587b03e2107482bdf"/><dir name="payment"><file name="form.phtml" hash="fffe2fb194db0fa68bacf59174654a16"/></dir></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="5b84bf57eb8ae2bb76d99a4ab6844450"/></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>