Use a class that uses the trait instead of calling it directly
Some checks failed
CI / PHP 7.4 (push) Has been cancelled
CI / PHP 8.0 (push) Has been cancelled
CI / PHP 8.1 (push) Has been cancelled
CI / PHP 8.2 (push) Has been cancelled
CI / PHP 8.3 (push) Has been cancelled
CI / PHP 8.4 (push) Has been cancelled

This commit is contained in:
Narek Zakarian 2025-08-12 16:07:53 +04:00
parent fbd7d843ff
commit afd39b28df
No known key found for this signature in database
GPG key ID: 07AFD7E7A9C164A7
2 changed files with 7 additions and 5 deletions

View file

@ -19,14 +19,12 @@ use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order; use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
use WooCommerce\PayPalCommerce\OrderTracking\Endpoint\OrderTrackingEndpoint; use WooCommerce\PayPalCommerce\OrderTracking\Endpoint\OrderTrackingEndpoint;
use WooCommerce\PayPalCommerce\OrderTracking\Shipment\ShipmentFactoryInterface; use WooCommerce\PayPalCommerce\OrderTracking\Shipment\ShipmentFactoryInterface;
use WooCommerce\PayPalCommerce\OrderTracking\Shipment\ShipmentInterface;
use WooCommerce\PayPalCommerce\PPCP; use WooCommerce\PayPalCommerce\PPCP;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway; use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
use WooCommerce\PayPalCommerce\WcGateway\Helper\RefundFeesUpdater; use WooCommerce\PayPalCommerce\WcGateway\Helper\RefundFeesUpdater;
use WooCommerce\PayPalCommerce\WcGateway\Processor\AuthorizedPaymentsProcessor; use WooCommerce\PayPalCommerce\WcGateway\Processor\AuthorizedPaymentsProcessor;
use WooCommerce\PayPalCommerce\WcGateway\Processor\OrderProcessor; use WooCommerce\PayPalCommerce\WcGateway\Processor\OrderProcessor;
use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor; use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor;
use \WooCommerce\PayPalCommerce\WcGateway\Processor\TransactionIdHandlingTrait;
/** /**
* Returns the PayPal order. * Returns the PayPal order.
@ -190,8 +188,12 @@ function ppcp_create_order_tracking( WC_Order $wc_order, string $tracking_number
assert( $endpoint instanceof OrderTrackingEndpoint ); assert( $endpoint instanceof OrderTrackingEndpoint );
$paypal_order = ppcp_get_paypal_order( $wc_order ); $paypal_order = ppcp_get_paypal_order( $wc_order );
$capture_id = TransactionIdHandlingTrait::get_paypal_order_transaction_id( $paypal_order ); $capture_id = $endpoint->get_paypal_order_transaction_id( $paypal_order );
$wc_order_id = $wc_order->get_id(); if ( is_null( $capture_id ) ) {
throw new RuntimeException( 'Could not retrieve transaction ID from PayPal order' );
}
$wc_order_id = $wc_order->get_id();
$ppcp_shipment = $shipment_factory->create_shipment( $ppcp_shipment = $shipment_factory->create_shipment(
$wc_order_id, $wc_order_id,

View file

@ -67,7 +67,7 @@ trait TransactionIdHandlingTrait {
* *
* @return string|null * @return string|null
*/ */
public static function get_paypal_order_transaction_id( Order $order ): ?string { public function get_paypal_order_transaction_id( Order $order ): ?string {
$purchase_unit = $order->purchase_units()[0] ?? null; $purchase_unit = $order->purchase_units()[0] ?? null;
if ( ! $purchase_unit ) { if ( ! $purchase_unit ) {
return null; return null;