From f40dd36d8d35d9302a219f602fb30bd660a97d0b Mon Sep 17 00:00:00 2001 From: GHaberis Date: Tue, 22 Oct 2024 11:00:17 +0100 Subject: [PATCH 1/3] only throw Missing Billing State error if required --- .../assets/pages/[countryGroupId]/checkout.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/support-frontend/assets/pages/[countryGroupId]/checkout.tsx b/support-frontend/assets/pages/[countryGroupId]/checkout.tsx index bceae10c6d..a6e7bb1013 100644 --- a/support-frontend/assets/pages/[countryGroupId]/checkout.tsx +++ b/support-frontend/assets/pages/[countryGroupId]/checkout.tsx @@ -136,6 +136,7 @@ import { */ type PaymentMethod = LegacyPaymentMethod | 'StripeExpressCheckoutElement'; const countryId: IsoCountry = CountryHelper.detect(); +const countryGroupIdsRequiringBillingState = ['US', 'CA', 'AU']; function paymentMethodIsActive(paymentMethod: LegacyPaymentMethod) { return isSwitchOn( @@ -1172,7 +1173,10 @@ function CheckoutComponent({ event.billingDetails.address.postal_code, ); - if (!event.billingDetails?.address.state) { + if ( + !event.billingDetails?.address.state && + countryGroupIdsRequiringBillingState.includes(countryId) + ) { logException( "Could not find state from Stripe's billingDetails", { geoId, countryGroupId, countryId }, @@ -1347,7 +1351,7 @@ function CheckoutComponent({ * We require state for non-deliverable products as we use different taxes within those regions upstream * For deliverable products we take the state and zip code with the delivery address */} - {['US', 'CA', 'AU'].includes(countryId) && + {countryGroupIdsRequiringBillingState.includes(countryId) && !productDescription.deliverableTo && ( Date: Tue, 22 Oct 2024 11:09:48 +0100 Subject: [PATCH 2/3] small refactor --- support-frontend/assets/pages/[countryGroupId]/checkout.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/support-frontend/assets/pages/[countryGroupId]/checkout.tsx b/support-frontend/assets/pages/[countryGroupId]/checkout.tsx index a6e7bb1013..1d83d51ac3 100644 --- a/support-frontend/assets/pages/[countryGroupId]/checkout.tsx +++ b/support-frontend/assets/pages/[countryGroupId]/checkout.tsx @@ -136,7 +136,7 @@ import { */ type PaymentMethod = LegacyPaymentMethod | 'StripeExpressCheckoutElement'; const countryId: IsoCountry = CountryHelper.detect(); -const countryGroupIdsRequiringBillingState = ['US', 'CA', 'AU']; +const countryIdsRequiringBillingState = ['US', 'CA', 'AU']; function paymentMethodIsActive(paymentMethod: LegacyPaymentMethod) { return isSwitchOn( @@ -1175,7 +1175,7 @@ function CheckoutComponent({ if ( !event.billingDetails?.address.state && - countryGroupIdsRequiringBillingState.includes(countryId) + countryIdsRequiringBillingState.includes(countryId) ) { logException( "Could not find state from Stripe's billingDetails", @@ -1351,7 +1351,7 @@ function CheckoutComponent({ * We require state for non-deliverable products as we use different taxes within those regions upstream * For deliverable products we take the state and zip code with the delivery address */} - {countryGroupIdsRequiringBillingState.includes(countryId) && + {countryIdsRequiringBillingState.includes(countryId) && !productDescription.deliverableTo && ( Date: Tue, 22 Oct 2024 11:12:27 +0100 Subject: [PATCH 3/3] small refactor --- support-frontend/assets/pages/[countryGroupId]/checkout.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/support-frontend/assets/pages/[countryGroupId]/checkout.tsx b/support-frontend/assets/pages/[countryGroupId]/checkout.tsx index 1d83d51ac3..64b6011f52 100644 --- a/support-frontend/assets/pages/[countryGroupId]/checkout.tsx +++ b/support-frontend/assets/pages/[countryGroupId]/checkout.tsx @@ -136,7 +136,7 @@ import { */ type PaymentMethod = LegacyPaymentMethod | 'StripeExpressCheckoutElement'; const countryId: IsoCountry = CountryHelper.detect(); -const countryIdsRequiringBillingState = ['US', 'CA', 'AU']; +const countriesRequiringBillingState = ['US', 'CA', 'AU']; function paymentMethodIsActive(paymentMethod: LegacyPaymentMethod) { return isSwitchOn( @@ -1175,7 +1175,7 @@ function CheckoutComponent({ if ( !event.billingDetails?.address.state && - countryIdsRequiringBillingState.includes(countryId) + countriesRequiringBillingState.includes(countryId) ) { logException( "Could not find state from Stripe's billingDetails", @@ -1351,7 +1351,7 @@ function CheckoutComponent({ * We require state for non-deliverable products as we use different taxes within those regions upstream * For deliverable products we take the state and zip code with the delivery address */} - {countryIdsRequiringBillingState.includes(countryId) && + {countriesRequiringBillingState.includes(countryId) && !productDescription.deliverableTo && (