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: add renewal gift route #69769

Merged
merged 22 commits into from
Nov 7, 2022
Merged

Checkout: add renewal gift route #69769

merged 22 commits into from
Nov 7, 2022

Conversation

sirbrillig
Copy link
Member

@sirbrillig sirbrillig commented Nov 3, 2022

Proposed Changes

This PR adds a new checkout route of the form /checkout/:productSlugs/gift/:purchaseIds to enable gifting subscription renewals to other WordPress.com users (see pbOQVh-2wh-p2 for more details). An example URL might be /checkout/business-bundle-monthly,dotblog_domain/gift/10000,100001 to gift two products.

The new route works similarly to the current route for adding a renewal to the cart, which is /checkout/:productSlugs/renew/:purchaseIds/:domain. Both routes will attempt to add renewal products to the cart, but the gift route will allow adding a renewal for a different user. The user purchasing the gift does not need to have a WordPress.com site but does need to have an account.

Fixes https://github.com/Automattic/payments-shilling/issues/1194

(Most of this work was already prepared in the POC #69639 by @dylanrevisited)

Testing Instructions

You'll need two accounts and make sure that the store is sandboxed.

  • With account A, purchase a personal plan (or use an account which already owns a plan).
  • With account B, go to the following URL: /checkout/personal-bundle/gift/<ACCOUNT_A_SUBSCRIPTION_ID>. You can use Store Admin to find the subscription ID of the account A's plan.
  • Verify that you see the gift subscription in account B's shopping cart.

@sirbrillig sirbrillig self-assigned this Nov 3, 2022
@github-actions
Copy link

github-actions bot commented Nov 3, 2022

@matticbot
Copy link
Contributor

matticbot commented Nov 3, 2022

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

Sections (~168 bytes added 📈 [gzipped])

name                             parsed_size           gzip_size
checkout                              +628 B  (+0.0%)     +168 B  (+0.0%)
woocommerce-installation               +35 B  (+0.0%)      +13 B  (+0.0%)
woocommerce                            +35 B  (+0.0%)      +13 B  (+0.0%)
themes                                 +35 B  (+0.0%)      +13 B  (+0.0%)
theme                                  +35 B  (+0.0%)      +13 B  (+0.0%)
stats                                  +35 B  (+0.0%)      +13 B  (+0.0%)
site-purchases                         +35 B  (+0.0%)      +13 B  (+0.0%)
settings-writing                       +35 B  (+0.0%)      +13 B  (+0.0%)
settings-security                      +35 B  (+0.0%)      +13 B  (+0.0%)
settings-performance                   +35 B  (+0.0%)      +13 B  (+0.0%)
settings-jetpack                       +35 B  (+0.0%)      +13 B  (+0.0%)
settings-discussion                    +35 B  (+0.0%)      +13 B  (+0.0%)
settings                               +35 B  (+0.0%)      +13 B  (+0.0%)
scan                                   +35 B  (+0.0%)      +13 B  (+0.0%)
purchases                              +35 B  (+0.0%)      +13 B  (+0.0%)
promote-post                           +35 B  (+0.0%)      +13 B  (+0.0%)
preview                                +35 B  (+0.0%)      +13 B  (+0.0%)
posts-custom                           +35 B  (+0.0%)      +13 B  (+0.0%)
posts                                  +35 B  (+0.0%)      +13 B  (+0.0%)
plugins                                +35 B  (+0.0%)      +13 B  (+0.0%)
plans                                  +35 B  (+0.0%)      +13 B  (+0.0%)
people                                 +35 B  (+0.0%)      +13 B  (+0.0%)
pages                                  +35 B  (+0.0%)      +13 B  (+0.0%)
migrate                                +35 B  (+0.0%)      +13 B  (+0.0%)
media                                  +35 B  (+0.0%)      +13 B  (+0.0%)
marketplace                            +35 B  (+0.0%)      +13 B  (+0.0%)
marketing                              +35 B  (+0.0%)      +13 B  (+0.0%)
jetpack-social                         +35 B  (+0.0%)      +13 B  (+0.0%)
jetpack-search                         +35 B  (+0.0%)      +13 B  (+0.0%)
jetpack-connect                        +35 B  (+0.0%)      +13 B  (+0.0%)
jetpack-cloud-settings                 +35 B  (+0.0%)      +13 B  (+0.0%)
jetpack-cloud-pricing                  +35 B  (+0.0%)      +13 B  (+0.0%)
jetpack-cloud-plugin-management        +35 B  (+0.0%)      +13 B  (+0.0%)
jetpack-cloud                          +35 B  (+0.0%)      +13 B  (+0.0%)
import                                 +35 B  (+0.0%)      +13 B  (+0.0%)
hosting                                +35 B  (+0.0%)      +13 B  (+0.0%)
home                                   +35 B  (+0.0%)      +13 B  (+0.0%)
gutenberg-editor                       +35 B  (+0.0%)      +13 B  (+0.0%)
google-my-business                     +35 B  (+0.0%)      +13 B  (+0.0%)
export                                 +35 B  (+0.0%)      +13 B  (+0.0%)
email                                  +35 B  (+0.0%)      +13 B  (+0.0%)
earn                                   +35 B  (+0.0%)      +13 B  (+0.0%)
domains                                +35 B  (+0.0%)      +13 B  (+0.0%)
customize                              +35 B  (+0.0%)      +13 B  (+0.0%)
concierge                              +35 B  (+0.0%)      +13 B  (+0.0%)
comments                               +35 B  (+0.0%)      +13 B  (+0.0%)
backup                                 +35 B  (+0.0%)      +13 B  (+0.0%)
add-ons                                +35 B  (+0.0%)      +13 B  (+0.0%)
activity                               +35 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 (~41 bytes added 📈 [gzipped])

name                                             parsed_size           gzip_size
async-load-calypso-my-sites-checkout-modal            +202 B  (+0.0%)      +41 B  (+0.0%)
async-load-calypso-blocks-editor-checkout-modal       +202 B  (+0.0%)      +41 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.

@sirbrillig sirbrillig marked this pull request as ready for review November 3, 2022 23:52
@sirbrillig sirbrillig requested a review from a team as a code owner November 3, 2022 23:52
@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 Nov 3, 2022
@pottedmeat pottedmeat self-requested a review November 7, 2022 15:07
Copy link
Contributor

@pottedmeat pottedmeat left a comment

Choose a reason for hiding this comment

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

Code looks good, just have questions.

Testing:

  • Verified it asks me to log in if visiting when logged out
  • Did a full credit, partial credit with credit card, credit card, and PayPal purchase
  • Did a plan/domain combination purchase with credit card and PayPal
  • Plain/domain combination purchase did not complete the redirect for me
    • Screen Shot 2022-11-07 at 11 12 46 AM

const product = isJetpackCheckout
? context.params.productSlug
: getProductSlugFromContext( context );
const product = getProductSlugFromContext( context );
Copy link
Member Author

@sirbrillig sirbrillig Nov 7, 2022

Choose a reason for hiding this comment

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

This PR modifies getProductSlugFromContext() to support determining isJetpackCheckout on its own, which allows us to simplify this call.

NOTE: this will affect redirectJetpackLegacyPlans() which also calls getProductSlugFromContext(), but I think that should be fine since it's only used on non-Jetpack-siteless-checkout routes.

page(
`/checkout/jetpack/:productSlug`,
setLocaleMiddleware(),
noSite,
checkoutSiteless,
checkoutJetpackSiteless,
Copy link
Member Author

Choose a reason for hiding this comment

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

This PR renames this controller from checkoutSiteless to checkoutJetpackSiteless to clarify the difference between this route and other siteless checkout flows.

@sirbrillig
Copy link
Member Author

sirbrillig commented Nov 7, 2022

@pottedmeat could you give this another try just to make sure I didn't break anything?

Plain/domain combination purchase did not complete the redirect for me

When this happened, were there any errors in the console?

@pottedmeat
Copy link
Contributor

When this happened, were there any errors in the console?

No errors.

@sirbrillig sirbrillig merged commit 2c707ea into trunk Nov 7, 2022
@sirbrillig sirbrillig deleted the add/checkout-gift-route branch November 7, 2022 20:51
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 7, 2022
@sirbrillig
Copy link
Member Author

Plain/domain combination purchase did not complete the redirect for me

I've created #69833 to investigate this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants