Skip to content

Commit f4b8367

Browse files
Merge pull request #61 from xendit/TPI-2020/dana
Add DANA payment method
2 parents ce2f330 + 4397042 commit f4b8367

33 files changed

+363
-50
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# CHANGELOG
22

3+
## 2.4.0 (2020-11-02)
4+
5+
Features:
6+
7+
- Add DANA payment method
8+
- Add Indomaret payment method
9+
310
## 2.3.0 (2020-10-06)
411

512
Features:

Xendit/M2Invoice/Controller/Checkout/Invoice.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ private function getApiRequestData($order)
6868
'preferred_method' => $preferredMethod,
6969
'should_send_email' => $this->getDataHelper()->getSendInvoiceEmail() ? "true" : "false",
7070
'platform_callback_url' => $this->getXenditCallbackUrl(),
71-
'client_type' => 'INTEGRATION'
71+
'client_type' => 'INTEGRATION',
72+
'payment_methods' => json_encode([strtoupper($preferredMethod)])
7273
];
7374

7475
return $requestData;

Xendit/M2Invoice/Controller/Checkout/InvoiceMultishipping.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public function execute()
5656
'preferred_method' => $preferredMethod,
5757
'should_send_email' => $this->getDataHelper()->getSendInvoiceEmail() ? "true" : "false",
5858
'platform_callback_url' => $this->getXenditCallbackUrl(),
59-
'client_type' => 'INTEGRATION'
59+
'client_type' => 'INTEGRATION',
60+
'payment_methods' => json_encode([strtoupper($preferredMethod)])
6061
];
6162

6263
$invoice = $this->createInvoice($requestData);

Xendit/M2Invoice/Controller/Checkout/Notification.m22.php

