File tree 21 files changed +255
-32
lines changed
21 files changed +255
-32
lines changed Original file line number Diff line number Diff line change 1
1
# CHANGELOG
2
2
3
+ ## 10.0.0 (2022-01-10)
4
+ Features:
5
+ - Add new IDR payment: BSS VA
6
+
3
7
## 9.0.1 (2022-12-16)
4
8
Features:
5
9
- Implement Xendit metric
Original file line number Diff line number Diff line change @@ -512,18 +512,9 @@ protected function orderValidToCreateXenditInvoice(Order $order): bool
512
512
protected function getPreferredMethod (Order $ order )
513
513
{
514
514
$ payment = $ order ->getPayment ();
515
- $ preferredMethod = $ this ->getDataHelper ()->xenditPaymentMethod (
515
+ return $ this ->getDataHelper ()->xenditPaymentMethod (
516
516
$ payment ->getMethod ()
517
517
);
518
-
519
- switch ($ preferredMethod ) {
520
- case 'cc ' :
521
- return 'CREDIT_CARD ' ;
522
- case 'shopeepayph ' :
523
- return 'SHOPEEPAY ' ;
524
- default :
525
- return $ preferredMethod ;
526
- }
527
518
}
528
519
529
520
/**
Original file line number Diff line number Diff line change @@ -40,9 +40,7 @@ public function execute()
40
40
$ this ->_redirect ('checkout/cart ' );
41
41
}
42
42
} catch (\Throwable $ e ) {
43
- $ message = 'Exception caught on xendit/checkout/invoice: ' . $ e ->getMessage ();
44
-
45
- $ this ->getLogger ()->debug ('Exception caught on xendit/checkout/invoice: ' . $ message );
43
+ $ this ->getLogger ()->debug ('Exception caught on xendit/checkout/invoice: ' . $ e ->getMessage ());
46
44
$ this ->getLogger ()->debug ($ e ->getTraceAsString ());
47
45
48
46
$ this ->cancelOrder ($ order , $ e ->getMessage ());
@@ -57,7 +55,7 @@ public function execute()
57
55
]
58
56
);
59
57
60
- return $ this ->redirectToCart ($ message );
58
+ return $ this ->redirectToCart ($ e -> getMessage () );
61
59
}
62
60
}
63
61
@@ -140,7 +138,10 @@ private function createInvoice($requestData)
140
138
);
141
139
}
142
140
if (isset ($ invoice ['error_code ' ])) {
143
- $ message = $ this ->getErrorHandler ()->mapInvoiceErrorCode ($ invoice ['error_code ' ]);
141
+ $ message = $ this ->getErrorHandler ()->mapInvoiceErrorCode (
142
+ $ invoice ['error_code ' ],
143
+ str_replace ('{{currency}} ' , $ requestData ['currency ' ], $ invoice ['message ' ] ?? '' )
144
+ );
144
145
throw new LocalizedException (
145
146
new Phrase ($ message )
146
147
);
Original file line number Diff line number Diff line change @@ -115,7 +115,10 @@ public function execute()
115
115
$ invoice = $ this ->createInvoice ($ requestData );
116
116
117
117
if (!empty ($ invoice ) && isset ($ invoice ['error_code ' ])) {
118
- $ message = $ this ->getErrorHandler ()->mapInvoiceErrorCode ($ invoice ['error_code ' ]);
118
+ $ message = $ this ->getErrorHandler ()->mapInvoiceErrorCode (
119
+ $ invoice ['error_code ' ],
120
+ str_replace ('{{currency}} ' , $ currency , $ invoice ['message ' ] ?? '' )
121
+ );
119
122
// cancel order and redirect to cart
120
123
return $ this ->processFailedPayment ($ orderIds , $ message );
121
124
}
@@ -127,8 +130,7 @@ public function execute()
127
130
$ resultRedirect ->setUrl ($ redirectUrl );
128
131
return $ resultRedirect ;
129
132
} catch (\Throwable $ e ) {
130
- $ message = 'Exception caught on xendit/checkout/redirect: ' . $ e ->getMessage ();
131
- $ this ->getLogger ()->info ($ message );
133
+ $ this ->getLogger ()->info ('Exception caught on xendit/checkout/redirect: ' . $ e ->getMessage ());
132
134
133
135
// log metric error
134
136
$ this ->metricHelper ->sendMetric (
@@ -140,7 +142,7 @@ public function execute()
140
142
]
141
143
);
142
144
143
- return $ this ->redirectToCart ($ message );
145
+ return $ this ->redirectToCart ($ e -> getMessage () );
144
146
}
145
147
}
146
148
Original file line number Diff line number Diff line change 30
30
*/
31
31
class Data extends AbstractHelper
32
32
{
33
- const XENDIT_M2INVOICE_VERSION = '9 .0.1 ' ;
33
+ const XENDIT_M2INVOICE_VERSION = '10 .0.0 ' ;
34
34
35
35
/**
36
36
* @var StoreManagerInterface
@@ -399,12 +399,13 @@ public function mapSalesRuleType($type)
399
399
public function getXenditPaymentList (): array
400
400
{
401
401
return [
402
- "cc " => "cc " ,
402
+ "cc " => "credit_card " ,
403
403
"bcava " => "bca " ,
404
404
"bniva " => "bni " ,
405
405
"bjbva " => "bjb " ,
406
406
"briva " => "bri " ,
407
407
"bsiva " => "bsi " ,
408
+ "bssva " => "sahabat_sampoerna " ,
408
409
"mandiriva " => "mandiri " ,
409
410
"permatava " => "permata " ,
410
411
"alfamart " => "alfamart " ,
@@ -429,7 +430,7 @@ public function getXenditPaymentList(): array
429
430
"dp_ecpay_loan " => "dp_ecpay_loan " ,
430
431
"dp_ecpay_school " => "dp_ecpay_school " ,
431
432
"cashalo " => "cashalo " ,
432
- "shopeepayph " => "shopeepayph " ,
433
+ "shopeepayph " => "shopeepay " ,
433
434
"uangme " => "uangme " ,
434
435
"astrapay " => "astrapay " ,
435
436
"akulaku " => "akulaku " ,
Original file line number Diff line number Diff line change @@ -10,13 +10,18 @@ class ErrorHandler
10
10
{
11
11
/**
12
12
* @param $errorCode
13
- * @return string
13
+ * @param string $message
14
+ * @return array|string|string[]
14
15
*/
15
- public function mapInvoiceErrorCode ($ errorCode )
16
- {
16
+ public function mapInvoiceErrorCode (
17
+ $ errorCode ,
18
+ string $ message = ''
19
+ ) {
20
+ $ defaultMessage = "Failed to pay with Invoice. Error code: $ errorCode " ;
17
21
switch ($ errorCode ) {
22
+ case 'UNSUPPORTED_CURRENCY ' :
18
23
case 'API_VALIDATION_ERROR ' :
19
- return ' Inputs are failing validation. The errors field contains details about which fields are violating validation. ' ;
24
+ return ! empty ( $ message ) ? $ message : $ defaultMessage ;
20
25
case 'INVALID_JSON_FORMAT ' :
21
26
return 'The request body is not a valid JSON format. ' ;
22
27
case 'MINIMAL_TRANSFER_AMOUNT_ERROR ' :
@@ -40,7 +45,7 @@ public function mapInvoiceErrorCode($errorCode)
40
45
case 'MERCHANT_NOT_FOUND ' :
41
46
return 'You are not registered yet to use this payment method. ' ;
42
47
default :
43
- return " Failed to pay with Invoice. Error code: $ errorCode " ;
48
+ return $ defaultMessage ;
44
49
}
45
50
}
46
51
}
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ public function toOptionArray($isMultiselect = false)
26
26
['value ' => 'bniva ' , 'label ' => __ ('Bank Transfer BNI ' )],
27
27
['value ' => 'briva ' , 'label ' => __ ('Bank Transfer BRI ' )],
28
28
['value ' => 'bsiva ' , 'label ' => __ ('Bank Transfer BSI ' )],
29
+ ['value ' => 'bssva ' , 'label ' => __ ('Bank Transfer BSS ' )],
29
30
['value ' => 'mandiriva ' , 'label ' => __ ('Bank Transfer Mandiri ' )],
30
31
['value ' => 'permatava ' , 'label ' => __ ('Bank Transfer Permata ' )],
31
32
['value ' => 'cc ' , 'label ' => __ ('Credit Card ' )],
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Xendit \M2Invoice \Model \Payment ;
4
+
5
+ use Magento \Quote \Api \Data \CartInterface ;
6
+
7
+ /**
8
+ * Class BSSVA
9
+ * @package Xendit\M2Invoice\Model\Payment
10
+ */
11
+ class BSSVA extends AbstractInvoice
12
+ {
13
+ /**
14
+ * Payment Method feature
15
+ *
16
+ * @var bool
17
+ */
18
+ protected $ _isInitializeNeeded = true ;
19
+
20
+ /**
21
+ * Payment code
22
+ *
23
+ * @var string
24
+ */
25
+ protected $ _code = 'bssva ' ;
26
+ protected $ methodCode = 'BSS ' ;
27
+ }
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ public function __construct(
59
59
*/
60
60
public function getConfig ()
61
61
{
62
- $ config = [
62
+ return [
63
63
'payment ' => [
64
64
Config::CODE => [
65
65
'xendit_env ' => $ this ->xendit ->getConfigData ('xendit_env ' ),
@@ -332,9 +332,14 @@ public function getConfig()
332
332
'description ' => $ this ->xenditHelper ->getPaymentDescription ("lbc " ),
333
333
'image ' => $ this ->xenditHelper ->getPaymentImage ('lbc ' )
334
334
],
335
+ 'bssva ' => [
336
+ 'title ' => $ this ->xenditHelper ->getPaymentTitle ("bssva " ),
337
+ 'min_order_amount ' => $ this ->xenditHelper ->getPaymentMinOrderAmount ("bssva " ),
338
+ 'max_order_amount ' => $ this ->xenditHelper ->getPaymentMaxOrderAmount ("bssva " ),
339
+ 'description ' => $ this ->xenditHelper ->getPaymentDescription ("bssva " ),
340
+ 'image ' => $ this ->xenditHelper ->getPaymentImage ('bssva ' )
341
+ ],
335
342
]
336
343
];
337
-
338
- return $ config ;
339
344
}
340
345
}
Original file line number Diff line number Diff line change 2
2
"name" : " xendit/m2invoice" ,
3
3
"description" : " Xendit Payment Gateway Module" ,
4
4
"type" : " magento2-module" ,
5
- "version" : " 9 .0.1 " ,
5
+ "version" : " 10 .0.0 " ,
6
6
"license" : [
7
7
" GPL-3.0"
8
8
],
Original file line number Diff line number Diff line change 165
165
<include path =" Xendit_M2Invoice::virtual_account/bniva.xml" />
166
166
<include path =" Xendit_M2Invoice::virtual_account/briva.xml" />
167
167
<include path =" Xendit_M2Invoice::virtual_account/bsiva.xml" />
168
+ <include path =" Xendit_M2Invoice::virtual_account/bssva.xml" />
168
169
<include path =" Xendit_M2Invoice::virtual_account/mandiriva.xml" />
169
170
<include path =" Xendit_M2Invoice::virtual_account/permatava.xml" />
170
171
</group >
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" ?>
2
+ <include xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : noNamespaceSchemaLocation =" urn:magento:module:Magento_Config:etc/system_include.xsd" >
3
+ <group id =" bssva" translate =" label" type =" text" sortOrder =" 150" showInDefault =" 1" showInWebsite =" 1" showInStore =" 1" >
4
+ <label >BSS</label >
5
+ <field id =" active" translate =" label comment" sortOrder =" 1" type =" select" showInDefault =" 1" showInWebsite =" 1" showInStore =" 1" canRestore =" 1" >
6
+ <label >Enable</label >
7
+ <source_model >Magento\Config\Model\Config\Source\Yesno</source_model >
8
+ <config_path >payment/bssva/active</config_path >
9
+ </field >
10
+ <field id =" title" translate =" label" type =" text" sortOrder =" 20" showInDefault =" 1" showInWebsite =" 1" showInStore =" 1" canRestore =" 1" >
11
+ <label >Title</label >
12
+ <config_path >payment/bssva/title</config_path >
13
+ </field >
14
+ <field id =" description" translate =" label" type =" textarea" sortOrder =" 30" showInDefault =" 1" showInWebsite =" 1" showInStore =" 1" canRestore =" 1" >
15
+ <label >Description</label >
16
+ <config_path >payment/bssva/description</config_path >
17
+ </field >
18
+ <field id =" min_order_total" translate =" label" type =" text" sortOrder =" 50" showInDefault =" 1" showInWebsite =" 1" showInStore =" 1" canRestore =" 1" >
19
+ <label >Minimum Order Total</label >
20
+ <frontend_class >validate-zero-or-greater</frontend_class >
21
+ <config_path >payment/bssva/min_order_total</config_path >
22
+ </field >
23
+ <field id =" max_order_total" translate =" label" type =" text" sortOrder =" 50" showInDefault =" 1" showInWebsite =" 1" showInStore =" 1" canRestore =" 1" >
24
+ <label >Maximum Order Total</label >
25
+ <frontend_class >validate-zero-or-greater</frontend_class >
26
+ <config_path >payment/bssva/max_order_total</config_path >
27
+ </field >
28
+ </group >
29
+ </include >
Original file line number Diff line number Diff line change 147
147
<sort_order >7</sort_order >
148
148
<currency >IDR</currency >
149
149
</bsiva >
150
+ <bssva >
151
+ <active >1</active >
152
+ <payment_action >initialize</payment_action >
153
+ <model >Xendit\M2Invoice\Model\Payment\BSSVA</model >
154
+ <title >Bank Transfer - BSS</title >
155
+ <description >Bayar pesanan dengan transfer bank BSS dengan virtual account melalui Xendit</description >
156
+ <min_order_total >1</min_order_total >
157
+ <max_order_total >50000000000</max_order_total >
158
+ <is_gateway >1</is_gateway >
159
+ <can_initialize >1</can_initialize >
160
+ <can_use_checkout >1</can_use_checkout >
161
+ <sort_order >7</sort_order >
162
+ <currency >IDR</currency >
163
+ </bssva >
150
164
<mandiriva >
151
165
<active >1</active >
152
166
<payment_action >initialize</payment_action >
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" ?>
2
2
<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 =" 9 .0.1 " active =" true" ></module >
3
+ <module name =" Xendit_M2Invoice" setup_version =" 10 .0.0 " active =" true" ></module >
4
4
</config >
Original file line number Diff line number Diff line change @@ -120,5 +120,8 @@ https://github.com/magento/magento2/blob/2.2.0-rc2.1/app/code/Magento/Multishipp
120
120
<method name =' atome' >
121
121
<allow_multiple_address >1</allow_multiple_address >
122
122
</method >
123
+ <method name =' bssva' >
124
+ <allow_multiple_address >1</allow_multiple_address >
125
+ </method >
123
126
</methods >
124
127
</payment >
Original file line number Diff line number Diff line change 45
45
<item name =" atome" xsi : type =" string" >Xendit_M2Invoice::multishipping/atome.phtml</item >
46
46
<item name =" dd_rcbc" xsi : type =" string" >Xendit_M2Invoice::multishipping/dd_rcbc.phtml</item >
47
47
<item name =" lbc" xsi : type =" string" >Xendit_M2Invoice::multishipping/lbc.phtml</item >
48
+ <item name =" bssva" xsi : type =" string" >Xendit_M2Invoice::multishipping/bssva.phtml</item >
48
49
</argument >
49
50
</arguments >
50
51
</referenceBlock >
Original file line number Diff line number Diff line change
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: 'bssva'
15
+ };
16
+ layout([
17
+ {
18
+ component: 'Xendit_M2Invoice/js/view/payment/method-renderer/multishipping/bssva',
19
+ name: 'payment_method_bssva',
20
+ method: paymentMethodData.method,
21
+ item: paymentMethodData
22
+ }
23
+ ]);
24
+
25
+ if(window.checkoutConfig.payment[paymentMethodData.method].image != ""){
26
+ $("label[for=p_method_"+paymentMethodData.method+"]")
27
+ .prepend('<img class="xendit-payment-icon" src="'+window.checkoutConfig.payment[paymentMethodData.method].image+'" />');
28
+ }
29
+
30
+ $('body').trigger('contentUpdated');
31
+ })
32
+ })
33
+ </script>
34
+ <!-- ko template: getTemplate() --><!-- /ko -->
Original file line number Diff line number Diff line change @@ -158,6 +158,10 @@ define(
158
158
type : 'lbc' ,
159
159
component : 'Xendit_M2Invoice/js/view/payment/method-renderer/lbc'
160
160
} ,
161
+ {
162
+ type : 'bssva' ,
163
+ component : 'Xendit_M2Invoice/js/view/payment/method-renderer/bssva'
164
+ }
161
165
) ;
162
166
return Component . extend ( { } ) ;
163
167
}
You can’t perform that action at this time.
0 commit comments