mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
save transaction id to WC order
This commit is contained in:
parent
2d1507863b
commit
7bd17838fb
1 changed files with 36 additions and 0 deletions
|
@ -163,6 +163,12 @@ class OrderProcessor {
|
||||||
$wc_order->update_meta_data( PayPalGateway::CAPTURED_META_KEY, 'false' );
|
$wc_order->update_meta_data( PayPalGateway::CAPTURED_META_KEY, 'false' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$transaction_id = $this->get_paypal_order_transaction_id($order);
|
||||||
|
|
||||||
|
if($transaction_id !== ''){
|
||||||
|
$wc_order->set_transaction_id($transaction_id);
|
||||||
|
}
|
||||||
|
|
||||||
$wc_order->update_status(
|
$wc_order->update_status(
|
||||||
'on-hold',
|
'on-hold',
|
||||||
__( 'Awaiting payment.', 'woocommerce-paypal-payments' )
|
__( 'Awaiting payment.', 'woocommerce-paypal-payments' )
|
||||||
|
@ -187,6 +193,36 @@ class OrderProcessor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve transaction id from PayPal order.
|
||||||
|
*
|
||||||
|
* @param Order $order Order to get transaction id from.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function get_paypal_order_transaction_id(Order $order): string
|
||||||
|
{
|
||||||
|
$purchase_units = $order->purchase_units();
|
||||||
|
|
||||||
|
if(! isset($purchase_units[0])){
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$payments = $purchase_units[0]->payments();
|
||||||
|
|
||||||
|
if($payments === null){
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$captures = $payments->captures();
|
||||||
|
|
||||||
|
if(isset($captures[0])){
|
||||||
|
return $captures[0]->id();
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if an order should be captured immediately.
|
* Returns if an order should be captured immediately.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue