mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Fail WC order only if PayPal order status is not completed
This commit is contained in:
parent
5fbe7580d0
commit
035ff32d59
1 changed files with 15 additions and 8 deletions
|
@ -14,6 +14,7 @@ use Dhii\Modular\Module\ModuleInterface;
|
|||
use WC_Order;
|
||||
use WooCommerce\PayPalCommerce\AdminNotices\Repository\Repository;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Capture;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Repository\PayPalRequestIdRepository;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Admin\FeesRenderer;
|
||||
|
@ -239,20 +240,26 @@ class WCGatewayModule implements ModuleInterface {
|
|||
$order_endpoint = $c->get( 'api.endpoint.order' );
|
||||
$logger = $c->get( 'woocommerce.logger.woocommerce' );
|
||||
$order = $order_endpoint->order( $order_id );
|
||||
$order_status = $order->status();
|
||||
$logger->info( 'Checking payment captured webhook, order status: ' . $order_status->name());
|
||||
$order_status = $order->status();
|
||||
$logger->info( "Checking payment captured webhook for WC order #{$wc_order_id}, PayPal order status: " . $order_status->name() );
|
||||
|
||||
$wc_order = wc_get_order( $wc_order_id );
|
||||
if ( ! is_a( $wc_order, WC_Order::class ) || $wc_order->get_status() !== 'on-hold' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$message = __(
|
||||
'Could not process order because PAYMENT.CAPTURE.COMPLETED webhook not received.',
|
||||
'woocommerce-paypal-payments'
|
||||
);
|
||||
$wc_order->update_status( 'failed', $message );
|
||||
}, 10, 2
|
||||
if ( $order_status->name() !== OrderStatus::COMPLETED ) {
|
||||
$message = __(
|
||||
'Could not process WC order because PAYMENT.CAPTURE.COMPLETED webhook not received.',
|
||||
'woocommerce-paypal-payments'
|
||||
);
|
||||
$logger->error( $message );
|
||||
$wc_order->update_status( 'failed', $message );
|
||||
}
|
||||
|
||||
},
|
||||
10,
|
||||
2
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue