Apruve_B2B_Payment_Gateway - Version 2.0.2

Version Notes

Stable Version

Download this release

Release Info

Developer Apruve
Extension Apruve_B2B_Payment_Gateway
Version 2.0.2
Comparing to
See all releases


Code changes from version 2.0.1 to 2.0.2

app/code/community/Apruve/ApruvePayment/Model/Api/Rest/Invoice.php CHANGED
@@ -33,6 +33,9 @@ class Apruve_ApruvePayment_Model_Api_Rest_Invoice extends Apruve_ApruvePayment_M
33
  */
34
  protected function _getCreateInvoiceUrl($apruveOrderId)
35
  {
 
 
 
36
  return $this->getBaseUrl(true) . $this->getApiUrl() . 'orders/' . $apruveOrderId . '/invoices';
37
  }
38
 
@@ -243,4 +246,38 @@ class Apruve_ApruvePayment_Model_Api_Rest_Invoice extends Apruve_ApruvePayment_M
243
  $result = $this->execCurlRequest($this->_getCancelInvoiceUrl($apruveInvoiceId), 'POST');
244
  return $result;
245
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  }
33
  */
34
  protected function _getCreateInvoiceUrl($apruveOrderId)
35
  {
36
+ if($apruveOrderId === null){
37
+ Mage::throwException(Mage::helper('apruvepayment')->__('No Apruve Order ID for _getCreateInvoiceUrl'));
38
+ }
39
  return $this->getBaseUrl(true) . $this->getApiUrl() . 'orders/' . $apruveOrderId . '/invoices';
40
  }
41
 
246
  $result = $this->execCurlRequest($this->_getCancelInvoiceUrl($apruveInvoiceId), 'POST');
247
  return $result;
248
  }
249
+
250
+
251
+ /**
252
+ * refund an existing invoice by its ID in apruve
253
+ *
254
+ * @param $id string
255
+ * @return $result string
256
+ */
257
+ public function refundInvoice($apruveInvoiceId, $amount)
258
+ {
259
+
260
+ $data = json_encode(array(
261
+ "amount_cents" => ($amount * 100),
262
+ "currency" => "USD",
263
+ "reason" => "OTHER"
264
+ ));
265
+ $curlOptions = [];
266
+ $curlOptions[CURLOPT_POSTFIELDS] = $data;
267
+
268
+ $result = $this->execCurlRequest($this->_getInvoiceRefundUrl($apruveInvoiceId), 'POST', $curlOptions);
269
+
270
+ return $result;
271
+ }
272
+
273
+ /**
274
+ * Get url for invoice refund
275
+ * @param string $apruveOrderId
276
+ * @return string
277
+ */
278
+ protected function _getInvoiceRefundUrl($apruveInvoiceId)
279
+ {
280
+ return $this->getBaseUrl(true) . $this->getApiUrl() . 'invoices/' . $apruveInvoiceId . '/invoice_returns';
281
+ }
282
+
283
  }
app/code/community/Apruve/ApruvePayment/Model/Api/Rest/Order.php CHANGED
@@ -158,7 +158,7 @@ class Apruve_ApruvePayment_Model_Api_Rest_Order extends Apruve_ApruvePayment_Mod
158
  $curlOptions = [];
159
  $curlOptions[CURLOPT_POSTFIELDS] = $data;
160
 
161
- if (@$apruveOrderId === null) {
162
  $curlAction = 'POST';
163
  } else {
164
  $curlAction = 'PUT';
@@ -210,6 +210,16 @@ class Apruve_ApruvePayment_Model_Api_Rest_Order extends Apruve_ApruvePayment_Mod
210
  return $result;
211
  }
212
 
 
 
 
 
 
 
 
 
 
 
