-
Notifications
You must be signed in to change notification settings - Fork 210
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
Implement PE with deferred intent for the card payment method in the classic checkout #2753
Implement PE with deferred intent for the card payment method in the classic checkout #2753
Conversation
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.
Niiiice changes @a-danae !! I'm excited to see the work being started in this PR.
I've only just performed a quick code review so far but I'll have play with the front-end changes and then look over the changes with more attention to detail. 🙌
const paymentMethodType = domElement.dataset.paymentMethodType; | ||
let upeElement; | ||
|
||
// Non-split PE. To be removed. |
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.
To be removed.
Just making sure I understand this and other similar in-line comments. This section can be removed when we stop supporting the legacy PE?
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 section can be removed when we stop supporting the legacy PE?
Exactly. More specifically, this can be removed when we implement using split PE.
We could fully switch to using deferred intents, but we'll still need this until we split the payment elements in the frontend in separate WooCommerce gateways.
* @return array An array containing the payment information for processing a payment intent. | ||
*/ | ||
private function prepare_payment_information_from_request( WC_Order $order ) { | ||
// TODO: throw exception if any required information is missing. |
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.
Just checking, are the TODO's added in this PR going to be addressed in this PR or later?
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 one specifically was already solved. Removed in 8098d58
But, yup, it's probably confusing to have them around and we already have tasks for working on them. I'm removing the ones that aren't meant to be solved in this PR, which is all but one.
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 @a-danae !
It's probably confusing to have them around and we already have tasks for working on them
I personally think they're fine to have in this base PR to help indicate where we expect code from another issue to go. I just wanted to avoid shipping the feature with a bunch of TODO's that we added early on and then never got around to addressing 😄
Happy to go with whatever you think is best!
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.
Makes complete sense 😄
I've removed the TODO comments in cf90c3c. We can decide where's the best place to handle the behaviors mentioned in those comments when working on the issues.
includes/payment-methods/class-wc-stripe-upe-payment-gateway.php
Outdated
Show resolved
Hide resolved
$order->update_meta_data( '_stripe_upe_payment_type', $selected_payment_type ); | ||
} | ||
|
||
$order->update_status( 'pending', __( 'Awaiting payment.', 'woocommerce-gateway-stripe' ) ); |
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 haven't tested anything yet but I'm curious why we need to update the status of the order to pending when dealing with deferred intents. What is the order status before this?
I'm wondering if we should have a $order->needs_payment()
somewhere so that we're only attempting to create and confirm an intent for orders that have pending/failed status.
Maybe inside process_payment_with_deferred_intent()
?
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 haven't tested anything yet but I'm curious why we need to update the status of the order to pending when dealing with deferred intents. What is the order status before this?
You're right, no need to update the order status. The order is already "pending" at this point. Fixed in fef7018
I'm wondering if we should have a $order->needs_payment() somewhere so that we're only attempting to create and confirm an intent for orders that have pending/failed status.
Yeah, I agree.
I see there's a more complex logic around this in verify_intent_after_checkout(), but I think it's specific for the legacy PE implementation because it runs between the Checkout and Thank you pages.
Would it be okay with you to have an issue for addressing this, instead of doing it in this PR? I'm thinking that webhooks and cache may also come into play, but would like to dive into it. Also to not delay merging this base PR.
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.
Would it be okay with you to have an issue for addressing this, instead of doing it in this PR? I'm thinking that webhooks and cache may also come into play, but would like to dive into it. Also to not delay merging this base PR.
That sounds good to me!
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.
Yay! GH issue created over here #2785 . Of course feel free to update it!
And thanks as always for pointing these out 😄
Co-authored-by: Matt Allan <matttallan@gmail.com>
… intent Co-authored-by: Matt Allan <matttallan@gmail.com>
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.
Amazing work on this one @a-danae !!
As per the testing instructions you shared on the PR, I purchased two orders using a new card on both the develop
and add/card-classic-with-deferred-intent
and ran through the following checks I've posted below.
The only two issues I found were when I tried to purchase a regular WC product as a guest customer and the other issue was I noticed shipping details were missing from the payment data when looking at the payment from the Stripe dashboard
I'm not sure if you wanted to fix these in this PR or open separate issues for them but I'm happy to approve this PR and leave that decision up to you 😄
I also left a small comment regarding the empty initializeAppearance
function
- Confirmed the
_stripe_upe_redirect_processed
meta is not set on the order purchased on this branch - Confirmed all of the stripe processing meta is set on the order (i.e.
_stripe_fee
&_stripe_intent_id
) and is consistent across both orders - Confirmed the payment intent in the Stripe dashabord has the correct customer, payment & meta data and is consistent across both orders created on different branched.
⚠️ The customer, payment and metadata all looked correct, however one thing I noticed is the payment on this branch doesn't have a shipping section when looking at Stripe. Looking in the events and logs section, it looks like ondevelop
we send aPOST /payment_intents/pi_
request with shipping. Not sure if this is needed but I'm happy to move this to a separate issue if you like.
Tested the above cases as:
- Guest customer
- Tested with a failed card (0431) along with other erroring cases and confirmed new intents were created each time on this branch (confirming the bug that will be fixed in [Deferred intent] When possible, reuse a payment intent associated with the order #2761)
Specific deferred intent checks:
- Confirm no intent is created on checkout page load on this branch
- Confirm intent is created and confirmed after processing the checkout
…d in the selected country
Thanks for going ahead and re-reviewing this PR! I completely missed the missing shipping information, great catch 🙂 I was planning to leave a comment here after solving the guest customer issue but I'll continue with that in the morning. |
This should be fixed by 863cfc7. Something similar was happening in another place, and should be fixed by 1c2f308 Also, I introduced this validation that was present in the legacy PE flow 646299c Back to you. Thanks for such a thorough review, Matt! 🙌 |
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 @a-danae for fixing those issues!
- I've confirmed the issue with not being able to purchase as a guest customer have been resolved.
- I've given the latest changes a code review
- Smoke tested the overall changes once again
I'm happy to approve this to be merged 🎉💃
Thanks for all the work you did to lay the foundation for deferred intents!
Fixes #2747
This PR doesn't point to
develop
as we'll require further work before these changes get shipped.Changes proposed in this Pull Request:
This PR only covers:
Testing instructions
Happy path
develop
Confirm the intent creation flow is deferred
Card failures
Note: With the card failures, a new payment intent will be created for each retry. In the future, the same intent will be reused as possible. This will be fixed by #2761.
changelog.txt
andreadme.txt
(or does not apply)Post merge