Merge branch 'trunk' into pcp-370-onboarding

This commit is contained in:
dinamiko 2022-02-07 10:23:31 +01:00
commit 4c71240684
13 changed files with 104 additions and 38 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. ', 'woocommerce-paypal-payments' ) . $error->details()[0]->description ?? ''
);
$this->session_handler->increment_insufficient_funding_tries();
@ -298,6 +298,19 @@ trait ProcessPaymentTrait {
);
}
$error_message = $error->getMessage();
if ( $error->issues() ) {
$error_message = implode(
array_map(
function( $issue ) {
return $issue->issue . ' ' . $issue->description . '<br/>';
},
$error->issues()
)
);
}
wc_add_notice( $error_message, 'error' );
$this->session_handler->destroy_session_data();
} catch ( RuntimeException $error ) {
$this->handle_failure( $wc_order, $error );
@ -308,9 +321,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. ', 'woocommerce-paypal-payments' ) . $this->order_processor->last_error()
);
return $failure_data;
@ -355,7 +369,7 @@ trait ProcessPaymentTrait {
$wc_order->update_status(
'failed',
__( 'Could not process order.', 'woocommerce-paypal-payments' )
__( 'Could not process order. ', 'woocommerce-paypal-payments' ) . $error->getMessage()
);
$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;
}

View file

@ -36,6 +36,15 @@ trait TransactionIdHandlingTrait {
try {
$wc_order->set_transaction_id( $transaction_id );
$wc_order->save();
$wc_order->add_order_note(
sprintf(
/* translators: %s is the PayPal transaction ID */
__( 'PayPal transaction ID: %s', 'woocommerce-paypal-payments' ),
$transaction_id
)
);
return true;
} catch ( Exception $exception ) {
if ( $logger ) {