213
  /**
214
  * Get order from quote
215
  *
@@ -227,6 +237,27 @@ class Apruve_ApruvePayment_Model_Api_Rest_Order extends Apruve_ApruvePayment_Mod
227
  return $order;
228
  }
229
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
  /**
231
  * Finalize an existing order by its ID in apruve
232
  *
158
  $curlOptions = [];
159
  $curlOptions[CURLOPT_POSTFIELDS] = $data;
160
 
161
+ if ($apruveOrderId === null) {
162
  $curlAction = 'POST';
163
  } else {
164
  $curlAction = 'PUT';
210
  return $result;
211
  }
212
 
213
+ /**
214
+ * Get url for order invoices
215
+ * @param string $apruveOrderId
216
+ * @return string
217
+ */
218
+ protected function _getOrderInvoicesUrl($apruveOrderId)
219
+ {
220
+ return $this->getBaseUrl(true) . $this->getApiUrl() . 'orders/' . $apruveOrderId . '/invoices';
221
+ }
222
+
223
  /**
224
  * Get order from quote
225
  *
237
  return $order;
238
  }
239
 
240
+ /**
241
+ * Get invoices from order
242
+ *
243
+ * @param $apruveOrderId string
244
+ * @return $invoices
245
+ * @throws Mage_Core_Exception
246
+ */
247
+ public function getInvoices($apruveOrderId)
248
+ {
249
+ $result = $this->execCurlRequest($this->_getOrderInvoicesUrl($apruveOrderId));
250
+ if ($result['success'] == true) {
251
+ Mage::helper('apruvepayment')->logException('getInvoices...');
252
+ return $result['response'];
253
+ } else {
254
+ Mage::throwException(Mage::helper('apruvepayment')->__('Couldn\'t get invoices from order.'));
255
+ }
256
+
257
+ return $result;
258
+ }
259
+
260
+
261
  /**
262
  * Finalize an existing order by its ID in apruve
263
  *
app/code/community/Apruve/ApruvePayment/Model/PaymentMethod.php CHANGED
@@ -24,161 +24,241 @@
24
  */
25
  class Apruve_ApruvePayment_Model_PaymentMethod extends Mage_Payment_Model_Method_Abstract
26
  {
27
- const PAYMENT_METHOD_CODE = 'apruvepayment';
28
-
29
- protected $_code = self::PAYMENT_METHOD_CODE;
30
- protected $_formBlockType = 'apruvepayment/payment_form';
31
-
32
- protected $_canAuthorize = true;
33
- protected $_canCapture = true;
34
- protected $_canVoid = true;
35
- protected $_canUseInternal = true;
36
- protected $_canUseCheckout = true;
37
- protected $_canCreateBillingAgreement = true;
38
- protected $_isGateway = true;
39
- protected $_canManageRecurringProfiles = false;
40
- protected $_canUseForMultishipping = false;
41
- protected $_canReviewPayment = true;
42
-
43
- /**
44
- * Can edit order (renew order)
45
- *
46
- * @return bool
47
- */
48
- public function canEdit()
49
- {
50
- return false;
51
- }
52
-
53
- /**
54
- * Assign data to info model instance
55
- *
56
- * @param mixed $data
57
- * @return Mage_Payment_Model_Info
58
- */
59
- public function assignData($data)
60
- {
61
- if (is_array($data)) {
62
- $this->getInfoInstance()->setAdditionalInformation('aprt', isset($data['aprt']) ? $data['aprt'] : null);
63
- } elseif ($data instanceof Varien_Object) {
64
- $aprt = $data->getAprt();
65
- $this->getInfoInstance()->setAdditionalInformation('aprt', isset($aprt) ? $aprt : null);
66
- }
67
- return $this;
68
- }
69
-
70
- /**
71
- * Check whether apruve payment request id(aprt) is exitst
72
- * @return Mage_Payment_Model_Abstract|void
73
- * @throws Mage_Core_Exception
74
- */
75
- public function validate()
76
- {
77
- parent::validate();
78
-
79
- if (Mage::app()->getStore()->isAdmin()) {
80
- $paymentInfo = $this->getInfoInstance();
81
- if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
82
- $billingCountry = $paymentInfo->getOrder()->getBillingAddress()->getCountryId();
83
- } else {
84
- $billingCountry = $paymentInfo->getQuote()->getBillingAddress()->getCountryId();
85
- }
86
- if (!$this->canUseForCountry($billingCountry)) {
87
- Mage::throwException($this->_getHelper()->__('Selected payment type is not allowed for billing country.'));
88
- }
89
- return $this;
90
- } elseif (!$this->getInfoInstance()->getAdditionalInformation('aprt')) {
91
- Mage::throwException('Something is going wrong, try again to post order with apruve.');
92
- }
93
- }
94
-
95
- /**
96
- * Get token and create transaction
97
- * @param Varien_Object $payment
98
- * @param float $amount
99
- * @return Mage_Payment_Model_Abstract|void
100
- * @throws Mage_Core_Exception
101
- */
102
- public function authorize(Varien_Object $payment, $amount)
103
- {
104
- parent::authorize($payment, $amount);
105
- Mage::helper('apruvepayment')->logException('Authorize...');
106
-
107
- $additionalInformation = $payment->getAdditionalInformation();
108
- $token = $additionalInformation['aprt'];
109
-
110
- /** @var Mage_Sales_Model_Order $order */
111
- $order = $payment->getOrder();
112
-
113
- /** @var Apruve_ApruvePayment_Helper_Data $apiVersion */
114
- $apiVersion = Mage::helper('apruvepayment')->getApiVersion();
115
-
116
- /** @var Apruve_ApruvePayment_Model_Api_Rest_Order $orderApi */
117
- $orderApi = Mage::getModel('apruvepayment/api_rest_order');
118
-
119
-
120
- $updateResult = $orderApi->updateOrder($token, $order);
121
- if (!$updateResult || !$updateResult['success']) {
122
- Mage::throwException('Couldn\'t update order in Apruve.');
123
- }
124
-
125
- return $this;
126
- }
127
-
128
- /**
129
- * Captures a payment
130
- *
131
- * @param Varien_Object $payment
132
- * @return bool
133
- * @throws Mage_Core_Exception
134
- */
135
- public function capture(Varien_Object $payment, $amount)
136
- {
137
- parent::capture($payment, $amount);
138
- Mage::helper('apruvepayment')->logException('Capture...');
139
-
140
- if ($amount <= 0) {
141
- Mage::throwException(Mage::helper('paygate')->__('Invalid amount for capture.'));
142
- }
143
-
144
- $payment->setSkipTransactionCreation(true);
145
- return $this;
146
- }
147
-
148
- /**
149
- * Check void availability
150
- *
151
- * @param Varien_Object $payment
152
- * @return bool
153
- */
154
- public function canVoid(Varien_Object $payment)
155
- {
156
- if ($payment instanceof Mage_Sales_Model_Order_Invoice
157
- || $payment instanceof Mage_Sales_Model_Order_Creditmemo
158
- ) {
159
- return false;
160
- }
161
- if ($payment->getAmountPaid()) {
162
- $this->_canVoid = false;
163
- }
164
-
165
- return true;
166
- }
167
-
168
- /**
169
- * Attempt to void the authorization on cancelling
170
- *
171
- * @param Varien_Object $payment
172
- * @return Apruve_ApruvePayment_Model_PaymentMethod | false
173
- */
174
- public function cancel(Varien_Object $payment)
175
- {
176
- Mage::helper('apruvepayment')->logException('Cancel...');
177
-
178
- if (!$payment->getOrder()->getInvoiceCollection()->count()) {
179
- return $this->void($payment);
180
- }
181
-
182
- return false;
183
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  }
24
  */
25
  class Apruve_ApruvePayment_Model_PaymentMethod extends Mage_Payment_Model_Method_Abstract
26
  {
27
+ const PAYMENT_METHOD_CODE = 'apruvepayment';
28
+
29
+ protected $_code = self::PAYMENT_METHOD_CODE;
30
+ protected $_formBlockType = 'apruvepayment/payment_form';
31
+
32
+ protected $_canAuthorize = true;
33
+ protected $_canCapture = true;
34
+ protected $_canRefund = true;
35
+ protected $_canRefundInvoicePartial = true;
36
+ protected $_canVoid = true;
37
+ protected $_canUseInternal = true;
38
+ protected $_canUseCheckout = true;
39
+ protected $_canCreateBillingAgreement = true;
40
+ protected $_isGateway = true;
41
+ protected $_canManageRecurringProfiles = false;
42
+ protected $_canUseForMultishipping = false;
43
+ protected $_canReviewPayment = true;
44
+
45
+ /**
46
+ * Can edit order (renew order)
47
+ *
48
+ * @return bool
49
+ */
50
+ public function canEdit()
51
+ {
52
+ return false;
53
+ }
54
+
55
+ /**
56
+ * Assign data to info model instance
57
+ *
58
+ * @param mixed $data
59
+ * @return Mage_Payment_Model_Info
60
+ */
61
+ public function assignData($data)
62
+ {
63
+ if (is_array($data)) {
64
+ $this->getInfoInstance()->setAdditionalInformation('aprt', isset($data['aprt']) ? $data['aprt'] : null);
65
+ } elseif ($data instanceof Varien_Object) {
66
+ $aprt = $data->getAprt();
67
+ $this->getInfoInstance()->setAdditionalInformation('aprt', isset($aprt) ? $aprt : null);
68
+ }
69
+ return $this;
70
+ }
71
+
72
+ /**
73
+ * Check whether apruve payment request id(aprt) is exitst
74
+ * @return Mage_Payment_Model_Abstract|void
75
+ * @throws Mage_Core_Exception
76
+ */
77
+ public function validate()
78
+ {
79
+ parent::validate();
80
+
81
+ if (Mage::app()->getStore()->isAdmin()) {
82
+ $paymentInfo = $this->getInfoInstance();
83
+ if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
84
+ $billingCountry = $paymentInfo->getOrder()->getBillingAddress()->getCountryId();
85
+ } else {
86
+ $billingCountry = $paymentInfo->getQuote()->getBillingAddress()->getCountryId();
87
+ }
88
+ if (!$this->canUseForCountry($billingCountry)) {
89
+ Mage::throwException($this->_getHelper()->__('Selected payment type is not allowed for billing country.'));
90
+ }
91
+ return $this;
92
+ } elseif (!$this->getInfoInstance()->getAdditionalInformation('aprt')) {
93
+ Mage::throwException('Something is going wrong, try again to post order with apruve.');
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Get token and create transaction
99
+ * @param Varien_Object $payment
100
+ * @param float $amount
101
+ * @return Mage_Payment_Model_Abstract|void
102
+ * @throws Mage_Core_Exception
103
+ */
104
+ public function authorize(Varien_Object $payment, $amount)
105
+ {
106
+ parent::authorize($payment, $amount);
107
+ Mage::helper('apruvepayment')->logException('Authorize...');
108
+
109
+ $additionalInformation = $payment->getAdditionalInformation();
110
+ $token = $additionalInformation['aprt'];
111
+
112
+ /** @var Mage_Sales_Model_Order $order */
113
+ $order = $payment->getOrder();
114
+
115
+ /** @var Apruve_ApruvePayment_Model_Api_Rest_Order $orderApi */
116
+ $orderApi = Mage::getModel('apruvepayment/api_rest_order');
117
+
118
+
119
+ $updateResult = $orderApi->updateOrder($token, $order);
120
+ if (!$updateResult || !$updateResult['success']) {
121
+ Mage::throwException('Couldn\'t update order in Apruve.');
122
+ }
123
+
124
+ $payment->setTransactionId($updateResult['response']['id']);
125
+ $payment->setIsTransactionClosed(0);
126
+
127
+ return $this;
128
+ }
129
+
130
+ /**
131
+ * Captures a payment
132
+ *
133
+ * @param Varien_Object $payment
134
+ * @return bool
135
+ * @throws Mage_Core_Exception
136
+ */
137
+ public function capture(Varien_Object $payment, $amount)
138
+ {
139
+ parent::capture($payment, $amount);
140
+ Mage::helper('apruvepayment')->logException('Capture...');
141
+
142
+ if ($amount <= 0) {
143
+ Mage::throwException(Mage::helper('paygate')->__('Invalid amount for capture.'));
144
+ }
145
+
146
+ $payment->setSkipTransactionCreation(true);
147
+ return $this;
148
+ }
149
+
150
+
151
+ /**
152
+ * Create a refund
153
+ *
154
+ * @param Varien_Object $payment
155
+ * @return bool
156
+ * @throws Mage_Core_Exception
157
+ */
158
+ public function refund(Varien_Object $payment, $amount){
159
+ Mage::helper('apruvepayment')->logException('Refund...');
160
+
161
+ // Get Magento Order
162
+ $order = $payment->getOrder();
163
+ $magentoOrderId = $order->getIncrementId();
164
+ $apruveEntity = Mage::getModel('apruvepayment/entity')->loadByOrderId($magentoOrderId, 'magento_id');
165
+ $apruveOrderId = $apruveEntity->getApruveId();
166
+
167
+ $magentoInvoice = $this->_getInvoiceFromPayment($payment);
168
+
169
+ // Get API objects
170
+ $orderApi = Mage::getModel('apruvepayment/api_rest_order');
171
+ $invoiceApi = Mage::getModel('apruvepayment/api_rest_invoice');
172
+
173
+ // User Order to Get Apruve invoices
174
+ $apruveInvoices = $orderApi->getInvoices($apruveOrderId);
175
+
176
+ $validInvoice = null;
177
+ $totalAmountCents = 0;
178
+
179
+ foreach ($apruveInvoices as $invoice){
180
+ $totalAmountCents += $invoice['amount_cents'];
181
+ if ($invoice['merchant_invoice_id']== $magentoInvoice->getIncrementId()){
182
+ $validApruveInvoiceId = $invoice['id'];
183
+ }
184
+ }
185
+
186
+ Mage::helper('apruvepayment')->logException('$totalAmountCents: ' . $totalAmountCents);
187
+ Mage::helper('apruvepayment')->logException('$validInvoice: ' . $validInvoice);
188
+ if ($totalAmountCents >= ($amount * 100) && !empty($validApruveInvoiceId)){
189
+ $result = $invoiceApi->refundInvoice($validApruveInvoiceId, $amount);
190
+ } else {
191
+ Mage::throwException(Mage::helper('paygate')->__('Invalid data for online refund.'));
192
+ }
193
+
194
+ if ($result['success'] == false) {
195
+ Mage::throwException(Mage::helper('paygate')->__('Refund Failure Code:' . $result['code'] . ' - ' . $result['messsage']));
196
+ } else {
197
+ return $this;
198
+ }
199
+ }
200
+
201
+ /**
202
+ * Check void availability
203
+ *
204
+ * @param Varien_Object $payment
205
+ * @return bool
206
+ */
207
+ public function canVoid(Varien_Object $payment)
208
+ {
209
+ if ($payment instanceof Mage_Sales_Model_Order_Invoice
210
+ || $payment instanceof Mage_Sales_Model_Order_Creditmemo
211
+ ) {
212
+ return false;
213
+ }
214
+ if ($payment->getAmountPaid()) {
215
+ $this->_canVoid = false;
216
+ }
217
+
218
+ return true;
219
+ }
220
+
221
+ /**
222
+ * Attempt to void the authorization on cancelling
223
+ *
224
+ * @param Varien_Object $payment
225
+ * @return Apruve_ApruvePayment_Model_PaymentMethod | false
226
+ */
227
+ public function cancel(Varien_Object $payment)
228
+ {
229
+ Mage::helper('apruvepayment')->logException('Cancel...');
230
+
231
+ if (!$payment->getOrder()->getInvoiceCollection()->count()) {
232
+ return $this->void($payment);
233
+ }
234
+
235
+ return false;
236
+ }
237
+
238
+ /**
239
+ * Return invoice model from a payment
240
+ *
241
+ * @param Varien_Object $payment
242
+ * @return Mage_Sales_Model_Order_Invoice
243
+ */
244
+ protected function _getInvoiceFromPayment($payment)
245
+ {
246
+ $transactionId = $payment->getParentTransactionId();
247
+
248
+ foreach ($payment->getOrder()->getInvoiceCollection() as $invoice) {
249
+ if ($invoice->getTransactionId() == $transactionId) {
250
+ $invoice->load($invoice->getId()); // to make sure all data will properly load (maybe not required)
251
+ return $invoice;
252
+ }
253
+ }
254
+ foreach ($payment->getOrder()->getInvoiceCollection() as $invoice) {
255
+ if ($invoice->getState() == Mage_Sales_Model_Order_Invoice::STATE_OPEN
256
+ && $invoice->load($invoice->getId())
257
+ ) {
258
+ $invoice->setTransactionId($transactionId);
259
+ return $invoice;
260
+ }
261
+ }
262
+ return false;
263
+ }
264
  }
app/code/community/Apruve/ApruvePayment/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Apruve_ApruvePayment>
5
- <version>2.0.1</version>
6
  </Apruve_ApruvePayment>
7
  </modules>
8
  <global>
2
  <config>
3
  <modules>
4
  <Apruve_ApruvePayment>
5
+ <version>2.0.2</version>
6
  </Apruve_ApruvePayment>
7
  </modules>
8
  <global>
app/code/community/Apruve/ApruvePayment/etc/system.xml CHANGED
@@ -33,8 +33,8 @@
33
  <frontend_type>select</frontend_type>
34
  <source_model>apruvepayment/version</source_model>
35
  <sort_order>2</sort_order>
36
- <show_in_default>1</show_in_default>
37
- <show_in_website>1</show_in_website>
38
  <show_in_store>0</show_in_store>
39
  </version>
40
  <autosubmit translate="label">
@@ -52,8 +52,8 @@
52
  <frontend_type>select</frontend_type>
53
  <source_model>adminhtml/system_config_source_order_status_new</source_model>
54
  <sort_order>6</sort_order>
55
- <show_in_default>1</show_in_default>
56
- <show_in_website>1</show_in_website>
57
  <show_in_store>0</show_in_store>
58
  </order_status>
59
  <title translate="label">
33
  <frontend_type>select</frontend_type>
34
  <source_model>apruvepayment/version</source_model>
35
  <sort_order>2</sort_order>
36
+ <show_in_default>0</show_in_default>
37
+ <show_in_website>0</show_in_website>
38
  <show_in_store>0</show_in_store>
39
  </version>
40
  <autosubmit translate="label">
52
  <frontend_type>select</frontend_type>
53
  <source_model>adminhtml/system_config_source_order_status_new</source_model>
54
  <sort_order>6</sort_order>
55
+ <show_in_default>0</show_in_default>
56
+ <show_in_website>0</show_in_website>
57
  <show_in_store>0</show_in_store>
58
  </order_status>
59
  <title translate="label">
app/code/community/Apruve/ApruvePayment/sql/apruvepayment_setup/install-2.0.0.php CHANGED
@@ -7,58 +7,89 @@ $installer->startSetup();
7
  $connection = $installer->getConnection();
8
  $entity_table = $installer->getTable('apruvepayment/entity');
9
  if(!$connection->isTableExists($entity_table)) {
10
- $table = $connection->newTable($entity_table)
11
- ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
12
- 'identity' => true,
13
- 'unsigned' => true,
14
- 'nullable' => false,
15
- 'primary' => true
16
- ), 'ID')
17
- ->addColumn('magento_id', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
18
- 'nullable' => false
19
- ), 'Entity\'s ID in Magento')
20
- ->addColumn('apruve_id', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
21
- 'nullable' => false
22
- ), 'Entity\'s ID in Apruve')
23
- ->addColumn('apruve_item_id', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
24
- 'nullable' => false
25
- ), 'Entity Item ID in Apruve')
26
- ->addColumn('entity_type', Varien_Db_Ddl_Table::TYPE_TEXT, 10, array(
27
- 'nullable' => false
28
- ), 'Entity Type')
29
- ->addIndex(
30
- $installer->getIdxName(
31
- 'apruvepayment/entity',
32
- array(
33
- 'magento_id',
34
- 'apruve_id',
35
- 'entity_type'
36
- ),
37
- Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
38
- ),
39
- array(
40
- 'magento_id',
41
- 'apruve_id',
42
- 'entity_type'
43
- ),
44
- array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)
45
- )
46
- ->addIndex(
47
- $installer->getIdxName(
48
- 'apruvepayment/entity',
49
- array(
50
- 'magento_id',
51
- 'apruve_id',
52
- 'entity_type'
53
- )
54
- ),
55
- array(
56
- 'magento_id',
57
- 'apruve_id',
58
- 'entity_type'
59
- )
60
- );
61
- $installer->getConnection()->createTable($table);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  }
63
 
