-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Registrationless checkout: Create account, new site, and process transaction #44234
Registrationless checkout: Create account, new site, and process transaction #44234
Conversation
…for the logged out checkout page
…nt and site creation endpoint is called by clicking the Pay button
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Webpack Runtime (~3971 bytes removed 📉 [gzipped])
Webpack runtime for loading modules. It is included in the HTML page as an inline script. Is downloaded and parsed every time the app is loaded. App Entrypoints (~95138 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~168749 bytes removed 📉 [gzipped])
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 (~19734 bytes added 📈 [gzipped])
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. Generated by performance advisor bot at iscalypsofastyet.com. |
…account-site-and-pay-userless-checkout
…account-site-and-pay-userless-checkout
client/my-sites/checkout/composite-checkout/payment-method-helpers.js
Outdated
Show resolved
Hide resolved
client/my-sites/checkout/composite-checkout/payment-method-helpers.js
Outdated
Show resolved
Hide resolved
client/my-sites/checkout/composite-checkout/payment-method-helpers.js
Outdated
Show resolved
Hide resolved
client/my-sites/checkout/composite-checkout/payment-method-helpers.js
Outdated
Show resolved
Hide resolved
client/my-sites/checkout/composite-checkout/payment-method-helpers.js
Outdated
Show resolved
Hide resolved
client/my-sites/checkout/composite-checkout/use-get-thank-you-url.js
Outdated
Show resolved
Hide resolved
…and isEmpty with native methods, and a variable name change
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 code looks good to me! I just haven't tested it yet, but that should happen soon.
Thank you again for the thorough testing instructions! Just a heads up - we have payment sandboxes in place so we can test specific processor responses without using real cards. Here's a list of stripe test cards: https://stripe.com/docs/testing. You just need to set a couple of constants on your sandbox; let me know if you'd like help with that. Here are the results of my initial testing. I didn't get through all the scenarios yet but already ran into a couple of issues. Scenario 1 (plan only with card success):
From here several things happened.
One note:
Scenario 1 (plan+domain with card success):
Scenario 2 (plan+domain with paypal success):
|
…t type errors out, then we still have the siteSlug in state when another payment type is tried
My guess is that this is happening because your incognito browser blocks third party cookies. This is a recent change from Chrome that enables blocking of third party cookies by default for incognito windows. So, with calypso URLs, wpcom cookies don't interact as expected. Please try disabling the option(check screenshot below) and let me know if it works for you i.e after payment succeeds you should be taken to /home and not the log in page.
TBH I'm not the biggest fan of the randomly generated names and I agree that it looks confusing. Right now it serves an important purpose and other flows are using it too(including Gutenboarding). Doing it a different way could be a project on its own though :)
The email field validation gets first priority, so if there's an email error, the other field errors won't show at first. I thought this would help give focus to email errors. This is especially in the case where the user has typed an existing email address and we ask them to log in because if they are going to log in, then showing the other field errors is distracting. If the email successfully validates, then other field errors will show and they do not get short circuited.
Disabling the setting to block third party cookies in your browser should fix this.
I use store sandbox for credit cards and also the sandbox mode for PayPal and other payment types. Thanks for surfacing this. |
Updates
|
Thanks for the suggestion @nbloomf . I've fixed this in the backend D45659-code. You should now receive emails of the form you mentioned. |
client/my-sites/checkout/composite-checkout/composite-checkout.js
Outdated
Show resolved
Hide resolved
…account-site-and-pay-userless-checkout
…account-site-and-pay-userless-checkout
@sirbrillig @DavidRothstein @nbloomf I think I've addressed all the review inputs on this PR, but please let me know if I missed anything. |
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.
Looks ok to me. I'll approve.
* When removing item from cart, also delete from localStorage * import/export getProductSlug * Define getProductSlug * If cart is empty, then redirect to the first signup flow step * default value should be an empty array * Remove products from localstorage with the cart response from server * If cart is emptied, then remove the site params prop saved in localstorage * Update the error message * If cart is emptied after site has been created already, then take to /plans page * Add note about usage of window.location * Modify the cart remove message for the logged out cart * Fix merge issues * Add isLoggedOutCart dependency * Registrationless checkout: Handle page reload scenarios (#44238) * 1. If /checkout/no-site is opened while logged in, then replace no-site with the siteSlug if there is only one site, else open site picker * Don't show sitepicker for the no-site route while logged in, unless there is a no-user query param * The path when clicking a site from the site selector should also include the query param. We need this when we append ?cart=no-user * The X button in the masterbar should take to /plans * Poll from localstorage if query param contains no-user value * url module import is restricted, but skipping the lint rule for this PR to avoid an unrelated refactor * Replace let by const * Add a missing / * Add trailing slash if missing * Refactor the / path * Enable logged out cart payments for saved cards and credits * Pass isLoggedOutCart prop to saved card processor * Registrationless checkout: Show Secure Checkout text (#44456) * Show Secure Checkout text and close button for the logged out checkout page * If the account and site is created, then take to /plans page * Refactor - use the sectionName variable instead of fetching the value from object * Remove the Sign Up and Log In links from the masterbar if on the registrationless checkout page. These links could be a distraction and we allow signup in the checkout form itself * Registrationless checkout: Transfer cart after log in to account with no site (#44475) * 1. Don't show site picker if logged in user has no site 2. Define a new flag isNoSiteCart that is used to determine the case where user is on checkout logged in but without a site * 1. If the user is logged in and without a site, then define the cart key as 'no-user' so that we can create a site for them first 2. Fetch cart from localstorage instead of doing a server get request if the user is logged in and without a site * Send flag to the create account to determine if a new site should be created * Send site slug if we're on the checkout page on an account that has no sites yet * Refactor createUserAndSiteBeforeTransaction to an options object for improved readability * Fix dependencies list * Modify the cart remove messaging for the case where we are on checkout in an account with no sites yet * Pass transactionOptions for saved cards and credits processors * Registrationless checkout: Show the help icon in the checkout page (#44477) * Set a position attribute for the recaptcha logo * Load the inline help icon for the logged out page * Show inline help only for the logged out checkout page * Move recaptcha badge to the bottom right, and increase its z-index so that it hides the wpcom floating help icon * cartKey should be siteSlug if in the logged out cart
…t page (#44231) * Init google recaptch on the logged out checkout page * Set recaptcha client ID in store * Move initGoogleRecaptcha to useEffect block * useEffect to call initGoogleRecaptcha only if cart has updated * Move the g-recaptcha div that is used to render the Recaptcha sticky logo to its own component. Also, memoize the component since we don't want re-renders of this component * Registrationless checkout: Create account, new site, and process transaction (#44234) * Send isLoggedOutCart prop to descendants * Call create account and site endpoint, and only then process payment for the logged out checkout page * Create account and site endpoint * Pass down isLoggedOutCart prop to descendants * Add reducers for the setSiteSlug state * siteSlug in the state * Update siteSlug value, since we would have a new siteSlug after account and site creation endpoint is called by clicking the Pay button * Define getRecaptchaClientId * Implemented review comments - removing try/catch, replace lodash get and isEmpty with native methods, and a variable name change * Disable lint for url import * Set site slug in the create account callback. This way, if one payment type errors out, then we still have the siteSlug in state when another payment type is tried * Use siteSlug as cart key if we are in the logged out checkout cart * Set the blog name as username hint, so that we don't create a random username * Reverting an auto lint fix * Remove an extra comma * Add isLoggedOutCart dependency * Send should_create_site flag * Registrationless checkout: Handle removing items from cart (#44236) * When removing item from cart, also delete from localStorage * import/export getProductSlug * Define getProductSlug * If cart is empty, then redirect to the first signup flow step * default value should be an empty array * Remove products from localstorage with the cart response from server * If cart is emptied, then remove the site params prop saved in localstorage * Update the error message * If cart is emptied after site has been created already, then take to /plans page * Add note about usage of window.location * Modify the cart remove message for the logged out cart * Fix merge issues * Add isLoggedOutCart dependency * Registrationless checkout: Handle page reload scenarios (#44238) * 1. If /checkout/no-site is opened while logged in, then replace no-site with the siteSlug if there is only one site, else open site picker * Don't show sitepicker for the no-site route while logged in, unless there is a no-user query param * The path when clicking a site from the site selector should also include the query param. We need this when we append ?cart=no-user * The X button in the masterbar should take to /plans * Poll from localstorage if query param contains no-user value * url module import is restricted, but skipping the lint rule for this PR to avoid an unrelated refactor * Replace let by const * Add a missing / * Add trailing slash if missing * Refactor the / path * Enable logged out cart payments for saved cards and credits * Pass isLoggedOutCart prop to saved card processor * Registrationless checkout: Show Secure Checkout text (#44456) * Show Secure Checkout text and close button for the logged out checkout page * If the account and site is created, then take to /plans page * Refactor - use the sectionName variable instead of fetching the value from object * Remove the Sign Up and Log In links from the masterbar if on the registrationless checkout page. These links could be a distraction and we allow signup in the checkout form itself * Registrationless checkout: Transfer cart after log in to account with no site (#44475) * 1. Don't show site picker if logged in user has no site 2. Define a new flag isNoSiteCart that is used to determine the case where user is on checkout logged in but without a site * 1. If the user is logged in and without a site, then define the cart key as 'no-user' so that we can create a site for them first 2. Fetch cart from localstorage instead of doing a server get request if the user is logged in and without a site * Send flag to the create account to determine if a new site should be created * Send site slug if we're on the checkout page on an account that has no sites yet * Refactor createUserAndSiteBeforeTransaction to an options object for improved readability * Fix dependencies list * Modify the cart remove messaging for the case where we are on checkout in an account with no sites yet * Pass transactionOptions for saved cards and credits processors * Registrationless checkout: Show the help icon in the checkout page (#44477) * Set a position attribute for the recaptcha logo * Load the inline help icon for the logged out page * Show inline help only for the logged out checkout page * Move recaptcha badge to the bottom right, and increase its z-index so that it hides the wpcom floating help icon * cartKey should be siteSlug if in the logged out cart
… present in the cart (#44229) * Add a default value for .ca cctld form * Refactor to use optional chaining * Registrationless checkout: Initialize Google Recaptcha on the checkout page (#44231) * Init google recaptch on the logged out checkout page * Set recaptcha client ID in store * Move initGoogleRecaptcha to useEffect block * useEffect to call initGoogleRecaptcha only if cart has updated * Move the g-recaptcha div that is used to render the Recaptcha sticky logo to its own component. Also, memoize the component since we don't want re-renders of this component * Registrationless checkout: Create account, new site, and process transaction (#44234) * Send isLoggedOutCart prop to descendants * Call create account and site endpoint, and only then process payment for the logged out checkout page * Create account and site endpoint * Pass down isLoggedOutCart prop to descendants * Add reducers for the setSiteSlug state * siteSlug in the state * Update siteSlug value, since we would have a new siteSlug after account and site creation endpoint is called by clicking the Pay button * Define getRecaptchaClientId * Implemented review comments - removing try/catch, replace lodash get and isEmpty with native methods, and a variable name change * Disable lint for url import * Set site slug in the create account callback. This way, if one payment type errors out, then we still have the siteSlug in state when another payment type is tried * Use siteSlug as cart key if we are in the logged out checkout cart * Set the blog name as username hint, so that we don't create a random username * Reverting an auto lint fix * Remove an extra comma * Add isLoggedOutCart dependency * Send should_create_site flag * Registrationless checkout: Handle removing items from cart (#44236) * When removing item from cart, also delete from localStorage * import/export getProductSlug * Define getProductSlug * If cart is empty, then redirect to the first signup flow step * default value should be an empty array * Remove products from localstorage with the cart response from server * If cart is emptied, then remove the site params prop saved in localstorage * Update the error message * If cart is emptied after site has been created already, then take to /plans page * Add note about usage of window.location * Modify the cart remove message for the logged out cart * Fix merge issues * Add isLoggedOutCart dependency * Registrationless checkout: Handle page reload scenarios (#44238) * 1. If /checkout/no-site is opened while logged in, then replace no-site with the siteSlug if there is only one site, else open site picker * Don't show sitepicker for the no-site route while logged in, unless there is a no-user query param * The path when clicking a site from the site selector should also include the query param. We need this when we append ?cart=no-user * The X button in the masterbar should take to /plans * Poll from localstorage if query param contains no-user value * url module import is restricted, but skipping the lint rule for this PR to avoid an unrelated refactor * Replace let by const * Add a missing / * Add trailing slash if missing * Refactor the / path * Enable logged out cart payments for saved cards and credits * Pass isLoggedOutCart prop to saved card processor * Registrationless checkout: Show Secure Checkout text (#44456) * Show Secure Checkout text and close button for the logged out checkout page * If the account and site is created, then take to /plans page * Refactor - use the sectionName variable instead of fetching the value from object * Remove the Sign Up and Log In links from the masterbar if on the registrationless checkout page. These links could be a distraction and we allow signup in the checkout form itself * Registrationless checkout: Transfer cart after log in to account with no site (#44475) * 1. Don't show site picker if logged in user has no site 2. Define a new flag isNoSiteCart that is used to determine the case where user is on checkout logged in but without a site * 1. If the user is logged in and without a site, then define the cart key as 'no-user' so that we can create a site for them first 2. Fetch cart from localstorage instead of doing a server get request if the user is logged in and without a site * Send flag to the create account to determine if a new site should be created * Send site slug if we're on the checkout page on an account that has no sites yet * Refactor createUserAndSiteBeforeTransaction to an options object for improved readability * Fix dependencies list * Modify the cart remove messaging for the case where we are on checkout in an account with no sites yet * Pass transactionOptions for saved cards and credits processors * Registrationless checkout: Show the help icon in the checkout page (#44477) * Set a position attribute for the recaptcha logo * Load the inline help icon for the logged out page * Show inline help only for the logged out checkout page * Move recaptcha badge to the bottom right, and increase its z-index so that it hides the wpcom floating help icon * cartKey should be siteSlug if in the logged out cart
* Add validation for the email field and show error message * Process error response from endpoint * Process error response from endpoint * Define import/export paths * Send request to validate signup email and validate response * Change Object to string array type * Show error message for the email field * Send flag to the email validation endpoint to identify the request as coming from userless checkout. This is needed to bypass the validation if the user is already logged in, as happens in the case where there's a payment error after account creation * Remove try catch block * 1. Refactor wpcomValidateSignupEmailt to remove unnecesssary try catch block 2. Copy update on the email taken error message 3. Added the signup email validation check in the validateContactDetails block * rename userless to registrationless * cartKey should be siteSlug if in the logged out cart * Registrationless checkout: Show checkout page if ccTLD domain item is present in the cart (#44229) * Add a default value for .ca cctld form * Refactor to use optional chaining * Registrationless checkout: Initialize Google Recaptcha on the checkout page (#44231) * Init google recaptch on the logged out checkout page * Set recaptcha client ID in store * Move initGoogleRecaptcha to useEffect block * useEffect to call initGoogleRecaptcha only if cart has updated * Move the g-recaptcha div that is used to render the Recaptcha sticky logo to its own component. Also, memoize the component since we don't want re-renders of this component * Registrationless checkout: Create account, new site, and process transaction (#44234) * Send isLoggedOutCart prop to descendants * Call create account and site endpoint, and only then process payment for the logged out checkout page * Create account and site endpoint * Pass down isLoggedOutCart prop to descendants * Add reducers for the setSiteSlug state * siteSlug in the state * Update siteSlug value, since we would have a new siteSlug after account and site creation endpoint is called by clicking the Pay button * Define getRecaptchaClientId * Implemented review comments - removing try/catch, replace lodash get and isEmpty with native methods, and a variable name change * Disable lint for url import * Set site slug in the create account callback. This way, if one payment type errors out, then we still have the siteSlug in state when another payment type is tried * Use siteSlug as cart key if we are in the logged out checkout cart * Set the blog name as username hint, so that we don't create a random username * Reverting an auto lint fix * Remove an extra comma * Add isLoggedOutCart dependency * Send should_create_site flag * Registrationless checkout: Handle removing items from cart (#44236) * When removing item from cart, also delete from localStorage * import/export getProductSlug * Define getProductSlug * If cart is empty, then redirect to the first signup flow step * default value should be an empty array * Remove products from localstorage with the cart response from server * If cart is emptied, then remove the site params prop saved in localstorage * Update the error message * If cart is emptied after site has been created already, then take to /plans page * Add note about usage of window.location * Modify the cart remove message for the logged out cart * Fix merge issues * Add isLoggedOutCart dependency * Registrationless checkout: Handle page reload scenarios (#44238) * 1. If /checkout/no-site is opened while logged in, then replace no-site with the siteSlug if there is only one site, else open site picker * Don't show sitepicker for the no-site route while logged in, unless there is a no-user query param * The path when clicking a site from the site selector should also include the query param. We need this when we append ?cart=no-user * The X button in the masterbar should take to /plans * Poll from localstorage if query param contains no-user value * url module import is restricted, but skipping the lint rule for this PR to avoid an unrelated refactor * Replace let by const * Add a missing / * Add trailing slash if missing * Refactor the / path * Enable logged out cart payments for saved cards and credits * Pass isLoggedOutCart prop to saved card processor * Registrationless checkout: Show Secure Checkout text (#44456) * Show Secure Checkout text and close button for the logged out checkout page * If the account and site is created, then take to /plans page * Refactor - use the sectionName variable instead of fetching the value from object * Remove the Sign Up and Log In links from the masterbar if on the registrationless checkout page. These links could be a distraction and we allow signup in the checkout form itself * Registrationless checkout: Transfer cart after log in to account with no site (#44475) * 1. Don't show site picker if logged in user has no site 2. Define a new flag isNoSiteCart that is used to determine the case where user is on checkout logged in but without a site * 1. If the user is logged in and without a site, then define the cart key as 'no-user' so that we can create a site for them first 2. Fetch cart from localstorage instead of doing a server get request if the user is logged in and without a site * Send flag to the create account to determine if a new site should be created * Send site slug if we're on the checkout page on an account that has no sites yet * Refactor createUserAndSiteBeforeTransaction to an options object for improved readability * Fix dependencies list * Modify the cart remove messaging for the case where we are on checkout in an account with no sites yet * Pass transactionOptions for saved cards and credits processors * Registrationless checkout: Show the help icon in the checkout page (#44477) * Set a position attribute for the recaptcha logo * Load the inline help icon for the logged out page * Show inline help only for the logged out checkout page * Move recaptcha badge to the bottom right, and increase its z-index so that it hides the wpcom floating help icon * cartKey should be siteSlug if in the logged out cart
…4211) * Do not query support history for logged out cart * Do not query support history for logged out cart * Send isLoggedOutCart to the contact fields component * Modify UI of billing info section as per the latest UI screen * Send isLoggedOutCart prop to the WPCheckout component * Send isLoggedOutCart prop to the WPContactForm component * Render email field when there is no domain in cart * Update email when the value is updated in the form field * Update email when the value is updated in the form field * Send isLoggedOutCart flag to descendants * Fetch locale from cookie for the logged out cart, and pass logged out cart flag as prop to descendants * Add email field description for the domain contact info section * Hide explanation if there's an error * Registrationless checkout: Add email field validation (#44227) * Add validation for the email field and show error message * Process error response from endpoint * Process error response from endpoint * Define import/export paths * Send request to validate signup email and validate response * Change Object to string array type * Show error message for the email field * Send flag to the email validation endpoint to identify the request as coming from userless checkout. This is needed to bypass the validation if the user is already logged in, as happens in the case where there's a payment error after account creation * Remove try catch block * 1. Refactor wpcomValidateSignupEmailt to remove unnecesssary try catch block 2. Copy update on the email taken error message 3. Added the signup email validation check in the validateContactDetails block * rename userless to registrationless * cartKey should be siteSlug if in the logged out cart * Registrationless checkout: Show checkout page if ccTLD domain item is present in the cart (#44229) * Add a default value for .ca cctld form * Refactor to use optional chaining * Registrationless checkout: Initialize Google Recaptcha on the checkout page (#44231) * Init google recaptch on the logged out checkout page * Set recaptcha client ID in store * Move initGoogleRecaptcha to useEffect block * useEffect to call initGoogleRecaptcha only if cart has updated * Move the g-recaptcha div that is used to render the Recaptcha sticky logo to its own component. Also, memoize the component since we don't want re-renders of this component * Registrationless checkout: Create account, new site, and process transaction (#44234) * Send isLoggedOutCart prop to descendants * Call create account and site endpoint, and only then process payment for the logged out checkout page * Create account and site endpoint * Pass down isLoggedOutCart prop to descendants * Add reducers for the setSiteSlug state * siteSlug in the state * Update siteSlug value, since we would have a new siteSlug after account and site creation endpoint is called by clicking the Pay button * Define getRecaptchaClientId * Implemented review comments - removing try/catch, replace lodash get and isEmpty with native methods, and a variable name change * Disable lint for url import * Set site slug in the create account callback. This way, if one payment type errors out, then we still have the siteSlug in state when another payment type is tried * Use siteSlug as cart key if we are in the logged out checkout cart * Set the blog name as username hint, so that we don't create a random username * Reverting an auto lint fix * Remove an extra comma * Add isLoggedOutCart dependency * Send should_create_site flag * Registrationless checkout: Handle removing items from cart (#44236) * When removing item from cart, also delete from localStorage * import/export getProductSlug * Define getProductSlug * If cart is empty, then redirect to the first signup flow step * default value should be an empty array * Remove products from localstorage with the cart response from server * If cart is emptied, then remove the site params prop saved in localstorage * Update the error message * If cart is emptied after site has been created already, then take to /plans page * Add note about usage of window.location * Modify the cart remove message for the logged out cart * Fix merge issues * Add isLoggedOutCart dependency * Registrationless checkout: Handle page reload scenarios (#44238) * 1. If /checkout/no-site is opened while logged in, then replace no-site with the siteSlug if there is only one site, else open site picker * Don't show sitepicker for the no-site route while logged in, unless there is a no-user query param * The path when clicking a site from the site selector should also include the query param. We need this when we append ?cart=no-user * The X button in the masterbar should take to /plans * Poll from localstorage if query param contains no-user value * url module import is restricted, but skipping the lint rule for this PR to avoid an unrelated refactor * Replace let by const * Add a missing / * Add trailing slash if missing * Refactor the / path * Enable logged out cart payments for saved cards and credits * Pass isLoggedOutCart prop to saved card processor * Registrationless checkout: Show Secure Checkout text (#44456) * Show Secure Checkout text and close button for the logged out checkout page * If the account and site is created, then take to /plans page * Refactor - use the sectionName variable instead of fetching the value from object * Remove the Sign Up and Log In links from the masterbar if on the registrationless checkout page. These links could be a distraction and we allow signup in the checkout form itself * Registrationless checkout: Transfer cart after log in to account with no site (#44475) * 1. Don't show site picker if logged in user has no site 2. Define a new flag isNoSiteCart that is used to determine the case where user is on checkout logged in but without a site * 1. If the user is logged in and without a site, then define the cart key as 'no-user' so that we can create a site for them first 2. Fetch cart from localstorage instead of doing a server get request if the user is logged in and without a site * Send flag to the create account to determine if a new site should be created * Send site slug if we're on the checkout page on an account that has no sites yet * Refactor createUserAndSiteBeforeTransaction to an options object for improved readability * Fix dependencies list * Modify the cart remove messaging for the case where we are on checkout in an account with no sites yet * Pass transactionOptions for saved cards and credits processors * Registrationless checkout: Show the help icon in the checkout page (#44477) * Set a position attribute for the recaptcha logo * Load the inline help icon for the logged out page * Show inline help only for the logged out checkout page * Move recaptcha badge to the bottom right, and increase its z-index so that it hides the wpcom floating help icon * cartKey should be siteSlug if in the logged out cart
#44209) * Add route for /checkout/no-site to open for logged out users * If in the logged out checkout page, then poll cart by building products from localstorage, instead of getting cart from server * For logged out Calypso pages, set the locale from slug * Fix route * If the checkout page is opened logged out, then do not query for stored cards and build shopping cart from localstorage * If in the logged out checkout page, then poll cart by building products from localstorage, instead of getting cart from server * Fix support history state * Do not query the saved cards endpoint when logged out * Do not query the saved cards endpoint when logged out * Add conditional check for the tax key, since cart from local store will not have the tax field * Add conditional check for the tax key, since cart from local store will not have the tax field * Add conditional check for the tax key for tests to pass * Update * Default value should be empty array * Fix test errors * Pass down props isLoggedOutCart to descendants * Convert raw response only if cart items exists * 1. Fix tests 2. Get location from cookie * Fix lint errors * Fix lint error * Instead of passing the cart from Cartstore to a function, directly resolve the promise. If the Cartstore does not have a cart value, then fetch from server * Remove prop not used in the function * Remove <QueryStoredCards /> since useStoredCards performs its own fetch * Add cartRawResponse as a dependency to useEffect * Fix dependencies * Use getCart prop to handle fetching logged-out cart instead * Remove unnecessary changes to useShoppingCart These should have no functional benefit and can be done later. * getCart should return a resolved promise * url module import is restricted, but skipping the lint rule for this PR to avoid an unrelated refactor * Do not display Site name in order review summary if no site is created yet * Merge from add/new-signup-flow-userless-checkout-1 * Registrationless checkout: Add email ID field with the new design (#44211) * Do not query support history for logged out cart * Do not query support history for logged out cart * Send isLoggedOutCart to the contact fields component * Modify UI of billing info section as per the latest UI screen * Send isLoggedOutCart prop to the WPCheckout component * Send isLoggedOutCart prop to the WPContactForm component * Render email field when there is no domain in cart * Update email when the value is updated in the form field * Update email when the value is updated in the form field * Send isLoggedOutCart flag to descendants * Fetch locale from cookie for the logged out cart, and pass logged out cart flag as prop to descendants * Add email field description for the domain contact info section * Hide explanation if there's an error * Registrationless checkout: Add email field validation (#44227) * Add validation for the email field and show error message * Process error response from endpoint * Process error response from endpoint * Define import/export paths * Send request to validate signup email and validate response * Change Object to string array type * Show error message for the email field * Send flag to the email validation endpoint to identify the request as coming from userless checkout. This is needed to bypass the validation if the user is already logged in, as happens in the case where there's a payment error after account creation * Remove try catch block * 1. Refactor wpcomValidateSignupEmailt to remove unnecesssary try catch block 2. Copy update on the email taken error message 3. Added the signup email validation check in the validateContactDetails block * rename userless to registrationless * cartKey should be siteSlug if in the logged out cart * Registrationless checkout: Show checkout page if ccTLD domain item is present in the cart (#44229) * Add a default value for .ca cctld form * Refactor to use optional chaining * Registrationless checkout: Initialize Google Recaptcha on the checkout page (#44231) * Init google recaptch on the logged out checkout page * Set recaptcha client ID in store * Move initGoogleRecaptcha to useEffect block * useEffect to call initGoogleRecaptcha only if cart has updated * Move the g-recaptcha div that is used to render the Recaptcha sticky logo to its own component. Also, memoize the component since we don't want re-renders of this component * Registrationless checkout: Create account, new site, and process transaction (#44234) * Send isLoggedOutCart prop to descendants * Call create account and site endpoint, and only then process payment for the logged out checkout page * Create account and site endpoint * Pass down isLoggedOutCart prop to descendants * Add reducers for the setSiteSlug state * siteSlug in the state * Update siteSlug value, since we would have a new siteSlug after account and site creation endpoint is called by clicking the Pay button * Define getRecaptchaClientId * Implemented review comments - removing try/catch, replace lodash get and isEmpty with native methods, and a variable name change * Disable lint for url import * Set site slug in the create account callback. This way, if one payment type errors out, then we still have the siteSlug in state when another payment type is tried * Use siteSlug as cart key if we are in the logged out checkout cart * Set the blog name as username hint, so that we don't create a random username * Reverting an auto lint fix * Remove an extra comma * Add isLoggedOutCart dependency * Send should_create_site flag * Registrationless checkout: Handle removing items from cart (#44236) * When removing item from cart, also delete from localStorage * import/export getProductSlug * Define getProductSlug * If cart is empty, then redirect to the first signup flow step * default value should be an empty array * Remove products from localstorage with the cart response from server * If cart is emptied, then remove the site params prop saved in localstorage * Update the error message * If cart is emptied after site has been created already, then take to /plans page * Add note about usage of window.location * Modify the cart remove message for the logged out cart * Fix merge issues * Add isLoggedOutCart dependency * Registrationless checkout: Handle page reload scenarios (#44238) * 1. If /checkout/no-site is opened while logged in, then replace no-site with the siteSlug if there is only one site, else open site picker * Don't show sitepicker for the no-site route while logged in, unless there is a no-user query param * The path when clicking a site from the site selector should also include the query param. We need this when we append ?cart=no-user * The X button in the masterbar should take to /plans * Poll from localstorage if query param contains no-user value * url module import is restricted, but skipping the lint rule for this PR to avoid an unrelated refactor * Replace let by const * Add a missing / * Add trailing slash if missing * Refactor the / path * Enable logged out cart payments for saved cards and credits * Pass isLoggedOutCart prop to saved card processor * Registrationless checkout: Show Secure Checkout text (#44456) * Show Secure Checkout text and close button for the logged out checkout page * If the account and site is created, then take to /plans page * Refactor - use the sectionName variable instead of fetching the value from object * Remove the Sign Up and Log In links from the masterbar if on the registrationless checkout page. These links could be a distraction and we allow signup in the checkout form itself * Registrationless checkout: Transfer cart after log in to account with no site (#44475) * 1. Don't show site picker if logged in user has no site 2. Define a new flag isNoSiteCart that is used to determine the case where user is on checkout logged in but without a site * 1. If the user is logged in and without a site, then define the cart key as 'no-user' so that we can create a site for them first 2. Fetch cart from localstorage instead of doing a server get request if the user is logged in and without a site * Send flag to the create account to determine if a new site should be created * Send site slug if we're on the checkout page on an account that has no sites yet * Refactor createUserAndSiteBeforeTransaction to an options object for improved readability * Fix dependencies list * Modify the cart remove messaging for the case where we are on checkout in an account with no sites yet * Pass transactionOptions for saved cards and credits processors * Registrationless checkout: Show the help icon in the checkout page (#44477) * Set a position attribute for the recaptcha logo * Load the inline help icon for the logged out page * Show inline help only for the logged out checkout page * Move recaptcha badge to the bottom right, and increase its z-index so that it hides the wpcom floating help icon * cartKey should be siteSlug if in the logged out cart Co-authored-by: Payton Swick <payton@foolord.com>
#44209) * Add route for /checkout/no-site to open for logged out users * If in the logged out checkout page, then poll cart by building products from localstorage, instead of getting cart from server * For logged out Calypso pages, set the locale from slug * Fix route * If the checkout page is opened logged out, then do not query for stored cards and build shopping cart from localstorage * If in the logged out checkout page, then poll cart by building products from localstorage, instead of getting cart from server * Fix support history state * Do not query the saved cards endpoint when logged out * Do not query the saved cards endpoint when logged out * Add conditional check for the tax key, since cart from local store will not have the tax field * Add conditional check for the tax key, since cart from local store will not have the tax field * Add conditional check for the tax key for tests to pass * Update * Default value should be empty array * Fix test errors * Pass down props isLoggedOutCart to descendants * Convert raw response only if cart items exists * 1. Fix tests 2. Get location from cookie * Fix lint errors * Fix lint error * Instead of passing the cart from Cartstore to a function, directly resolve the promise. If the Cartstore does not have a cart value, then fetch from server * Remove prop not used in the function * Remove <QueryStoredCards /> since useStoredCards performs its own fetch * Add cartRawResponse as a dependency to useEffect * Fix dependencies * Use getCart prop to handle fetching logged-out cart instead * Remove unnecessary changes to useShoppingCart These should have no functional benefit and can be done later. * getCart should return a resolved promise * url module import is restricted, but skipping the lint rule for this PR to avoid an unrelated refactor * Do not display Site name in order review summary if no site is created yet * Merge from add/new-signup-flow-userless-checkout-1 * Registrationless checkout: Add email ID field with the new design (#44211) * Do not query support history for logged out cart * Do not query support history for logged out cart * Send isLoggedOutCart to the contact fields component * Modify UI of billing info section as per the latest UI screen * Send isLoggedOutCart prop to the WPCheckout component * Send isLoggedOutCart prop to the WPContactForm component * Render email field when there is no domain in cart * Update email when the value is updated in the form field * Update email when the value is updated in the form field * Send isLoggedOutCart flag to descendants * Fetch locale from cookie for the logged out cart, and pass logged out cart flag as prop to descendants * Add email field description for the domain contact info section * Hide explanation if there's an error * Registrationless checkout: Add email field validation (#44227) * Add validation for the email field and show error message * Process error response from endpoint * Process error response from endpoint * Define import/export paths * Send request to validate signup email and validate response * Change Object to string array type * Show error message for the email field * Send flag to the email validation endpoint to identify the request as coming from userless checkout. This is needed to bypass the validation if the user is already logged in, as happens in the case where there's a payment error after account creation * Remove try catch block * 1. Refactor wpcomValidateSignupEmailt to remove unnecesssary try catch block 2. Copy update on the email taken error message 3. Added the signup email validation check in the validateContactDetails block * rename userless to registrationless * cartKey should be siteSlug if in the logged out cart * Registrationless checkout: Show checkout page if ccTLD domain item is present in the cart (#44229) * Add a default value for .ca cctld form * Refactor to use optional chaining * Registrationless checkout: Initialize Google Recaptcha on the checkout page (#44231) * Init google recaptch on the logged out checkout page * Set recaptcha client ID in store * Move initGoogleRecaptcha to useEffect block * useEffect to call initGoogleRecaptcha only if cart has updated * Move the g-recaptcha div that is used to render the Recaptcha sticky logo to its own component. Also, memoize the component since we don't want re-renders of this component * Registrationless checkout: Create account, new site, and process transaction (#44234) * Send isLoggedOutCart prop to descendants * Call create account and site endpoint, and only then process payment for the logged out checkout page * Create account and site endpoint * Pass down isLoggedOutCart prop to descendants * Add reducers for the setSiteSlug state * siteSlug in the state * Update siteSlug value, since we would have a new siteSlug after account and site creation endpoint is called by clicking the Pay button * Define getRecaptchaClientId * Implemented review comments - removing try/catch, replace lodash get and isEmpty with native methods, and a variable name change * Disable lint for url import * Set site slug in the create account callback. This way, if one payment type errors out, then we still have the siteSlug in state when another payment type is tried * Use siteSlug as cart key if we are in the logged out checkout cart * Set the blog name as username hint, so that we don't create a random username * Reverting an auto lint fix * Remove an extra comma * Add isLoggedOutCart dependency * Send should_create_site flag * Registrationless checkout: Handle removing items from cart (#44236) * When removing item from cart, also delete from localStorage * import/export getProductSlug * Define getProductSlug * If cart is empty, then redirect to the first signup flow step * default value should be an empty array * Remove products from localstorage with the cart response from server * If cart is emptied, then remove the site params prop saved in localstorage * Update the error message * If cart is emptied after site has been created already, then take to /plans page * Add note about usage of window.location * Modify the cart remove message for the logged out cart * Fix merge issues * Add isLoggedOutCart dependency * Registrationless checkout: Handle page reload scenarios (#44238) * 1. If /checkout/no-site is opened while logged in, then replace no-site with the siteSlug if there is only one site, else open site picker * Don't show sitepicker for the no-site route while logged in, unless there is a no-user query param * The path when clicking a site from the site selector should also include the query param. We need this when we append ?cart=no-user * The X button in the masterbar should take to /plans * Poll from localstorage if query param contains no-user value * url module import is restricted, but skipping the lint rule for this PR to avoid an unrelated refactor * Replace let by const * Add a missing / * Add trailing slash if missing * Refactor the / path * Enable logged out cart payments for saved cards and credits * Pass isLoggedOutCart prop to saved card processor * Registrationless checkout: Show Secure Checkout text (#44456) * Show Secure Checkout text and close button for the logged out checkout page * If the account and site is created, then take to /plans page * Refactor - use the sectionName variable instead of fetching the value from object * Remove the Sign Up and Log In links from the masterbar if on the registrationless checkout page. These links could be a distraction and we allow signup in the checkout form itself * Registrationless checkout: Transfer cart after log in to account with no site (#44475) * 1. Don't show site picker if logged in user has no site 2. Define a new flag isNoSiteCart that is used to determine the case where user is on checkout logged in but without a site * 1. If the user is logged in and without a site, then define the cart key as 'no-user' so that we can create a site for them first 2. Fetch cart from localstorage instead of doing a server get request if the user is logged in and without a site * Send flag to the create account to determine if a new site should be created * Send site slug if we're on the checkout page on an account that has no sites yet * Refactor createUserAndSiteBeforeTransaction to an options object for improved readability * Fix dependencies list * Modify the cart remove messaging for the case where we are on checkout in an account with no sites yet * Pass transactionOptions for saved cards and credits processors * Registrationless checkout: Show the help icon in the checkout page (#44477) * Set a position attribute for the recaptcha logo * Load the inline help icon for the logged out page * Show inline help only for the logged out checkout page * Move recaptcha badge to the bottom right, and increase its z-index so that it hides the wpcom floating help icon * cartKey should be siteSlug if in the logged out cart Co-authored-by: Payton Swick <payton@foolord.com>
* Create A/B test for showing the userless checkout flow * Create new signup flow called onboarding-new for the userless checkout * Registrationless checkout: Show the checkout page for logged out users (#44209) * Registrationless checkout: Add email ID field with the new design (#44211) * Registrationless checkout: Add email field validation (#44227) * Registrationless checkout: Show checkout page if ccTLD domain item is present in the cart (#44229) * Registrationless checkout: Initialize Google Recaptcha on the checkout page (#44231) * Registrationless checkout: Create account, new site, and process transaction (#44234) * Registrationless checkout: Handle removing items from cart (#44236) * Registrationless checkout: Handle page reload scenarios (#44238) * Registrationless checkout: Show Secure Checkout text (#44456) * Registrationless checkout: Transfer cart after log in to account with no site (#44475) * Registrationless checkout: Show the help icon in the checkout page (#44477) * Create A/B test for showing the userless checkout flow * Don't assign to the composite checkout i18n test when in registrationless context * Update datestamp for the abtest Co-authored-by: Payton Swick <payton@foolord.com>
Changes proposed in this Pull Request
This is one among a set of stacked PRs that implements userless checkout A/B test. For more reading on the userless
checkout project, read pau2Xa-1hW-p2.
This PR implements the following:
Testing instructions
NOTE: Depends on D45659-code, so please apply this first.
Scenario 1 - Verify transaction is successful with a credit card
userlessCheckout
test.localstorage.shoppingCart
andlocalstorage.siteParams
in your browser consle and confirm that it's deleted.NOTE - Buying an eCommerce plan will need take to the Thank You page after transaction - this will be fixed in #44238
Scenario 2 - Verify transaction is successful with PayPal
NOTE - Canceling transaction from the paypal.com page will not work correctly with this PR, and it will be fixed in #44238
Scenario 3 - Verify recaptcha response is sent to account endpoint
g-recaptcha-response
prop having the recaptcha token value.Scenario 4 - Verify that after credit card payment error, account or site creation is not duplicated
Scenario 5 - Verify that after payment error, email ID change gives an appropriate behaviour
Scenario 6 - Verify coupon works