Skip to content

Commit

Permalink
Gutenberg no longer accepts NULL as a result of process_payment
Browse files Browse the repository at this point in the history
  • Loading branch information
iverok committed Oct 4, 2024
1 parent 5133e59 commit 98089f9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions WC_Gateway_Vipps.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,7 @@ public function express_checkout_available() {
// IOK 2018-04-20 Initiate payment at Vipps and redirect to the Vipps payment terminal.
public function process_payment ($order_id) {
global $woocommerce, $Vipps;
if (!$order_id) return false;
if (!$order_id) return [];

do_action('woo_vipps_before_process_payment',$order_id);

Expand All @@ -1449,7 +1449,7 @@ public function process_payment ($order_id) {
} catch (Exception $e) {
$this->log(sprintf(__('Could not get access token when initiating %1$s payment for order id:','woo-vipps'), $this->get_payment_method_name()) . $order_id .":\n" . $e->getMessage(), 'error');
wc_add_notice(sprintf(__('Unfortunately, the %1$s payment method is currently unavailable. Please choose another method.','woo-vipps'), $this->get_payment_method_name()),'error');
return false;
return [];
}


Expand All @@ -1471,7 +1471,7 @@ public function process_payment ($order_id) {
// No longer the case for V2 of the API
if (false && !$phone) {
wc_add_notice(sprintf(__('You need to enter your phone number to pay with %1$s','woo-vipps'), $this->get_payment_method_name()) ,'error');
return false;
return [];
}

$order = wc_get_order($order_id);
Expand All @@ -1481,7 +1481,7 @@ public function process_payment ($order_id) {
if (! $order->has_status('pending', 'failed')) {
$this->log(sprintf(__("Trying to start order %1\$s with status %2\$s - only 'pending' and 'failed' are allowed, so this will fail", 'woo-vipps'), $order_id, $order->get_status()));
wc_add_notice(sprintf(__('This order cannot be paid with %1$s - please try another payment method or try again later', 'woo-vipps'), $this->get_payment_method_name()), 'error');
return false;
return [];
}

// If the Vipps order already has an init-timestamp, we should *not* call init_payment again,
Expand All @@ -1498,7 +1498,7 @@ public function process_payment ($order_id) {
$this->log(sprintf(__("Order %2\$d was attempted restarted, but had no %1\$s session url stored. Cannot continue!", 'woo-vipps'), Vipps::CompanyName(), $order_id), 'error');
wc_add_notice(sprintf(__('Order session expired at %1$s, please try again!', 'woo-vipps'), Vipps::CompanyName()), 'error');
$order->update_status('cancelled', sprintf(__('Cannot restart order at %1$s', 'woo-vipps'), Vipps::CompanyName()));
return false;
return [];
}

$order->add_order_note(sprintf(__('%1$s payment restarted','woo-vipps'), $this->get_payment_method_name()));
Expand Down Expand Up @@ -1546,7 +1546,7 @@ public function process_payment ($order_id) {
} catch (TemporaryVippsApiException $e) {
$this->log(sprintf(__('Could not initiate %1$s payment','woo-vipps'), $this->get_payment_method_name()) . ' ' . $e->getMessage(), 'error');
wc_add_notice(sprintf(__('Unfortunately, the %1$s payment method is temporarily unavailable. Please wait or choose another method.','woo-vipps'), $this->get_payment_method_name()),'error');
return false;
return [];
} catch (Exception $e) {

// Special case the "duplicate order id" thing to ensure it doesn't happen again, and if it does, at least
Expand All @@ -1559,7 +1559,7 @@ public function process_payment ($order_id) {

$this->log(sprintf(__('Could not initiate %1$s payment','woo-vipps'), $this->get_payment_method_name()) . ' ' . $e->getMessage(), 'error');
wc_add_notice(sprintf(__('Unfortunately, the %1$s payment method is currently unavailable. Please choose another method.','woo-vipps'), $this->get_payment_method_name()),'error');
return false;
return [];
}

$url = $content['url'];
Expand Down

0 comments on commit 98089f9

Please sign in to comment.