64
  $installer->endSetup();
7
  $connection = $installer->getConnection();
8
  $entity_table = $installer->getTable('apruvepayment/entity');
9
  if(!$connection->isTableExists($entity_table)) {
10
+ $table = $connection->newTable($entity_table)
11
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
12
+ 'identity' => true,
13
+ 'unsigned' => true,
14
+ 'nullable' => false,
15
+ 'primary' => true
16
+ ), 'ID')
17
+ ->addColumn('magento_id', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
18
+ 'nullable' => false
19
+ ), 'Entity\'s ID in Magento')
20
+ ->addColumn('apruve_id', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
21
+ 'nullable' => false
22
+ ), 'Entity\'s ID in Apruve')
23
+ ->addColumn('apruve_item_id', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
24
+ 'nullable' => false
25
+ ), 'Entity Item ID in Apruve')
26
+ ->addColumn('entity_type', Varien_Db_Ddl_Table::TYPE_TEXT, 10, array(
27
+ 'nullable' => false
28
+ ), 'Entity Type')
29
+ ->addIndex(
30
+ $installer->getIdxName(
31
+ 'apruvepayment/entity',
32
+ array(
33
+ 'magento_id',
34
+ 'apruve_id',
35
+ 'entity_type'
36
+ ),
37
+ Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
38
+ ),
39
+ array(
40
+ 'magento_id',
41
+ 'apruve_id',
42
+ 'entity_type'
43
+ ),
44
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)
45
+ )
46
+ ->addIndex(
47
+ $installer->getIdxName(
48
+ 'apruvepayment/entity',
49
+ array(
50
+ 'magento_id',
51
+ 'apruve_id',
52
+ 'entity_type'
53
+ )
54
+ ),
55
+ array(
56
+ 'magento_id',
57
+ 'apruve_id',
58
+ 'entity_type'
59
+ )
60
+ );
61
+ $installer->getConnection()->createTable($table);
62
+
63
+ $statusTable = $installer->getTable('sales/order_status');
64
+ $statusStateTable = $installer->getTable('sales/order_status_state');
65
+
66
+ // Insert statuses
67
+
68
+ $installer->getConnection()->insertArray($statusTable, array(
69
+ 'status',
70
+ 'label'
71
+ ) , array(
72
+ array(
73
+ 'status' => 'buyer_approved',
74
+ 'label' => 'Buyer Approved'
75
+ )
76
+ ));
77
+
78
+ // Insert states and mapping of statuses to states
79
+
80
+ $installer->getConnection()->insertArray($statusStateTable, array(
81
+ 'status',
82
+ 'state',
83
+ 'is_default'
84
+ ) , array(
85
+ array(
86
+ 'status' => 'buyer_approved',
87
+ 'state' => 'buyer_approved',
88
+ 'is_default' => 1
89
+ )
90
+ ));
91
+
92
+
93
  }
94
 
95
  $installer->endSetup();
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Apruve_B2B_Payment_Gateway</name>
4
- <version>2.0.1</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>2017-03-10</date>
14
- <time>07:41:55</time>
15
- <contents><target name="magecommunity"><dir name="Apruve"><dir name="ApruvePayment"><dir name="Block"><dir name="Admin"><file name="Webhook.php" hash="5a4eb68f48306322a973f1f837f53ac8"/></dir><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="View.php" hash="517c950361e27545c3ff841cd7bccae4"/></dir></dir></dir><dir name="Payment"><file name="Form.php" hash="c84481487b8a831fc382d90c76eeb962"/></dir></dir><dir name="Helper"><file name="Data.php" hash="c6d29ea8c507e36eae18d1a3491cb7f1"/></dir><file name="LICENSE.txt" hash="9b76dd4b62de4f9840b5d462fcb25e39"/><dir name="Model"><dir name="Api"><file name="Abstract.php" hash="799c80a34d98fa19248720364fdcb733"/><file name="Payment.php" hash="cdc85003d73cf6b9de6f82e0c163b320"/><dir name="Rest"><file name="Account.php" hash="3ffe86022f08f9969fab56d0e12850db"/><file name="Invoice.php" hash="7b2f037c9c30218cc379eb551c6f27cf"/><file name="Order.php" hash="4b8ce16292d3ea593313ae4fb30a07cb"/><file name="Shipment.php" hash="fb8150febd9643cfb4fe3dd23d0c5be6"/></dir><file name="Rest.php" hash="c1071949a8dc1229d85cebae150985b7"/></dir><file name="Entity.php" hash="6652836c17449c86c8a599ea63079258"/><file name="Mode.php" hash="95e5f17903661df50f3dea2849adc1bb"/><file name="Observer.php" hash="7c162dfa058e307b9b299d4ed7581f60"/><file name="PaymentMethod.php" hash="6fc52aaad006d142162c690822925d5f"/><dir name="Resource"><dir name="Entity"><file name="Collection.php" hash="7a8f8115e87d6deaf6d05501e8160863"/></dir><file name="Entity.php" hash="9a2298e1c979f7ce998f867a81728013"/></dir><dir name="Sales"><dir name="Service"><file name="Order.php" hash="807c36c87883a4f01f4f8f7d86b44415"/></dir></dir><file name="Version.php" hash="5d76f8613344d1dfc278add7c2fa3ebf"/></dir><dir name="controllers"><file name="WebhookController.php" hash="fbaf0657861c73d2bbb7d1c372b960d4"/></dir><dir name="etc"><file name="config.xml" hash="ced9a00271a91454ebf6a25c79c8c2d6"/><file name="system.xml" hash="5762459db1687ed91c2d855591227c7f"/></dir><dir name="sql"><dir name="apruvepayment_setup"><file name="install-2.0.0.php" hash="eb0b5b2ab790d8710a00a817c52ef2b1"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="apruvepayment.xml" hash="6ade24fa77f4f55ce0bdf4f5c79fd65c"/></dir><dir name="template"><dir name="apruvepayment"><file name="head.phtml" hash="36809c6a8fa5aad587b03e2107482bdf"/><dir name="payment"><file name="form.phtml" hash="d0bff443c44e35201ced6abffdf7ec8f"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Apruve_ApruvePayment.xml" hash="8e20101d5c688c8505302df6d73686fb"/></dir></target><target name="mage"><dir name="js"><dir name="Apruve"><file name="ApruvePayment.js" hash="a9fab0a38c6bc2923106e9925462ef3e"/></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>2.0.2</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>2017-06-09</date>
14
+ <time>09:01:55</time>
15
+ <contents><target name="magecommunity"><dir name="Apruve"><dir name="ApruvePayment"><dir name="Block"><dir name="Admin"><file name="Webhook.php" hash="5a4eb68f48306322a973f1f837f53ac8"/></dir><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="View.php" hash="517c950361e27545c3ff841cd7bccae4"/></dir></dir></dir><dir name="Payment"><file name="Form.php" hash="c84481487b8a831fc382d90c76eeb962"/></dir></dir><dir name="Helper"><file name="Data.php" hash="c6d29ea8c507e36eae18d1a3491cb7f1"/></dir><file name="LICENSE.txt" hash="9b76dd4b62de4f9840b5d462fcb25e39"/><dir name="Model"><dir name="Api"><file name="Abstract.php" hash="799c80a34d98fa19248720364fdcb733"/><file name="Payment.php" hash="cdc85003d73cf6b9de6f82e0c163b320"/><dir name="Rest"><file name="Account.php" hash="3ffe86022f08f9969fab56d0e12850db"/><file name="Invoice.php" hash="df001eafbe650a13b6a21abae6c1ac0e"/><file name="Order.php" hash="23ceb8e4fdb9af5ac6e0f7304faa66e8"/><file name="Shipment.php" hash="fb8150febd9643cfb4fe3dd23d0c5be6"/></dir><file name="Rest.php" hash="c1071949a8dc1229d85cebae150985b7"/></dir><file name="Entity.php" hash="6652836c17449c86c8a599ea63079258"/><file name="Mode.php" hash="95e5f17903661df50f3dea2849adc1bb"/><file name="Observer.php" hash="7c162dfa058e307b9b299d4ed7581f60"/><file name="PaymentMethod.php" hash="ff1f95015d46506ab4dda841c920118f"/><dir name="Resource"><dir name="Entity"><file name="Collection.php" hash="7a8f8115e87d6deaf6d05501e8160863"/></dir><file name="Entity.php" hash="9a2298e1c979f7ce998f867a81728013"/></dir><dir name="Sales"><dir name="Service"><file name="Order.php" hash="807c36c87883a4f01f4f8f7d86b44415"/></dir></dir><file name="Version.php" hash="5d76f8613344d1dfc278add7c2fa3ebf"/></dir><dir name="controllers"><file name="WebhookController.php" hash="fbaf0657861c73d2bbb7d1c372b960d4"/></dir><dir name="etc"><file name="config.xml" hash="b87eae3dc65a7954343d254b1105399a"/><file name="system.xml" hash="5aa4e596a126f90708ed1443868e4d37"/></dir><dir name="sql"><dir name="apruvepayment_setup"><file name="install-2.0.0.php" hash="49ab896d2d4224d5a6e47f660fb853b0"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="apruvepayment.xml" hash="6ade24fa77f4f55ce0bdf4f5c79fd65c"/></dir><dir name="template"><dir name="apruvepayment"><file name="head.phtml" hash="36809c6a8fa5aad587b03e2107482bdf"/><dir name="payment"><file name="form.phtml" hash="d0bff443c44e35201ced6abffdf7ec8f"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Apruve_ApruvePayment.xml" hash="8e20101d5c688c8505302df6d73686fb"/></dir></target><target name="mage"><dir name="js"><dir name="Apruve"><file name="ApruvePayment.js" hash="a9fab0a38c6bc2923106e9925462ef3e"/></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>