-
Notifications
You must be signed in to change notification settings - Fork 221
Update the checkout order endpoint allowed order statuses for payment complete #12018
Update the checkout order endpoint allowed order statuses for payment complete #12018
Conversation
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
Size Change: 0 B Total Size: 1.61 MB ℹ️ View Unchanged
|
@@ -100,7 +100,7 @@ protected function get_route_post_response( \WP_REST_Request $request ) { | |||
$order_id = absint( $request['id'] ); | |||
$this->order = wc_get_order( $order_id ); | |||
|
|||
if ( $this->order->get_status() !== 'pending' && $this->order->get_status() !== 'failed' ) { | |||
if ( ! $this->order->needs_payment() ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a much better check yeah.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Change makes sense and tests well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't test this, but the code make sense and switching to needs_payment
is the correct call here.
97747a5
to
7fd4a2b
Compare
What
The checkout order endpoint requires that the order status is either
failed
orpending
so we can pay for the order. For plugin compatibility, we should allow custom order status, for example,scheduled
from WooCommerce Deposits.Fixes https://github.com/Automattic/woopay/issues/2374
Why
complete,
processing,
refunded,
etc., then we show the error, but we might miss other plugin's statuses.woocommerce_valid_order_statuses_for_payment_complete
filter, butneeds_payment
includes the filter, so it's a better approach.Testing Instructions
Please consider any edge cases this change may have, and also other areas of the product this may impact.
Test
scheduled
,failed
,pending
, etc order statuses.true
oncheck_nonce
scheduled
orders, and copy theCustomer payment page
linkCustomer payment page
to go to the pay-for-order pagekey
from the URLhttp://merchant.local/wp-json/wc/store/checkout/YOUR_ORDER_NUMBER?key=YOUR_KEY&billing_email=YOUR_BILLING_EMAIL
No Auth
Pending payment
and Customer:Existing customer
key
andbilling_email
params and send the requestScreenshots or screencast
WooCommerce Visibility
Required:
Checklist
Required:
[type]
label or a[skip-changelog]
label.Conditional:
[skip-changelog]
label is not present).Changelog