Skip to content

Commit c93ff45

Browse files
authored
Merge pull request #66 from xendit/TPI-2941/fix-failure-endpoint
fix failure endpoint
2 parents fdc2a8a + b4a176e commit c93ff45

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

CHANGELOG.md

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

3+
## 2.4.2 (2020-11-23)
4+
5+
Improvements:
6+
7+
- Check order status before cancelling through failure endpoint
8+
39
## 2.4.1 (2020-11-06)
410

511
Improvements:

Xendit/M2Invoice/Controller/Checkout/Failure.php

+14-16
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,29 @@ public function execute()
1313
$order = $this->getOrderFactory()->create();
1414
$order ->load($orderId);
1515

16-
if ($order) {
17-
$this->getLogger()->debug('Requested order cancelled by customer. OrderId: ' . $order->getIncrementId());
18-
$this->cancelOrder($order, "customer cancelled the payment.");
19-
20-
$quoteId = $order->getQuoteId();
21-
$quote = $this->getQuoteRepository()->get($quoteId);
22-
23-
$this->getCheckoutHelper()->restoreQuote($quote); //restore cart
24-
}
16+
$this->shouldCancelOrder($order);
2517
}
2618
} else { //onepage
2719
$order = $this->getOrderById($this->getRequest()->get('order_id'));
28-
29-
if ($order) {
20+
21+
$this->shouldCancelOrder($order);
22+
}
23+
24+
$this->getMessageManager()->addWarningMessage(__("Xendit payment failed. Please click on 'Update Shopping Cart'."));
25+
$this->_redirect('checkout/cart');
26+
}
27+
28+
private function shouldCancelOrder($order) {
29+
if ($order) {
30+
if ($order->canInvoice()) {
3031
$this->getLogger()->debug('Requested order cancelled by customer. OrderId: ' . $order->getIncrementId());
3132
$this->cancelOrder($order, "customer cancelled the payment.");
32-
33+
3334
$quoteId = $order->getQuoteId();
3435
$quote = $this->getQuoteRepository()->get($quoteId);
35-
36+
3637
$this->getCheckoutHelper()->restoreQuote($quote); //restore cart
3738
}
3839
}
39-
40-
$this->getMessageManager()->addWarningMessage(__("Xendit payment failed. Please click on 'Update Shopping Cart'."));
41-
$this->_redirect('checkout/cart');
4240
}
4341
}

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.4.1'
88+
'x-plugin-version' => '2.4.2'
8989
];
9090

9191
if ($preferredMethod !== null) {

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.4.1",
5+
"version": "2.4.2",
66
"license": [
77
"GPL-3.0"
88
],

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.4.1" active="true"></module>
3+
<module name="Xendit_M2Invoice" setup_version="2.4.2" active="true"></module>
44
</config>

0 commit comments

Comments
 (0)