Skip to content

Commit

Permalink
fix(payment): STRIPE-660 Disable state code mapping for Spain in Stri…
Browse files Browse the repository at this point in the history
…pe Link Address component
  • Loading branch information
PavlenkoM committed Feb 27, 2025
1 parent f39f018 commit 5762c2f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,18 @@ export default interface StripeUPEShippingInitializeOptions {
* @param country
* @param state
*/
getStripeState(country: string, state: string): string;
getStripeState(
country: string,
state: string,
isStripeStateMappingDisabledForES?: boolean,
): string;

/**
* Set the Stripe experiments to be used in checkout-js components;
* Stripe specific experiments broadcasts to SDK from payment provider configs request.
*
* @param experiments
* @returns void
*/
setStripeExperiments?(experiments: Record<string, boolean>): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default class StripeUPEShippingStrategy implements ShippingStrategy {
getStyles,
availableCountries,
getStripeState,
setStripeExperiments,
} = options.stripeupe;

Object.entries(options.stripeupe).forEach(([key, value]) => {
Expand All @@ -81,7 +82,11 @@ export default class StripeUPEShippingStrategy implements ShippingStrategy {
);
const paymentMethod = state.paymentMethods.getPaymentMethodOrThrow(methodId, gatewayId);
const {
initializationData: { stripePublishableKey, stripeConnectedAccount },
initializationData: {
stripePublishableKey,
stripeConnectedAccount,
isStripeStateMappingDisabledForES,
},
} = paymentMethod;

if (
Expand All @@ -92,6 +97,10 @@ export default class StripeUPEShippingStrategy implements ShippingStrategy {
throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);
}

setStripeExperiments?.({
isStripeStateMappingDisabledForES,
});

this._stripeUPEClient = await this._stripeUPEScriptLoader.getStripeClient(
stripePublishableKey,
stripeConnectedAccount,
Expand Down Expand Up @@ -174,7 +183,11 @@ export default class StripeUPEShippingStrategy implements ShippingStrategy {
} = shipping;
const stripeState =
stateOrProvinceCode && countryCode
? getStripeState(countryCode, stateOrProvinceCode)
? getStripeState(
countryCode,
stateOrProvinceCode,
isStripeStateMappingDisabledForES,
)
: stateOrProvinceCode;

option = {
Expand Down
1 change: 1 addition & 0 deletions packages/stripe-integration/src/stripe-upe/stripe-upe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ export interface StripeUPEInitializationData {
stripePublishableKey: string;
stripeConnectedAccount: string;
shopperLanguage: string;
isStripeStateMappingDisabledForES?: boolean;
}

export interface StripeElementUpdateOptions {
Expand Down

0 comments on commit 5762c2f

Please sign in to comment.