Create order and redirect when no order

This commit is contained in:
Alex P 2023-11-14 10:55:30 +02:00
parent 5c699c24a5
commit a61e9303e9
No known key found for this signature in database
GPG key ID: 54487A734A204D71
10 changed files with 214 additions and 131 deletions

View file

@ -15,6 +15,7 @@ use WC_Session_Handler;
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
use Psr\Log\LoggerInterface;
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
use WooCommerce\PayPalCommerce\Session\MemoryWcSession;
use WooCommerce\PayPalCommerce\Session\SessionHandler;
use WooCommerce\PayPalCommerce\WcGateway\FundingSource\FundingSourceRenderer;
@ -228,12 +229,14 @@ class CheckoutOrderApproved implements RequestHandler {
continue;
}
if ( ! $this->order_processor->process( $wc_order ) ) {
try {
$this->order_processor->process( $wc_order );
} catch ( RuntimeException $exception ) {
return $this->failure_response(
sprintf(
'Failed to process WC order %s: %s.',
(string) $wc_order->get_id(),
$this->order_processor->last_error()
$exception->getMessage()
)
);
}