Skip to content

Commit a642305

Browse files
authored
Merge pull request #25 from marinsagovac/feature/1.7.2
Feature/1.7.2
2 parents 3cb3515 + f7e539b commit a642305

File tree

3 files changed

+52
-47
lines changed

3 files changed

+52
-47
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Most recent latest changes is defined on every major, minor and bug fixes.
66

77
## Versions
88

9+
### 1.7.2
10+
11+
* Hotfix on on cancelling order will not empty cart
12+
913
### 1.7.1
1014

1115
* Change HNB URL tecajna to v3

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ Latest version:
4545

4646
API 2.x.x:
4747

48+
* Version [1.7.2](https://github.com/marinsagovac/woocommerce-tcom-payway/archive/refs/tags/1.7.2.zip) January/2023
4849
* Version [1.7.1](https://github.com/marinsagovac/woocommerce-tcom-payway/archive/refs/tags/1.7.1.zip) January/2023
49-
* Version [1.7](https://github.com/marinsagovac/woocommerce-tcom-payway/archive/refs/tags/1.7.zip) December/2022
50-
* Version [1.6.1](https://github.com/marinsagovac/woocommerce-tcom-payway/archive/refs/tags/1.6.1.zip) September/2022
5150

5251
Old releases (not recommended):
5352

53+
* Version [1.7](https://github.com/marinsagovac/woocommerce-tcom-payway/archive/refs/tags/1.7.zip) December/2022
54+
* Version [1.6.1](https://github.com/marinsagovac/woocommerce-tcom-payway/archive/refs/tags/1.6.1.zip) September/2022
5455
* Version [1.5](https://github.com/marinsagovac/woocommerce-tcom-payway/releases/tags/1.5.zip) November/2021
5556
* Version [1.4](https://github.com/marinsagovac/woocommerce-tcom-payway/releases/tags/1.4.zip) June/2021
5657
* Version [1.3.3](https://github.com/marinsagovac/woocommerce-tcom-payway/releases/tag/1.3.3) January/2021

classes/class-wc-tpayway.php

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Class WC_TPAYWAY
55
*
6-
* WC_TPAYWAY with API 2.0
6+
* WC_TPAYWAY with API 2.0.9
77
*/
88
class WC_TPAYWAY extends WC_Payment_Gateway
99
{
@@ -343,7 +343,7 @@ public function generate_ipg_form($order_id)
343343

344344
$order_format_value = str_pad(($order_total * 100), 12, '0', STR_PAD_LEFT);
345345
$total_amount = number_format($order_total, 2, '', '');
346-
$total_amount_request = number_format($order_total, 2, ',', '');
346+
$total_amount_request = number_format($order_total, 2, ',', '');
347347

348348
$secret_key = $this->acq_id; // Secret key
349349

@@ -485,18 +485,19 @@ function check_tcompayway_response()
485485

486486
// Return if is error during installation
487487
if (!$_POST['ShoppingCartID']) {
488-
return;
488+
return;
489489
}
490490

491491
if (!$_POST['Amount']) {
492-
return;
493-
}
494-
// End installation
492+
$amount = 0;
493+
} else {
494+
$amount = $_POST['Amount'];
495+
}
495496

496497
$order_id = $_POST['ShoppingCartID'];
497498

498499
$order = new WC_Order($order_id);
499-
$amount = $this->sanitize($_POST['Amount']);
500+
$amount = $this->sanitize($amount);
500501
$status = isset($_POST['Success']) ? (int)$_POST['Success'] : 0;
501502
$reasonCode = isset($_POST['ApprovalCode']) ? (int)$_POST['ApprovalCode'] : 0;
502503

@@ -546,11 +547,47 @@ function check_tcompayway_response()
546547
$order->payment_complete();
547548

548549
wp_redirect($this->get_return_url($order), 302);
549-
exit;
550+
exit;
550551
}
551552
}
552553

553554
if (isset($_POST['Success'])) {
555+
if (isset($_POST['ResponseCode'])) {
556+
$responseCode = (int)$_POST['ResponseCode'];
557+
if ($responseCode == 15 || $responseCode == 16) {
558+
559+
$order->add_order_note($this->get_response_codes($responseCode) . " (Code $responseCode)");
560+
$order->update_status('cancelled');
561+
$woocommerce->cart->empty_cart();
562+
563+
global $wpdb;
564+
$table_name = $wpdb->prefix . 'tpayway_ipg';
565+
$wpdb->update(
566+
$table_name,
567+
array(
568+
'response_code' => $responseCode,
569+
'response_code_desc' => $this->get_response_codes($responseCode),
570+
'reason_code' => 0,
571+
'status' => 0,
572+
),
573+
array('transaction_id' => $order_id)
574+
);
575+
576+
$text = '<html><meta charset="utf-8"><body><center>';
577+
$text .= __('A payment was not cancelled', 'tcom-payway-wc') . '<br>';
578+
$text .= __('Reason: ', 'tcom-payway-wc');
579+
$text .= $this->get_response_codes($responseCode) . '<br>';
580+
$text .= __('Order Id: ', 'tcom-payway-wc');
581+
$text .= $order_id . '<br>';
582+
$text .= __('Redirecting...', 'tcom-payway-wc');
583+
$text .= '</center><script>setTimeout(function(){ window.location.replace("' . $this->response_url_fail . '"); },3000);</script></body></html>';
584+
585+
echo $text;
586+
587+
exit;
588+
}
589+
}
590+
554591
if ($_POST['Success'] == "0") {
555592
$errorCodes = json_encode($_POST['ErrorCodes']);
556593

@@ -585,43 +622,6 @@ function check_tcompayway_response()
585622
exit;
586623
}
587624
}
588-
589-
// Cancelled
590-
if (isset($_POST['ResponseCode'])) {
591-
$responseCode = (int)$_POST['ResponseCode'];
592-
if ($responseCode == 15 || $responseCode == 16) {
593-
594-
$order->add_order_note($this->get_response_codes($responseCode) . " (Code $responseCode)");
595-
$order->update_status('cancelled');
596-
$woocommerce->cart->empty_cart();
597-
598-
global $wpdb;
599-
$table_name = $wpdb->prefix . 'tpayway_ipg';
600-
$wpdb->update(
601-
$table_name,
602-
array(
603-
'response_code' => $responseCode,
604-
'response_code_desc' => $this->get_response_codes($responseCode),
605-
'reason_code' => 0,
606-
'status' => 0,
607-
),
608-
array('transaction_id' => $order_id)
609-
);
610-
611-
$text = '<html><meta charset="utf-8"><body><center>';
612-
$text .= __('A payment was not cancelled', 'tcom-payway-wc') . '<br>';
613-
$text .= __('Reason: ', 'tcom-payway-wc');
614-
$text .= $this->get_response_codes($responseCode) . '<br>';
615-
$text .= __('Order Id: ', 'tcom-payway-wc');
616-
$text .= $order_id . '<br>';
617-
$text .= __('Redirecting...', 'tcom-payway-wc');
618-
$text .= '</center><script>setTimeout(function(){ window.location.replace("' . $this->response_url_fail . '"); },3000);</script></body></html>';
619-
620-
echo $text;
621-
622-
exit;
623-
}
624-
}
625625
}
626626

627627
function get_pages($title = false, $indent = true)

0 commit comments

Comments
 (0)