+5-10
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function handleInvoiceCallback($callbackPayload) {
112112

113113
$invoice = $this->getXenditInvoice($transactionId);
114114

115-
if( $isMultishipping ) {
115+
if ($isMultishipping) {
116116
foreach ($orderIds as $key => $value) {
117117
$order = $this->orderFactory->create();
118118
$order->load($value);
@@ -237,13 +237,12 @@ private function checkOrder($order, $isEwallet, $callbackPayload, $invoice, $cal
237237
$this->getCheckoutHelper()->restoreQuote(); //restore cart
238238
}
239239

240-
if ($isEwallet) {
241-
$order ->setState($orderState)
242-
->setStatus($orderState);
243-
$order ->save();
240+
$order ->addStatusHistoryComment("Xendit payment " . strtolower($paymentStatus) . ". Transaction ID: $transactionId")
241+
->save();
244242

243+
if ($isEwallet) {
245244
$payment = $order->getPayment();
246-
$payment->setAdditionalInformation('xendit_ewallet_failure_code', $failureCode);
245+
$payment->setAdditionalInformation('xendit_ewallet_failure_code', $callbackPayload['failure_code']);
247246
$payment->save();
248247
}
249248

@@ -286,10 +285,6 @@ private function getEwalletStatus($ewalletType, $externalId)
286285
);
287286
}
288287

289-
if ($ewalletType == 'DANA') {
290-
$response['status'] = $response['payment_status'];
291-
}
292-
293288
$statusList = array("COMPLETED", "PAID", "SUCCESS_COMPLETED"); //OVO, DANA, LINKAJA
294289
if (in_array($response['status'], $statusList)) {
295290
return "COMPLETED";

Xendit/M2Invoice/Controller/Checkout/Notification.m23.php

+5-10
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function handleInvoiceCallback($callbackPayload) {
123123

124124
$invoice = $this->getXenditInvoice($transactionId);
125125

126-
if( $isMultishipping ) {
126+
if ($isMultishipping) {
127127
foreach ($orderIds as $key => $value) {
128128
$order = $this->orderFactory->create();
129129
$order->load($value);
@@ -248,13 +248,12 @@ private function checkOrder($order, $isEwallet, $callbackPayload, $invoice, $cal
248248
$this->getCheckoutHelper()->restoreQuote(); //restore cart
249249
}
250250

251+
$order ->addStatusHistoryComment("Xendit payment " . strtolower($paymentStatus) . ". Transaction ID: $transactionId")
252+
->save();
253+
251254
if ($isEwallet) {
252-
$order ->setState($orderState)
253-
->setStatus($orderState);
254-
$order ->save();
255-
256255
$payment = $order->getPayment();
257-
$payment->setAdditionalInformation('xendit_ewallet_failure_code', $failureCode);
256+
$payment->setAdditionalInformation('xendit_ewallet_failure_code', $callbackPayload['failure_code']);
258257
$payment->save();
259258
}
260259

@@ -297,10 +296,6 @@ private function getEwalletStatus($ewalletType, $externalId)
297296
);
298297
}
299298

300-
if ($ewalletType == 'DANA') {
301-
$response['status'] = $response['payment_status'];
302-
}
303-
304299
$statusList = array("COMPLETED", "PAID", "SUCCESS_COMPLETED"); //OVO, DANA, LINKAJA
305300
if (in_array($response['status'], $statusList)) {
306301
return "COMPLETED";

Xendit/M2Invoice/Controller/Checkout/Redirect.php

-4
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,6 @@ private function getEwalletStatus($ewalletType, $externalId)
136136
);
137137
}
138138

139-
if ($ewalletType == 'DANA') {
140-
$response['status'] = $response['payment_status'];
141-
}
142-
143139
$statusList = array("COMPLETED", "PAID", "SUCCESS_COMPLETED"); //OVO, DANA, LINKAJA
144140
if (in_array($response['status'], $statusList)) {
145141
return "COMPLETED";

Xendit/M2Invoice/Helper/ApiRequest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private function getHeaders($isPublicRequest, $preferredMethod = null, $customHe
8585
'Content-Type' => 'application/json',
8686
'x-plugin-name' => 'MAGENTO2',
8787
'user-agent' => 'Magento 2 Module',
88-
'x-plugin-version' => '2.3.0'
88+
'x-plugin-version' => '2.4.0'
8989
];
9090

9191
if ($preferredMethod !== null) {

Xendit/M2Invoice/Helper/Data.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,9 @@ public function xenditPaymentMethod( $payment ){
283283
"mandiriva" => "mandiri",
284284
"permatava" => "permata",
285285
"alfamart" => "alfamart",
286-
"ovo" => "ovo"
286+
"ovo" => "ovo",
287+
"dana" => "dana",
288+
"indomaret" => "indomaret"
287289
];
288290

289291
$response = FALSE;

Xendit/M2Invoice/Model/Adminhtml/Source/ChosenMethod.php

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public function toOptionArray($isMultiselect = false)
2828
['value' => 'cc', 'label' => __('Credit Card')],
2929
['value' => 'cc_installment', 'label' => __('Credit Card Installment')],
3030
['value' => 'cc_subscription', 'label' => __('Credit Card Subscription')],
31+
['value' => 'dana', 'label' => __('DANA')],
32+
['value' => 'indomaret', 'label' => __('Indomaret')],
3133
['value' => 'ovo', 'label' => __('OVO')],
3234
];
3335

Xendit/M2Invoice/Model/Payment/AbstractInvoice.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
123123
return true;
124124
}
125125
//uncomment this block for local testing
126-
/*if($this->methodCode == 'OVO'){
126+
/*if($this->methodCode == 'OVO' || $this->methodCode == 'DANA'){
127127
return true;
128128
}*/
129129

130-
if ( !in_array( strtoupper($this->methodCode), $availableMethod ) ) {
130+
if (!in_array(strtoupper($this->methodCode), $availableMethod)) {
131131
return false;
132132
}
133133

@@ -156,7 +156,7 @@ private function getAvailableMethods()
156156
throw $e;
157157
}
158158

159-
if ( !isset($response['available_method']) ) {
159+
if (!isset($response['available_method'])) {
160160
return [];
161161
}
162162

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Xendit\M2Invoice\Model\Payment;
4+
5+
class DANA extends AbstractInvoice
6+
{
7+
/**
8+
* Payment code
9+
*
10+
* @var string
11+
*/
12+
protected $_code = 'dana';
13+
protected $_minAmount = 10000;
14+
protected $_maxAmount = 10000000;
15+
protected $methodCode = 'DANA';
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Xendit\M2Invoice\Model\Payment;
4+
5+
class Indomaret extends AbstractInvoice
6+
{
7+
/**
8+
* Payment code
9+
*
10+
* @var string
11+
*/
12+
protected $_code = 'indomaret';
13+
protected $_minAmount = 10000;
14+
protected $_maxAmount = 2500000;
15+
protected $methodCode = 'Indomaret';
16+
}

Xendit/M2Invoice/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "xendit/m2invoice",
33
"description": "Xendit Payment Gateway Module",
44
"type": "magento2-module",
5-
"version": "2.3.0",
5+
"version": "2.4.0",
66
"license": [
77
"GPL-3.0"
88
],

Xendit/M2Invoice/etc/adminhtml/system.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
function shouldDisplayAdditionalKYCWarningMethod() {
6565
var currentValue = specificSelection.val();
6666
67-
if (currentValue.includes('ovo') || currentValue.includes('alfamart') || currentValue.includes('bcava')) {
67+
if (currentValue.includes('ovo') || currentValue.includes('alfamart') || currentValue.includes('bcava') || currentValue.includes('dana')) {
6868
displayAdditionalKYCWarning(true);
6969
} else {
7070
displayAdditionalKYCWarning(false);

Xendit/M2Invoice/etc/config.xml

+21-1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,26 @@
119119
<cctypes>VI,MC,AE,JCB</cctypes>
120120
<sort_order>10</sort_order>
121121
</cc_subscription>
122+
<dana>
123+
<active>1</active>
124+
<payment_action>initialize</payment_action>
125+
<model>Xendit\M2Invoice\Model\Payment\DANA</model>
126+
<title>DANA</title>
127+
<is_gateway>1</is_gateway>
128+
<can_initialize>1</can_initialize>
129+
<can_use_checkout>1</can_use_checkout>
130+
<sort_order>11</sort_order>
131+
</dana>
132+
<indomaret>
133+
<active>1</active>
134+
<payment_action>initialize</payment_action>
135+
<model>Xendit\M2Invoice\Model\Payment\Indomaret</model>
136+
<title>Indomaret</title>
137+
<is_gateway>1</is_gateway>
138+
<can_initialize>1</can_initialize>
139+
<can_use_checkout>1</can_use_checkout>
140+
<sort_order>12</sort_order>
141+
</indomaret>
122142
<ovo>
123143
<active>1</active>
124144
<payment_action>authorize</payment_action>
@@ -127,7 +147,7 @@
127147
<is_gateway>1</is_gateway>
128148
<can_initialize>1</can_initialize>
129149
<can_use_checkout>1</can_use_checkout>
130-
<sort_order>11</sort_order>
150+
<sort_order>13</sort_order>
131151
</ovo>
132152
</payment>
133153
</default>

Xendit/M2Invoice/etc/module.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3-
<module name="Xendit_M2Invoice" setup_version="2.3.0" active="true"></module>
3+
<module name="Xendit_M2Invoice" setup_version="2.4.0" active="true"></module>
44
</config>

Xendit/M2Invoice/etc/payment.xml

+6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ https://github.com/magento/magento2/blob/2.2.0-rc2.1/app/code/Magento/Multishipp
3939
<method name='cc_subscription'>
4040
<allow_multiple_address>1</allow_multiple_address>
4141
</method>
42+
<method name='dana'>
43+
<allow_multiple_address>1</allow_multiple_address>
44+
</method>
45+
<method name='indomaret'>
46+
<allow_multiple_address>1</allow_multiple_address>
47+
</method>
4248
<method name='ovo'>
4349
<allow_multiple_address>1</allow_multiple_address>
4450
</method>

Xendit/M2Invoice/view/frontend/layout/multishipping_checkout_billing.xml

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
<item name="mandiriva" xsi:type="string">Xendit_M2Invoice::multishipping/mandiriva.phtml</item>
2323
<item name="permatava" xsi:type="string">Xendit_M2Invoice::multishipping/permatava.phtml</item>
2424
<item name="ovo" xsi:type="string">Xendit_M2Invoice::multishipping/ovo.phtml</item>
25+
<item name="dana" xsi:type="string">Xendit_M2Invoice::multishipping/dana.phtml</item>
26+
<item name="indomaret" xsi:type="string">Xendit_M2Invoice::multishipping/indomaret.phtml</item>
2527
</argument>
2628
</arguments>
2729
</referenceBlock>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
?>
7+
<script>
8+
require([
9+
'uiLayout',
10+
'jquery'
11+
], function (layout, $) {
12+
$(function () {
13+
var paymentMethodData = {
14+
method: 'dana'
15+
};
16+
layout([
17+
{
18+
component: 'Xendit_M2Invoice/js/view/payment/method-renderer/multishipping/dana',
19+
name: 'payment_method_dana',
20+
method: paymentMethodData.method,
21+
item: paymentMethodData
22+
}
23+
]);
24+
25+
$('body').trigger('contentUpdated');
26+
})
27+
})
28+
</script>
29+
<!-- ko template: getTemplate() --><!-- /ko -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
?>
7+
<script>
8+
require([
9+
'uiLayout',
10+
'jquery'
11+
], function (layout, $) {
12+
$(function () {
13+
var paymentMethodData = {
14+
method: 'indomaret'
15+
};
16+
layout([
17+
{
18+
component: 'Xendit_M2Invoice/js/view/payment/method-renderer/multishipping/indomaret',
19+
name: 'payment_method_indomaret',
20+
method: paymentMethodData.method,
21+
item: paymentMethodData
22+
}
23+
]);
24+
25+
$('body').trigger('contentUpdated');
26+
})
27+
})
28+
</script>
29+
<!-- ko template: getTemplate() --><!-- /ko -->

Xendit/M2Invoice/view/frontend/web/js/view/payment/method-renderer.js

+8
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ define(
3838
type: 'ovo',
3939
component: 'Xendit_M2Invoice/js/view/payment/method-renderer/ovo'
4040
},
41+
{
42+
type: 'dana',
43+
component: 'Xendit_M2Invoice/js/view/payment/method-renderer/dana'
44+
},
45+
{
46+
type: 'indomaret',
47+
component: 'Xendit_M2Invoice/js/view/payment/method-renderer/indomaret'
48+
},
4149
{
4250
type: 'cc',
4351
component: 'Xendit_M2Invoice/js/view/payment/method-renderer/cc'

Xendit/M2Invoice/view/frontend/web/js/view/payment/method-renderer/alfamart.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ define(
6969
}
7070

7171
if (totals.grand_total < 10000) {
72-
self.messageContainer.addErrorMessage({'message': 'Xendit doesn\'t support purchases less than Rp 11.000.'});
72+
self.messageContainer.addErrorMessage({'message': 'Xendit doesn\'t support purchases less than Rp 10,000.'});
7373
return false;
7474
}
7575

Xendit/M2Invoice/view/frontend/web/js/view/payment/method-renderer/bcava.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ define(
6969
}
7070

7171
if (totals.grand_total < 10000) {
72-
self.messageContainer.addErrorMessage({'message': 'Xendit doesn\'t support purchases less than Rp 11.000.'});
72+
self.messageContainer.addErrorMessage({'message': 'Xendit doesn\'t support purchases less than Rp 10,000.'});
7373
return false;
7474
}
7575

Xendit/M2Invoice/view/frontend/web/js/view/payment/method-renderer/bniva.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ define(
6969
}
7070

7171
if (totals.grand_total < 10000) {
72-
self.messageContainer.addErrorMessage({'message': 'Xendit doesn\'t support purchases less than Rp 11.000.'});
72+
self.messageContainer.addErrorMessage({'message': 'Xendit doesn\'t support purchases less than Rp 10,000.'});
7373
return false;
7474
}
7575

Xendit/M2Invoice/view/frontend/web/js/view/payment/method-renderer/briva.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ define(
6969
}
7070

7171
if (totals.grand_total < 10000) {
72-
self.messageContainer.addErrorMessage({'message': 'Xendit doesn\'t support purchases less than Rp 11.000.'});
72+
self.messageContainer.addErrorMessage({'message': 'Xendit doesn\'t support purchases less than Rp 10,000.'});
7373
return false;
7474
}
7575

0 commit comments

Comments
 (0)