Skip to content
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

Billing: Add option to assign payment method to all subscriptions when adding card #50057

Merged
merged 13 commits into from
Feb 17, 2021

Conversation

sirbrillig
Copy link
Member

@sirbrillig sirbrillig commented Feb 12, 2021

Changes proposed in this Pull Request

Currently the "Add payment method" forms at both the account and site-level display text in the sidebar that reads This card will be used for future renewals of existing purchases. and when the form is submitted, it assigns the newly added payment method to all existing subscriptions.

This PR adds a checkbox (defaulting to checked) to the form which allows the user to decide if they want to do that, or if they just want to add a card and assign it later. It moves the sidebar warning inline just underneath the submit button, and changes the warning's text if the checkbox is not checked.

NOTE Once #49897 is merged, this PR will include the site-level form as well. Since this PR removes the sidebar warning that the card will be used for all subscriptions, we should wait to merge this until that is complete so that we make sure that we replace it with the checkbox on all the active forms at once. (We cannot keep the sidebar warning because it is a React sibling of the PaymentMethodSelector where the checkbox lives and has no way to know the state of the checkbox.) That said, no changes will be needed to this PR to support that form, so this can be reviewed now.

Fixes #50047

Screenshots

Before:

Screen Shot 2021-02-12 at 5 58 19 PM

After:

Screen Shot 2021-02-12 at 5 54 29 PM

Close-up of checkbox checked (note text after button):

Screen Shot 2021-02-12 at 5 54 56 PM

Close-up of checkbox unchecked (note text after button):

Screen Shot 2021-02-12 at 5 54 49 PM

Testing instructions

  • Use a site that has at least one subscription.
  • Visit http://calypso.localhost:3000/me/purchases/add-payment-method and verify that you see the checkbox mentioned.
  • Add a new card (if your API is sandboxed you can use a stripe test card with a unique last 4 digits so you can more easily tell the cards apart) using the form and leave the checkbox checked.
  • Verify that the form submits correctly, and that your subscription has the new card assigned to it.
  • Repeat the above steps with a new card, but uncheck the box.
  • Verify that the form submits correctly, and that your subscription does not have the card assigned to it.
  • Verify that the new card shows up in the list of payment methods on http://calypso.localhost:3000/me/purchases/payment-methods

@matticbot
Copy link
Contributor

@matticbot
Copy link
Contributor

matticbot commented Feb 12, 2021

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~320 bytes added 📈 [gzipped])

name            parsed_size           gzip_size
purchases           +1133 B  (+0.1%)     +320 B  (+0.1%)
site-purchases      +1064 B  (+0.1%)     +288 B  (+0.1%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@sirbrillig sirbrillig marked this pull request as ready for review February 12, 2021 23:02
@sirbrillig sirbrillig requested a review from a team as a code owner February 12, 2021 23:02
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Feb 12, 2021
@sirbrillig sirbrillig self-assigned this Feb 12, 2021
@sirbrillig sirbrillig added [Estimate] 3 [Feature Group] WPCOM Store & Purchases All things billing on WordPress.com. This includes the backend store, plans, and billing management. labels Feb 12, 2021
@michaeldcain michaeldcain added the [Status] Needs Design Review Add this when you'd like to get a review / feedback from the Design team on your PR label Feb 15, 2021
@sirbrillig
Copy link
Member Author

sirbrillig commented Feb 15, 2021

Thanks to @michaeldcain, I realized that if we try to display the form when stripe fails to load, you will just see a loading screen forever.

I added code to display stripe errors, although it will need to be migrated to other places using PaymentMethodSelector also if they have their own custom loading component.

Screen Shot 2021-02-15 at 12 37 44 PM

UPDATE: added the same guard to site-level payments as part of #49897 and I believe that the change payment method forms don't need it.

Copy link
Member

@michaeldcain michaeldcain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works well for me and LGTM. I added a card with the checkbox selected and it properly assigned the payment method. I added another with it unselected and it properly added it to the account, unassigned. I was then able to assign the new method from different subscription setting pages.

I pushed a slight design change to group the warning and checkbox together. I think it's good enough to ship if we need to change it, we can do it in a future PR.

assign-checkbox

@michaeldcain michaeldcain added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Feb 15, 2021
@sirbrillig sirbrillig removed the [Status] Needs Design Review Add this when you'd like to get a review / feedback from the Design team on your PR label Feb 16, 2021
@sirbrillig sirbrillig force-pushed the add/assign-all-subscriptions-checkbox branch from ec1692b to deaf661 Compare February 16, 2021 22:50
@sirbrillig
Copy link
Member Author

Rebase now that #49897 is merged, just to be able to test site-level forms also.

@sirbrillig
Copy link
Member Author

Seems to work well with the site-level form. I'll merge it tomorrow.

@sirbrillig sirbrillig merged commit eb5b6d3 into trunk Feb 17, 2021
@sirbrillig sirbrillig deleted the add/assign-all-subscriptions-checkbox branch February 17, 2021 17:22
@a8ci18n
Copy link

a8ci18n commented Feb 17, 2021

This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/5531771

Thank you @sirbrillig for including a screenshot in the description! This is really helpful for our translators.

@a8ci18n
Copy link

a8ci18n commented Feb 25, 2021

Translation for this Pull Request has now been finished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Estimate] 3 [Feature Group] WPCOM Store & Purchases All things billing on WordPress.com. This includes the backend store, plans, and billing management.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Billing: Add checkbox (pre-selected) to "assign this payment method to all of my purchases"
4 participants