-
Notifications
You must be signed in to change notification settings - Fork 211
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
Handling saving of methods when SPE is enabled #4126
base: develop
Are you sure you want to change the base?
Conversation
…ps://github.com/woocommerce/woocommerce-gateway-stripe into fix/handling-saving-of-methods-with-spe-enabled
@@ -0,0 +1,14 @@ | |||
import { NON_REUSABLE_METHODS } from 'wcstripe/stripe-utils/constants'; |
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 will merge both files on the next PR so this one doesn't get too big. I will also add tests for this there.
} | ||
|
||
$payment_method_object = $this->stripe_request( 'payment_methods/' . $payment_method_id ); | ||
|
||
$payment_method = $this->payment_methods[ $payment_method_type ]; |
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 was redundant.
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 @wjrosa for implementing this.
✅ Saving a card from My account
page works.
✅ Saving a card during checkout in the shortcode checkout page works.
✅ Saving a card during checkout in the block checkout page works.
save payment method
checkbox is visible even when the create account
checkbox is not selected.
I have left a few comments.
Apart from that I notices a few UI issues. I am listing them here but they could be unrelated to this PR.
- It looks different when only Stripe is enabled, the radio button and title is not there.
Only Stripe enabled | Other Payment gateways enabled |
---|---|
![]() |
![]() |
- The gap between the payment method name and icon looks a bit off.

…ps://github.com/woocommerce/woocommerce-gateway-stripe into fix/handling-saving-of-methods-with-spe-enabled
Thanks for the great review, @Mayisha !
Good catch! That applies only to the classic/shortcode checkout, right? Because, for me, the saving checkbox does not appear for logged-out users in the blocks checkout. I'm not sure if that's expected or if it is a bug. Anyway, I have fixed the issue for the classic checkout in c3a62ea
That was initially intentional, as part of the effort to make smart checkout payment options look like any other payment method. Still, since we must make the "Stripe" label configurable by merchants in #4114, it may be worth reverting that.
That's the Stripe container's default style and card icon. I am unsure we can replace that icon, which looks different from the others, but I will take a look. |
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 the updates @wjrosa.
- I am getting this console error for logged in user.

- For a logged out user, the checkbox won't go away when
create account
is checked.
Screen.Recording.2025-03-27.at.11.52.06.AM.mov
- This is unrelated to the PR but noting this as I noticed. The card testing instruction is always there irrespective of the selected method.

- The radio button and label are still absent when Stripe is the only available gateway. For example, this is what I see if I only have COD and it has the label with radio button.

I am not able to reproduce this bug for some reason 🤔 . The previous logic already checked for the lack of the saving checkbox, but I have improved it in b32cdaf anyway adding a
I thought that was the expected behavior: for logged-out users, only show the saving checkbox if "create account" is checked. Since if the account is not created, we won't be able to save the payment method. Isn't that correct?
That is a known issue that will be handled in #4048
That's intentional. I will remove this behavior on another PR. I was going to remove it in #4114, but I can do it before. |
Sorry about not being clear. The save payment method checkbox should be present only when we select a method which allows saving a token, example - card. But in this case the checkbox is present even when I switch to Multibanco or iDeal which does not support payment method saving. |
Oh right! I was able to reproduce and fix it in e8b8d08 . The logic got reversed 🤦 |
Thanks @wjrosa. ✅ I do not see the console error anymore.
I think this did not completely fix the issue. To reproduce-
![]() If you would like to handle this edge case in a separate PR, I will approve this one as the main functionality implemented in the PR is working 👀 |
You're right. I properly fixed it in 7a8afd2. This was tricky, as I had to bind the listener to the create account checkbox once the element was mounted and every time a method was selected. I could not find a way to retrieve the current payment method chosen from the root JS files |
📈 PHP Unit Code Coverage Report
|
Fixes #4049
Changes proposed in this Pull Request:
This PR fixes the saving of payment methods when the Smart Checkout (Single Payment Element) is enabled. Due to this feature's different flow, I had to add multiple checks on our default flow, mostly updating the selected payment method (retrieving it from the Stripe payment method object instead of the POST value).
Testing instructions
fix/handling-saving-of-methods-with-spe-enabled
)https://dashboard.stripe.com/settings/payment_methods
(labeled "Your configuration")pmc_...
on all our frontend codes with the ID above. This is temporary until the parent configuration, labeled WooCommerce Inc., supports all methods by defaultnpm run build:webpack
)_wcstripe_feature_spe
). You can do it by either hardcoding the return value ofis_spe_available
totrue
or by runningnpm run wp option update _wcstripe_feature_spe 'yes'
wp-admin/admin.php?page=wc-settings&tab=checkout§ion=stripe&panel=settings
)Changelog entry
Changelog Entry Comment
Comment
Post merge