From 7f2b37240ecf04e3d7bb133f76c2fcc951025e61 Mon Sep 17 00:00:00 2001 From: julianajlk Date: Thu, 2 May 2024 15:53:37 -0400 Subject: [PATCH] fix: Remove postal code validation for DPM countries --- .../payment-form/CardHolderInformation.jsx | 9 ++--- .../CardHolderInformation.test.jsx | 2 +- .../payment-form/StripePaymentForm.jsx | 1 - .../payment-form/utils/form-validators.js | 37 ++----------------- 4 files changed, 8 insertions(+), 41 deletions(-) diff --git a/src/payment/checkout/payment-form/CardHolderInformation.jsx b/src/payment/checkout/payment-form/CardHolderInformation.jsx index 7dbae32d0..92fe1342f 100644 --- a/src/payment/checkout/payment-form/CardHolderInformation.jsx +++ b/src/payment/checkout/payment-form/CardHolderInformation.jsx @@ -59,9 +59,10 @@ export class CardHolderInformationComponent extends React.Component { } render() { - const { disabled, showBulkEnrollmentFields, isDynamicPaymentMethodsEnabled } = this.props; - const shouldRequirePostalCode = isPostalCodeRequired(this.state.selectedCountry, isDynamicPaymentMethodsEnabled) - && this.props.enableStripePaymentProcessor; + const { disabled, showBulkEnrollmentFields } = this.props; + const shouldRequirePostalCode = isPostalCodeRequired( + this.state.selectedCountry, + ) && this.props.enableStripePaymentProcessor; return (
@@ -277,14 +278,12 @@ CardHolderInformationComponent.propTypes = { intl: intlShape.isRequired, disabled: PropTypes.bool, enableStripePaymentProcessor: PropTypes.bool, - isDynamicPaymentMethodsEnabled: PropTypes.bool, showBulkEnrollmentFields: PropTypes.bool, }; CardHolderInformationComponent.defaultProps = { disabled: false, enableStripePaymentProcessor: false, - isDynamicPaymentMethodsEnabled: false, showBulkEnrollmentFields: false, }; diff --git a/src/payment/checkout/payment-form/CardHolderInformation.test.jsx b/src/payment/checkout/payment-form/CardHolderInformation.test.jsx index 2677badf3..07481b214 100644 --- a/src/payment/checkout/payment-form/CardHolderInformation.test.jsx +++ b/src/payment/checkout/payment-form/CardHolderInformation.test.jsx @@ -74,7 +74,7 @@ describe('', () => { fireEvent.change(screen.getByLabelText('Country (required)'), { target: { value: 'US' } }); expect(getCountryStatesMap).toHaveBeenCalledWith('US'); - expect(isPostalCodeRequired).toHaveBeenCalledWith('US', false); // DPM enabled added to the call + expect(isPostalCodeRequired).toHaveBeenCalledWith('US'); }); }); describe('purchasedForOrganization field', () => { diff --git a/src/payment/checkout/payment-form/StripePaymentForm.jsx b/src/payment/checkout/payment-form/StripePaymentForm.jsx index ac18cdebe..0a8d88aab 100644 --- a/src/payment/checkout/payment-form/StripePaymentForm.jsx +++ b/src/payment/checkout/payment-form/StripePaymentForm.jsx @@ -198,7 +198,6 @@ const StripePaymentForm = ({ showBulkEnrollmentFields={isBulkOrder} disabled={submitting} enableStripePaymentProcessor={enableStripePaymentProcessor} - isDynamicPaymentMethodsEnabled={isDynamicPaymentMethodsEnabled} />
{ }; // eslint-disable-next-line import/prefer-default-export -export function isPostalCodeRequired(selectedCountry, isDynamicPaymentMethodsEnabled) { - // Stripe recommends to have state and zip code since it can have a material effect on +export function isPostalCodeRequired(selectedCountry) { + // Stripe recommends to have state and zip code required since it can have a material effect on // our card authorization rates and fees that the card networks and issuers charge. - // 'CA', 'GB' and 'US' were alreay required prior to implementing Dynamic Payment Methods. - // The Stripe API also requires state and zip code for BNPL options (Affirm, Afterpay, Klarna) - // for the countries that these payment methods are compatible with. - let countryListRequiredPostalCode = []; - if (isDynamicPaymentMethodsEnabled) { - countryListRequiredPostalCode = [ - 'CA', // Affirm, Afterpay, Klarna - 'GB', // Afterpay, Klarna - 'US', // Affirm, Afterpay, Klarna - 'AU', // Afterpay, Klarna - 'AT', // Klarna - 'BE', // Klarna - 'CH', // Klarna - 'CZ', // Klarna - 'DE', // Klarna - 'DK', // Klarna - 'ES', // Klarna - 'FI', // Klarna - 'FR', // Klarna - 'GR', // Klarna - 'IE', // Klarna - 'IT', // Klarna - 'NL', // Klarna - 'NO', // Klarna - 'NZ', // Afterpay, Klarna - 'PL', // Klarna - 'PT', // Klarna - 'SE', // Klarna - ]; - } else { - countryListRequiredPostalCode = ['CA', 'GB', 'US']; - } + const countryListRequiredPostalCode = ['CA', 'GB', 'US']; const postalCodeRequired = countryListRequiredPostalCode.includes(selectedCountry);