mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Throw error when hosted fields transaction declined and display an error message to the customer
This commit is contained in:
parent
bc86c8341f
commit
c5a107d02b
3 changed files with 26 additions and 8 deletions
|
@ -329,7 +329,20 @@ class OrderEndpoint {
|
|||
);
|
||||
throw $error;
|
||||
}
|
||||
|
||||
$order = $this->order_factory->from_paypal_response( $json );
|
||||
|
||||
$purchase_units_payments_captures_status = $order->purchase_units()[0]->payments()->captures()[0]->status() ?? '';
|
||||
if ( $purchase_units_payments_captures_status && 'DECLINED' === $purchase_units_payments_captures_status ) {
|
||||
throw new RuntimeException(
|
||||
sprintf(
|
||||
// translators: %s is the current status.
|
||||
__( 'Purchase units payments captures status %s', 'woocommerce-paypal-payments' ),
|
||||
$purchase_units_payments_captures_status
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue