mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-10 01:15:45 +08:00
always return array from the process_payment()
This commit is contained in:
parent
9bdd2631dd
commit
edb0c9551c
1 changed files with 11 additions and 5 deletions
|
@ -21,13 +21,19 @@ trait ProcessPaymentTrait {
|
||||||
*
|
*
|
||||||
* @param int $order_id The WooCommerce order id.
|
* @param int $order_id The WooCommerce order id.
|
||||||
*
|
*
|
||||||
* @return array|null
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function process_payment( $order_id ) {
|
public function process_payment( $order_id ) {
|
||||||
global $woocommerce;
|
global $woocommerce;
|
||||||
|
|
||||||
|
$failure_data = array(
|
||||||
|
'result' => 'failure',
|
||||||
|
'redirect' => wc_get_checkout_url(),
|
||||||
|
);
|
||||||
|
|
||||||
$wc_order = wc_get_order( $order_id );
|
$wc_order = wc_get_order( $order_id );
|
||||||
if ( ! is_a( $wc_order, \WC_Order::class ) ) {
|
if ( ! is_a( $wc_order, \WC_Order::class ) ) {
|
||||||
return null;
|
return $failure_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,7 +69,7 @@ trait ProcessPaymentTrait {
|
||||||
__( 'Please use a different payment method.', 'woocommerce-paypal-payments' ),
|
__( 'Please use a different payment method.', 'woocommerce-paypal-payments' ),
|
||||||
'error'
|
'error'
|
||||||
);
|
);
|
||||||
return null;
|
return $failure_data;
|
||||||
}
|
}
|
||||||
return array(
|
return array(
|
||||||
'result' => 'success',
|
'result' => 'success',
|
||||||
|
@ -75,7 +81,7 @@ trait ProcessPaymentTrait {
|
||||||
} catch ( RuntimeException $error ) {
|
} catch ( RuntimeException $error ) {
|
||||||
$this->session_handler->destroy_session_data();
|
$this->session_handler->destroy_session_data();
|
||||||
wc_add_notice( $error->getMessage(), 'error' );
|
wc_add_notice( $error->getMessage(), 'error' );
|
||||||
return null;
|
return $failure_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
wc_add_notice(
|
wc_add_notice(
|
||||||
|
@ -83,6 +89,6 @@ trait ProcessPaymentTrait {
|
||||||
'error'
|
'error'
|
||||||
);
|
);
|
||||||
|
|
||||||
return null;
|
return $failure_data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue