-
Notifications
You must be signed in to change notification settings - Fork 69
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
UPE: intent caching tweaks #5653
Conversation
Size Change: 0 B Total Size: 1.37 MB ℹ️ View Unchanged
|
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.
Thank you for looking into making this part more reliable. Looking at the changes I start to think that there is a gap in WooCommerce API for payment plugins and it might require us looking upstream to properly solve such issues.
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.
Thanks for working on this. I am leaving some early comments.
…attic/woocommerce-payments into fix/5310-usage-of-processed-intent
A new batch of changes, and it makes sense to describe the current version. Three major decisions:
Tradeoffs:
This means it should be possible to open two pages and complete the order on one page; voila, the second open one uses a processed intent. Changes preventing duplicate orders/charges will likely cover this, but I suggest keeping the introduced verifications for now - I don't have better ideas on how to sync cached intent ID. |
I need inputs from more folks:
|
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.
The code changes look good based on my first-pass review. Keeping the caching logic exclusively in UPE gateway is a good idea. And thanks for various reliability improvements. I'll come back after some functional testing.
if ( $intent_data ) { | ||
// Extract the intent and ensure it's not bound to an order yet nor being processed. | ||
list( $cart_hash, $intent_id, $client_secret ) = explode( '-', $intent_data, 3 ); | ||
$order = ( new WC_Payments_DB() )->order_from_intent_id( $intent_id ); |
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.
Can we instead get the instance of WC_Payments_DB
from DI, like in webhook service?
$this->wcpay_db = $wcpay_db; |
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.
+1
// The invoked method already handles order status changes on success and partially on failure. | ||
// But, not all exceptions are triggering order status changes, so we have to clear intent cache. | ||
// The intent caching is UPE-specific, so we have to keep it in the UPE-gateways only. | ||
self::remove_upe_payment_intent_from_session(); |
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.
self::remove_upe_payment_intent_from_session(); | |
self::remove_upe_payment_intent_from_session(); | |
throw $e; |
Do we not need to rethrow the exception here as well? Otherwise if the parent gateway class throws an exception, for whatever reason, won't we just catch it and then continue on to return sucess instead of failure?
I have removed Helix from the review-queue due to Subscriptions being passed off to Quark. I have asked them to review. |
Fixes #5310
Changes proposed in this Pull Request
Testing instructions
To be done
npm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge