-
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
Split PE - Fixes Woo Subscriptions support when using card payments with dPE #2866
Split PE - Fixes Woo Subscriptions support when using card payments with dPE #2866
Conversation
I've performed the following tests on this PR: Classic checkout/shortcode
Checkout Blocks
Other subscription-related tests
|
Hey @mattallan I've been trying to make some subscription purchases using other payment methods like Bancontact. Stripe's doc suggest that Bancontact can be used for recurring revenue via SEPA Debit. Stipe will do the Bancontact -> SEPA stuff under the hood as long you send the required setup intent, off session args etc. However when I attempted to purchase a subscription using Bancontact I got a number of rolling issues:
![]() I'm not sure how you think we should proceed here. If theres a lot of unknowns here perhaps we limit the scope of this PR to card payments and work on other APMs in a separate PR. Thoughts? |
WooPayments have Bancontact as not a reusable payment method so perhaps there's more to this that makes it not possible. 🤔 |
So it turns out I had manual payments enabled with Subscriptions which is why Bancontact was showing up originally. If I disable manual payments, it is no longer shown. That changes the question slightly because we do still need to resolve those errors but I wonder if we need to change it so we only create set up intents for off session payments if we're creating an automatic subscription. 🤔 |
@james-allan Thanks for taking a look at this one. Since some of our APMs are listed as reusable, they should still technically work for subscription purchases and so I had a look at what is stopping us from accepting an APM like Bancontact to purchase a subscription product. Here's what I found needs to change:
There's a fair bit to change here but I'm happy to continue adding those changes to this PR unless you think it's best to separate them? |
I'm not sure how far down this rabbit hole you went but from my testing payment methods like Bancontact don't return the last 4 even once you've approved the payment and returned to the store.
Above is the response from the You'll notice that the SEPA PM response includes additional details like last4 whereas the Bancontact has essentially no information. Looking at Stripe docs, this appears to be the correct response. The Bancontact arg has no child args, but SEPA does. I think (I could be wrong) but this could mean Bancontact PMs cannot ever return a last4.
I think its fair to move this to a separate issue given there's additional research we'll need to do to investigate if Bancontact can be used as a saved token. As I mentioned, WooPayments have it as a non-resuable method, our Stripe plugin is torn on the topic because the |
Thanks @james-allan for going further than I did! I didn't get that far to confirm whether the last4 would be on the payment method object after finishing/confirming the Bancontact payment.
I agree with this comment and happy to handle this in a separate PR as it sounds like we'll need to do a bit more investigation into supporting automatic subscription renewals using our APMs. |
Ok, I've created the issue to add the other APMs here: #2872 |
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.
Changes look good @mattallan.
I've tested the following scenarios:
- Standard subscription purchase. 👍
- Free trial subscription. 👍
- Signing up using a saved card. 👍
- Early renewal order processed 👍
- Sign up to free trial using 3DS card ❌ I got an
invalid_intent_id
error message on checkout and the following error in my logs:
PHP Warning: Undefined property: stdClass::$latest_charge in /wp-content/plugins/woocommerce-gateway-stripe/includes/abstracts/abstract-wc-stripe-payment-gateway.php on line 717

FWIW the invalid intent error appears to be caused because the order doesn't have an intent stored on it but the update_order_status_ajax()
request receives a setup intent id. ie seti_1OfHMMCM0qfKgPGttSXXo0ZI !== ''
.
I think this means update_order_status_ajax()
needs to be changed to handle receiving setup intents and intents. eg if it recevies a set up intent, see if the order has a corresponding set up intent. At the moment it just pulls the payment intent order meta which is empty in this case.
- Standard sign up using 3DS card 👍
- Renewal run via Action scheduler. 👍
- Multiple subscriptions (weekly and monthly) 👍
includes/payment-methods/class-wc-stripe-upe-payment-gateway.php
Outdated
Show resolved
Hide resolved
Co-authored-by: James Allan <james.allan@automattic.com>
Co-authored-by: James Allan <james.allan@automattic.com>
Thanks for taking a look and testing this @james-allan
Good catch! I'll look into this one! |
@james-allan I've just pushed up 1668359 to fix the issue with using a 3DS card to purchase subscription product with no upfront cost (i.e. trial/synced). Something I also noticed while reviewing the code is that I was completing orders (and activating subscriptions) before the customer is redirected to an authentication modal. I pushed up 3eecfc4 to fix this. |
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.
Changes look good and work well. I just noticed a slightly confusing sentence in the new function comment you introduced. Otherwise this looks good to go.
Co-authored-by: James Allan <james.allan@automattic.com>
For #2777
Changes proposed in this Pull Request:
This PR fixes compatibility issues with Woo Subscriptions and our new Split PE with deferred intent changes. In my testing there were three main issues I found:
I have addressed the above issues in the following commits:
maybe_update_source_on_subscription_order()
whenever we're using an existing saved payment method so that thepm_
andcus_
tokens are saved on the subscription. This function was already being handled when a new card was being saved (see insidehandle_saving_payment_method()
), but not when an existing card was used.process_payment_with_deferred_intent()
for purchases that don't have an upfront payment but still require the card to be taken for future payments i.e. a subscription with a free trial. This single commit ended up being a bit larger than I typically like however, it can be broken down into the following changes:intent_controller->create_and_confirm_setup_intent()
function so that it can handle requests from the front-end (My Account > Payment methods > Add new) and ourprocess_payment_with_deferred_intent()
function.process_payment_with_deferred_intent()
to add functionality when$payment_needed
is false. When no payment needed and we're inside the process_payment flow, it's expected for a setup intent to be created.processPayment
when a customer is changing payment method to an existing saved card.Testing instructions
Before testing, make sure you have:
There are a lot of subscription flows to cover and rather than go through them all here, I'll link to our testing instructions for the critical subscription flows:
Purchasing and renewing subscriptions
pm_1234
) are correctly saved on the subscriptionPurchasing and renewing subscriptions with setup intents
Changing subscriptions payment method
Note
Before running this test, make sure you have at least 2 active subscriptions to test updating all payment methods.
4242424242424242
, change the payment to mastercard5555555555554444
so it's easier to notice the differencechangelog.txt
andreadme.txt
(or does not apply)Post merge