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

Checkout: Remove siteId check from stored card prepurchase validation #48632

Merged
merged 1 commit into from
Dec 31, 2020

Conversation

nbloomf
Copy link
Contributor

@nbloomf nbloomf commented Dec 30, 2020

Changes proposed in this Pull Request

A siteId is indeed required by the transaction endpoint; however for siteless checkout the corresponding no-site id value and related properties like create_new_site are added in createTransactionEndpointRequestPayloadFromLineItems, after this validation check happens.

With this check in place, when the siteId is not set we throw an error before getting to the code that cleans up the transaction payload. Removing this check has no effect on purchases with a site ID, and allows siteless purchases to proceed.

I think this regression was added in #48069 (which I reviewed 😬), and I missed it at the time because I didn't test it with the siteless flow. It is hard to keep track of which flows can be affected by what changes!

Testing instructions

We need to check two things: (1) that siteless purchases with a stored card succeed or fail as expected, and (2) that non-siteless (siteful?) purchases with a stored card are not affected.

  • To test the siteless flow, navigate to /domains, choose a domain, and when prompted to select a plan opt for "Just a domain". Once in checkout, verify that you can complete the purchase with a stored card.
  • To test the siteful flow, enter checkout with some product on either an existing site or a new site and make sure you can check out with a stored card.

A siteId is indeed required by the transaction endpoint; however for siteless checkout
the corresponding `no-site` id value is added in createTransactionEndpointRequestPayloadFromLineItems,
_after_ this validation check happens.

With this check in place, when the siteId is not set we throw an error before getting to the code that
cleans up the transaction payload.
@nbloomf nbloomf added [Type] Bug [Feature] Checkout The checkout screen and process for purchases made on WordPress.com. [Feature Group] Emails & Domains Features related to email integrations and domain management. labels Dec 30, 2020
@nbloomf nbloomf requested a review from a team December 30, 2020 21:51
@nbloomf nbloomf self-assigned this Dec 30, 2020
@matticbot
Copy link
Contributor

@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 Dec 30, 2020
@matticbot
Copy link
Contributor

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

Sections (~13 bytes removed 📉 [gzipped])

name      parsed_size           gzip_size
checkout        -82 B  (-0.0%)      -13 B  (-0.0%)

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

Async-loaded Components (~11 bytes removed 📉 [gzipped])

name                                             parsed_size           gzip_size
async-load-calypso-blocks-editor-checkout-modal        -82 B  (-0.0%)      -11 B  (-0.0%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

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.

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 as expected for both existing users and new users. Also, checking out with and without a site.

@michaeldcain michaeldcain merged commit 6e064ff into trunk Dec 31, 2020
@michaeldcain michaeldcain deleted the fix/domain-only-purchase-regression-in-checkout branch December 31, 2020 00:10
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Dec 31, 2020
@sirbrillig
Copy link
Member

Thanks for fixing this! I think we should also change the TS types to reflect siteId being optional. It is already optional in TransactionRequestWithLineItems but is made required by ExistingCardTransactionRequestWithLineItems. I believe all we need to do to make this match is to remove siteId from the latter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Checkout The checkout screen and process for purchases made on WordPress.com. [Feature Group] Emails & Domains Features related to email integrations and domain management. [Type] Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants