Add process order error messages

This commit is contained in:
dinamiko 2022-01-27 16:40:02 +01:00
parent fc5589612c
commit 74490c40c9
2 changed files with 5 additions and 3 deletions

View file

@ -277,7 +277,7 @@ trait ProcessPaymentTrait {
if ( $error->has_detail( 'INSTRUMENT_DECLINED' ) ) {
$wc_order->update_status(
'failed',
__( 'Instrument declined.', 'woocommerce-paypal-payments' )
__( 'Instrument declined. ' . $error->details()[0]->description ?? '', 'woocommerce-paypal-payments' )
);
$this->session_handler->increment_insufficient_funding_tries();
@ -308,9 +308,10 @@ trait ProcessPaymentTrait {
$this->order_processor->last_error(),
'error'
);
$wc_order->update_status(
'failed',
__( 'Could not process order.', 'woocommerce-paypal-payments' )
__( 'Could not process order. ' . $this->order_processor->last_error() , 'woocommerce-paypal-payments' )
);
return $failure_data;
@ -355,7 +356,7 @@ trait ProcessPaymentTrait {
$wc_order->update_status(
'failed',
__( 'Could not process order.', 'woocommerce-paypal-payments' )
__( 'Could not process order. ' . $error->getMessage(), 'woocommerce-paypal-payments' )
);
$this->session_handler->destroy_session_data();

View file

@ -141,6 +141,7 @@ class OrderProcessor {
public function process( \WC_Order $wc_order ): bool {
$order = $this->session_handler->order();
if ( ! $order ) {
$this->last_error = __('No PayPal order found in the current WooCommerce session.', 'woocommerce-paypal-payments');
return false;
}