Add order status CREATED to order processor check

This commit is contained in:
dinamiko 2022-06-07 12:17:35 +02:00
parent 77230fefa8
commit 8a0b439e5f
3 changed files with 12 additions and 9 deletions

View file

@ -173,10 +173,10 @@ class ApproveOrderEndpoint implements EndpointInterface {
wp_send_json_success( $order ); wp_send_json_success( $order );
} }
if ( ! $order->status()->is( OrderStatus::APPROVED ) ) { if ( ! $order->status()->is( OrderStatus::APPROVED ) && ! $order->status()->is( OrderStatus::CREATED ) ) {
$message = sprintf( $message = sprintf(
// translators: %s is the id of the order. // translators: %s is the id of the order.
__( 'Order %s is not approved yet.', 'woocommerce-paypal-payments' ), __( 'Order %s is not ready for processing yet.', 'woocommerce-paypal-payments' ),
$data['order_id'] $data['order_id']
); );

View file

@ -160,9 +160,9 @@ class OrderProcessor {
$this->add_paypal_meta( $wc_order, $order, $this->environment ); $this->add_paypal_meta( $wc_order, $order, $this->environment );
$error_message = null; $error_message = null;
if ( ! $this->order_is_approved( $order ) ) { if ( ! $this->order_is_ready_for_process( $order ) ) {
$error_message = __( $error_message = __(
'The payment has not been approved yet.', 'The payment is not ready for processing yet.',
'woocommerce-paypal-payments' 'woocommerce-paypal-payments'
); );
} }
@ -269,15 +269,15 @@ class OrderProcessor {
} }
/** /**
* Whether a given order is approved. * Whether a given order is ready for processing.
* *
* @param Order $order The order. * @param Order $order The order.
* *
* @return bool * @return bool
*/ */
private function order_is_approved( Order $order ): bool { private function order_is_ready_for_process( Order $order ): bool {
if ( $order->status()->is( OrderStatus::APPROVED ) ) { if ( $order->status()->is( OrderStatus::APPROVED ) || $order->status()->is( OrderStatus::CREATED ) ) {
return true; return true;
} }
@ -285,7 +285,7 @@ class OrderProcessor {
return false; return false;
} }
$is_approved = in_array( return in_array(
$this->threed_secure->proceed_with_order( $order ), $this->threed_secure->proceed_with_order( $order ),
array( array(
ThreeDSecure::NO_DECISION, ThreeDSecure::NO_DECISION,
@ -293,6 +293,5 @@ class OrderProcessor {
), ),
true true
); );
return $is_approved;
} }
} }

View file

@ -306,6 +306,10 @@ class OrderProcessorTest extends TestCase
->expects('is') ->expects('is')
->with(OrderStatus::APPROVED) ->with(OrderStatus::APPROVED)
->andReturn(false); ->andReturn(false);
$orderStatus
->expects('is')
->with(OrderStatus::CREATED)
->andReturn(false);
$orderId = 'abc'; $orderId = 'abc';
$orderIntent = 'CAPTURE'; $orderIntent = 'CAPTURE';
$currentOrder = Mockery::mock(Order::class); $currentOrder = Mockery::mock(Order::class);