-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cancel on expiry and duplication of payments #121
Conversation
This is really a good catch! User can pay with Konbini and later they can change the payment method.... I believe we should prevent this and cancel the previous order and placing a new order when payment
I will explain why this can be a problem,
the preivous order become processing. Q. Why this is problem?
So, this should only applied who went to through I also check with different total amount, It is not cancelling the previous order. So it only happens when user try to order with the same amount based on the test. |
@Dinwy Thank you for your review, and that's a great catch! HOWEVER - I have a bad news... I can reproduce this behaviour with the stable release of the plugin version 3.1.4! 😹 |
WRT the point that a payment for another new checkout will pay for an existing payment, it turned out that this was caused by this sequence of stack:
Specifically these portions:
With these codes, WooCommerce avoids to create a new order and instead tries to reuse a pre-existing one, if the contents of the shopping carts are identical ( As such, my conclusion is that:
@Dinwy I appreciate your another review, with this in your mind 🙏 There can be another corner case, and I truly appreciate your scrutiny! |
Konbini payments are unique: There's a considerable time gap between the timing that a payment is ready for capture (payment codes issued, or "authorized" in KOMOJU) and the timing of actual capture. For this purpose, the KOMOJU Payment plugin puts a WooCommerce order pending or on hold when a Konbini payment is "authorized".
During the period that orders on WooCommerce are pending or on-hold, however, WooCommerce allows shoppers to make another payment for the same order, through the page called order-pay (
/checkout/order-pay
- cf https://github.com/woocommerce/woocommerce/blob/4318dac7ecd6547a983148273fd2e278cbb18547/docs/getting-started/woocommerce-endpoints.md#L18). Due to this nature, there are multiple problematic scenarios that can happen, including:This PR adds countermeasures against these scenarios. Particularly, it amends the codes to:
set_transaction_id
much earlier, so thatexpired
webhook events are handled correctly,komoju_payment_id
(throughsave_komoju_meta_data
) much earlier, for easier detection of duplicated payments, and