mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Add PayPal transaction id to order note
This commit is contained in:
parent
f454c60292
commit
d2f257a812
4 changed files with 20 additions and 6 deletions
|
@ -277,7 +277,7 @@ trait ProcessPaymentTrait {
|
|||
if ( $error->has_detail( 'INSTRUMENT_DECLINED' ) ) {
|
||||
$wc_order->update_status(
|
||||
'failed',
|
||||
__( 'Instrument declined. ' . $error->details()[0]->description ?? '', 'woocommerce-paypal-payments' )
|
||||
__( 'Instrument declined. ', 'woocommerce-paypal-payments' ) . $error->details()[0]->description ?? ''
|
||||
);
|
||||
|
||||
$this->session_handler->increment_insufficient_funding_tries();
|
||||
|
@ -299,10 +299,10 @@ trait ProcessPaymentTrait {
|
|||
}
|
||||
|
||||
$error_message = $error->getMessage();
|
||||
if($error->issues()) {
|
||||
if ( $error->issues() ) {
|
||||
$error_message = $error->issues()[0]->issue . ' ' . $error->issues()[0]->description;
|
||||
}
|
||||
wc_add_notice($error_message, 'error');
|
||||
wc_add_notice( $error_message, 'error' );
|
||||
|
||||
$this->session_handler->destroy_session_data();
|
||||
} catch ( RuntimeException $error ) {
|
||||
|
@ -317,7 +317,7 @@ trait ProcessPaymentTrait {
|
|||
|
||||
$wc_order->update_status(
|
||||
'failed',
|
||||
__( 'Could not process order. ' . $this->order_processor->last_error() , 'woocommerce-paypal-payments' )
|
||||
__( 'Could not process order. ', 'woocommerce-paypal-payments' ) . $this->order_processor->last_error()
|
||||
);
|
||||
|
||||
return $failure_data;
|
||||
|
@ -362,7 +362,7 @@ trait ProcessPaymentTrait {
|
|||
|
||||
$wc_order->update_status(
|
||||
'failed',
|
||||
__( 'Could not process order. ' . $error->getMessage(), 'woocommerce-paypal-payments' )
|
||||
__( 'Could not process order. ', 'woocommerce-paypal-payments' ) . $error->getMessage()
|
||||
);
|
||||
|
||||
$this->session_handler->destroy_session_data();
|
||||
|
|
|
@ -141,7 +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');
|
||||
$this->last_error = __( 'No PayPal order found in the current WooCommerce session.', 'woocommerce-paypal-payments' );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue