Skip to content

Commit

Permalink
Handle payment response when showing the retry payment page. Ensures …
Browse files Browse the repository at this point in the history
…orders are marked as Failed. PAYTRAIL-29 paytrail#172
  • Loading branch information
chrisgan committed Jan 30, 2025
1 parent f403472 commit 12297cf
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ public function check_paytrail_response() {
$reference = filter_input(INPUT_GET, 'checkout-reference');
$cancel_order = filter_input(INPUT_GET, 'cancel_order');
$pay_for_order = filter_input(INPUT_GET, 'pay_for_order');
$payment_method = filter_input(INPUT_POST, 'payment_method');

if (!$status && !$reference && !$refund_callback && !$refund_unique_id) {
//no log to reduce number of log entries
Expand All @@ -834,7 +835,7 @@ public function check_paytrail_response() {
}

if ($pay_for_order) {
//Do not attempt to process further, the customer will be shown a page to choose payment methods
//The customer will be shown a page to choose payment methods
wc_clear_notices();
$message = __(
'Payment failed or was cancelled. Please try again',
Expand All @@ -843,6 +844,14 @@ public function check_paytrail_response() {

wc_add_notice( $message, 'notice');
$this->log('Paytrail: check_paytrail_response, pay_for_order is true. Payment page will be shown. Reference: ' . $reference, 'debug');

//Check to see if this is the first load of the page
if (!$payment_method) {
//Handle the payment response so that orders will change to Failed status
$this->log('Paytrail: Start handle_payment_response for reference ' . $reference, 'debug');
$this->handle_payment_response( $status );
}

return;
}

Expand Down

0 comments on commit 12297cf

Please sign in to comment.