mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Merge pull request #1029 from woocommerce/PCP-951-could-not-retrieve-order
Could not retrieve order error (951)
This commit is contained in:
commit
d4187854de
3 changed files with 27 additions and 16 deletions
|
@ -469,14 +469,8 @@ class OrderEndpoint {
|
|||
$error = new RuntimeException(
|
||||
__( 'Could not retrieve order.', 'woocommerce-paypal-payments' )
|
||||
);
|
||||
$this->logger->log(
|
||||
'warning',
|
||||
$error->getMessage(),
|
||||
array(
|
||||
'args' => $args,
|
||||
'response' => $response,
|
||||
)
|
||||
);
|
||||
$this->logger->warning( $error->getMessage() );
|
||||
|
||||
throw $error;
|
||||
}
|
||||
$json = json_decode( $response['body'] );
|
||||
|
@ -511,8 +505,8 @@ class OrderEndpoint {
|
|||
);
|
||||
throw $error;
|
||||
}
|
||||
$order = $this->order_factory->from_paypal_response( $json );
|
||||
return $order;
|
||||
|
||||
return $this->order_factory->from_paypal_response( $json );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,9 +10,11 @@ declare(strict_types=1);
|
|||
namespace WooCommerce\PayPalCommerce\WcGateway\Processor;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use WC_Order;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\OrderFactory;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\OrderHelper;
|
||||
use WooCommerce\PayPalCommerce\Button\Helper\ThreeDSecure;
|
||||
|
@ -160,12 +162,27 @@ class OrderProcessor {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function process( \WC_Order $wc_order ): bool {
|
||||
$order_id = $wc_order->get_meta( PayPalGateway::ORDER_ID_META_KEY );
|
||||
$order = $this->session_handler->order() ?? $this->order_endpoint->order( $order_id );
|
||||
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' );
|
||||
return false;
|
||||
$order_id = $wc_order->get_meta( PayPalGateway::ORDER_ID_META_KEY );
|
||||
if ( ! $order_id ) {
|
||||
$this->logger->warning(
|
||||
sprintf(
|
||||
'No PayPal order ID found in order #%d meta.',
|
||||
$wc_order->get_id()
|
||||
)
|
||||
);
|
||||
$this->last_error = __( 'Could not retrieve order. This browser may not be supported. Please try again with a different browser.', 'woocommerce-paypal-payments' );
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$order = $this->order_endpoint->order( $order_id );
|
||||
} catch ( RuntimeException $exception ) {
|
||||
$this->last_error = __( 'Could not retrieve PayPal order.', 'woocommerce-paypal-payments' );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->add_paypal_meta( $wc_order, $order, $this->environment );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue