Skip to content

[MKT_947]:feat/New checkout improves - #2077

Open
jaaaaavier wants to merge 11 commits into
masterfrom
feat/cloudflare-turnstile-integration
Open

[MKT_947]:feat/New checkout improves#2077
jaaaaavier wants to merge 11 commits into
masterfrom
feat/cloudflare-turnstile-integration

Conversation

@jaaaaavier

@jaaaaavier jaaaaavier commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Description

In this PR, we’ve improved the checkout process. Changes:

  • Until now, the postalCode was only required for a few countries, as it wasn’t always necessary, we used to dynamically display an input field that looked awful. We now retrieve this information from the widget used by Stripe.

  • The AvailableCryptoCurrenciesDropdown.tsx has been improved to make it clearer which cryptocurrency is intended for use. Furthermore, as payments with cryptocurrencies require the user’s first name, surname and address, we now dynamically display these fields, reusing the AddressElement previously used in the checkout process but integrated into this component.

  • Previously, when a user made a mistake whilst logging in at checkout (incorrect password, email already registered, etc.), we displayed an error showing the code, e.g. 409 now we display a short message that tells the user exactly what mistake they have made.

Related Issues

Related Pull Requests

Checklist

  • Changes have been tested locally.
  • Unit tests have been written or updated as necessary.
  • The code adheres to the repository's coding standards.
  • Relevant documentation has been added or updated.
  • No new warnings or errors have been introduced.
  • SonarCloud issues have been reviewed and addressed.
  • QA Passed

Testing Process

For testing purposes, I tried the following scenarios:

  • With a VPN to Canada: I verified that the card payment uses the ZIP code entered in the Stripe widget
  • Using a VPN to Canada, I verified that crypto payments request all the necessary information and proceed past the widget to complete the payment
  • Without a VPN, I verified that credit card payments work
  • Without a VPN, I verified that crypto payments request all the necessary information and proceed past the widget to complete the payment
  • I forced login errors and verified that text appears instead of an error code

Additional Notes

@jaaaaavier jaaaaavier self-assigned this Jul 28, 2026
@jaaaaavier jaaaaavier added the enhancement New feature or request label Jul 28, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 28, 2026

Copy link
Copy Markdown

Deploying drive-web with  Cloudflare Pages  Cloudflare Pages

Latest commit: e703909
Status: ✅  Deploy successful!
Preview URL: https://8a290992.drive-web.pages.dev
Branch Preview URL: https://feat-cloudflare-turnstile-in.drive-web.pages.dev

View logs

@jaaaaavier
jaaaaavier marked this pull request as ready for review July 28, 2026 10:11
</MenuItems>
</Transition>
</Menu>
{cryptoSelected && !isDropdownOpen && (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you extract that to a constant? Something like const shouldDisplayAddressElement = cryptoSelected && !isDropdownOpen;

options={CRYPTO_ADDRESS_ELEMENT_OPTIONS}
onChange={(event) => {
const { firstName, lastName, name, address } = event.value;
onUserNameChanges([firstName, lastName].filter(Boolean).join(' ').trim() || name);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Extract the filter/join/trim to a constant please.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As you added an object for the translation keys for the errors, why you did not use these keys to match it against the error? I mean, instead of doing:
expect(hookState.current.authError).toBe('checkout.authComponent.authError.invalidCredentials');

you can do:
expect(hookState.current.authError).toBe(AUTH_ERROR_TRANSLATION_KEY['invalidCredentials']);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay


try {
return await is2FANeeded(email);
} catch {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Log the error, just in case

} catch (err) {
const error = err as Error;
setAuthError(error.message);
errorService.reportError(err);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No need to report the error. There is no instrument. it just logs the error.

const { status } = errorService.castError(err);
const isTwoFactorEnabled = await isTwoFactorBlockingTheSignIn(email, authMethod, status);

setAuthError(translate(getAuthErrorTranslationKey({ status, authMethod, isTwoFactorEnabled })));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Try to not anidate a lot of things. Extract getAuthErrorTranslationKey to a constant, like: const errorKey = getAuthErrorTranslationKey and then:

const errorMessage = translate(errorKey);
setAuthError(errorMessage);

Comment on lines +98 to +110
{cryptoSelected && !isDropdownOpen && (
<div className="flex w-full flex-col gap-3">
<div className="flex w-full border-t border-gray-10" />
<AddressElement
options={CRYPTO_ADDRESS_ELEMENT_OPTIONS}
onChange={(event) => {
const { firstName, lastName, name, address } = event.value;
onUserNameChanges([firstName, lastName].filter(Boolean).join(' ').trim() || name);
onUserAddressChanges(address);
}}
/>
</div>
)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why did you move the AddressElement inside this component instead of handling it from the parent? I'm missing something? 🤔

Keep in mind that this component is the crypto currencies Dropdown. Not sure if this component should also handle the AddressElement.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The idea from the beginning was to remove the billing address, but for cryptocurrency payments, it's necessary to know the buyer's address as well as their first and last name. I decided to include it within the component and have it displayed only after the cryptocurrency is selected, since that made more sense to me than putting it in the parent component. I've checked this with Fran, and everything is correct.

Captura de pantalla 2026-07-28 a las 15 01 53

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rename the component then.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remember to rename the component @jaaaaavier

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renamed


if (currencyType === PaymentType['FIAT']) {
const { error: elementsError } = await elements.submit();
const { confirmationToken, error: confirmationTokenError } = await stripeSDK.createConfirmationToken({ elements });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How does it works? 🤔 When we need to pass the elements when currency is FIAT. Afaik, we only display the Elements when the currency is crypto isn't it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I use this confirmationToken to retrieve the ZIP code from the card payment widget created by Stripe. When a user from, say, Canada or the United States tries to make a purchase, they are automatically asked for their ZIP code, and we need it to correctly create the customer.

In the production environment right now, you can see that if you're in an area that requires a ZIP code, a new field appears for entering the ZIP code this was incorrect.

Captura de pantalla 2026-07-28 a las 14 57 20

@jaaaaavier
jaaaaavier requested a review from xabg2 July 28, 2026 14:48
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants