Skip to content

Conversation

@bimsonz
Copy link

@bimsonz bimsonz commented Dec 9, 2025

  • Reuse existing ADDRESS_SPECIFICATIONS labels for each country in PARTIAL_ADDRESS_SCHEMA
  • Ensures consistency between full and partial billing address modes
  • US shows "Zip Code", other countries show "Postcode" or default "Postal Code"
  • Add comprehensive tests for partial address mode specifications

This fixes an issue where partial billing address mode always showed "Zip Code" regardless of country, while full mode correctly regionalized the label.

📋 Pull Request Checklist

  • I have added unit tests to cover my changes.
  • I have added or updated Storybook stories where applicable.
  • I have tested the changes manually in the local environment.
  • I have checked that no PII data is being sent on analytics events
  • All E2E tests are passing, and I have added new tests if necessary.
  • All interfaces and types introduced or updated are strictly typed.

📝 Summary

This PR fixes postal code label regionalization in partial billing address
mode. Previously, labels were not correctly regionalized because the country
wasn't being passed to the label lookup.

Changes

Commit 1 (6fd9c70): Reuse ADDRESS_SPECIFICATIONS labels in
PARTIAL_ADDRESS_SCHEMA
Commit 2 (8c24be9): Refactor to dynamically generate schema + add tests
Commit 3 (a91c208): Pass merchant country to FieldContainer for label lookup

Changelog note: Fixed partial billing address mode to display regionalized
postal code labels (US shows "Zip code", others show "Postal code")


🧪 Tested scenarios

Manual Test Scenarios

To test, modify packages/playground/src/pages/Cards/Cards.js around line
228:

Test 1: US Country

window.avsPartialCard = new Card(checkout, {
    brands: ['mc', 'visa', 'amex', 'bcmc', 'maestro'],
    billingAddressRequired: true,
    billingAddressMode: 'partial',
    data: {
        billingAddress: {
            country: 'US'
        }
    }
}).mount('.card-avs-partial-field');

Expected: Label shows "Zip code"

Screenshot 2025-12-16 at 17 19 32

Test 2: Non-US Country (e.g., GB)

window.avsPartialCard = new Card(checkout, {
    brands: ['mc', 'visa', 'amex', 'bcmc', 'maestro'],
    billingAddressRequired: true,
    billingAddressMode: 'partial',
    data: {
        billingAddress: {
            country: 'GB'
        }
    }
}).mount('.card-avs-partial-field');

Expected: Label shows "Postal code"

Screenshot 2025-12-16 at 17 22 17

🔗 Related GitHub Issue / Internal Ticket number

Closes:


- Reuse existing ADDRESS_SPECIFICATIONS labels for each country in PARTIAL_ADDRESS_SCHEMA
- Ensures consistency between full and partial billing address modes
- US shows "Zip Code", other countries show "Postcode" or default "Postal Code"
- Add comprehensive tests for partial address mode specifications

This fixes an issue where partial billing address mode always showed "Zip Code"
regardless of country, while full mode correctly regionalized the label.
@bimsonz bimsonz requested a review from a team as a code owner December 9, 2025 21:52
@bimsonz bimsonz requested a review from ScottiBR December 9, 2025 21:52
@netlify
Copy link

netlify bot commented Dec 9, 2025

👷 Deploy request for adyen-web pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit a91c208

@changeset-bot
Copy link

changeset-bot bot commented Dec 9, 2025

⚠️ No Changeset found

Latest commit: a91c208

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @bimsonz, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an inconsistency in the billing address forms where the partial address mode failed to regionalize postal code labels, always defaulting to "Zip Code". By integrating the existing country-specific address specifications into the partial address schema, this change ensures that postal code labels are correctly displayed according to the selected country, aligning its behavior with the full billing address mode. This enhancement improves user experience by providing accurate and localized terminology.

Highlights

  • Regionalized Postal Code Labels: The partial billing address mode now correctly displays country-specific labels for postal codes (e.g., "Zip Code" for US, "Postcode" or "Postal Code" for others), resolving a previous inconsistency.
  • Consistency Across Address Modes: This change ensures that the partial billing address mode behaves consistently with the full billing address mode regarding postal code label regionalization, providing a more uniform user experience.
  • Improved PARTIAL_ADDRESS_SCHEMA: The PARTIAL_ADDRESS_SCHEMA has been updated to explicitly reference existing ADDRESS_SPECIFICATIONS for country-specific labels, rather than relying on a generic 'zipCode' default.
  • New Test Coverage: Comprehensive tests have been added to validate the correct regionalization of postal code labels and schema structure within the partial address mode for various countries.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly regionalizes the postal code labels for the partial billing address mode by reusing the main address specifications, fixing an inconsistency where 'Zip Code' was always shown. The added tests are comprehensive and validate the fix. I've provided a few suggestions to improve the maintainability of both the configuration and the new tests by reducing code duplication. Overall, this is a solid improvement.

Comment on lines 69 to 94
export const PARTIAL_ADDRESS_SCHEMA: AddressSpecifications = {
AU: {
labels: ADDRESS_SPECIFICATIONS.AU.labels,
schema: [POSTAL_CODE]
},
BR: {
labels: ADDRESS_SPECIFICATIONS.BR.labels,
schema: [POSTAL_CODE]
},
CA: {
labels: ADDRESS_SPECIFICATIONS.CA.labels,
schema: [POSTAL_CODE]
},
GB: {
labels: ADDRESS_SPECIFICATIONS.GB.labels,
schema: [POSTAL_CODE]
},
US: {
labels: ADDRESS_SPECIFICATIONS.US.labels,
schema: [POSTAL_CODE]
},
default: {
labels: {
[POSTAL_CODE]: 'zipCode'
},
labels: ADDRESS_SPECIFICATIONS.default.labels,
schema: [POSTAL_CODE]
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The definition of PARTIAL_ADDRESS_SCHEMA is quite repetitive. To improve maintainability and reduce code duplication, you could generate this object dynamically from ADDRESS_SPECIFICATIONS. This would ensure that any future additions to ADDRESS_SPECIFICATIONS are automatically reflected in the partial schema.

export const PARTIAL_ADDRESS_SCHEMA: AddressSpecifications = Object.keys(ADDRESS_SPECIFICATIONS).reduce((acc, countryCode) => {
    acc[countryCode] = {
        labels: ADDRESS_SPECIFICATIONS[countryCode].labels,
        schema: [POSTAL_CODE]
    };
    return acc;
}, {});

Comment on lines 77 to 97
test('should use default postalCode label for GB in partial mode', () => {
expect(partialSpecifications.getKeyForField('postalCode', 'GB')).toBe('postalCode');
});

test('should use default postalCode label for CA in partial mode', () => {
expect(partialSpecifications.getKeyForField('postalCode', 'CA')).toBe('postalCode');
});

test('should use default postalCode label for AU in partial mode', () => {
expect(partialSpecifications.getKeyForField('postalCode', 'AU')).toBe('postalCode');
});

test('should use default postalCode label for BR in partial mode', () => {
expect(partialSpecifications.getKeyForField('postalCode', 'BR')).toBe('postalCode');
});

test('should use default postalCode label for unspecified countries in partial mode', () => {
expect(partialSpecifications.getKeyForField('postalCode', 'FR')).toBe('postalCode');
expect(partialSpecifications.getKeyForField('postalCode', 'DE')).toBe('postalCode');
expect(partialSpecifications.getKeyForField('postalCode', 'NL')).toBe('postalCode');
});
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

These tests all check for the same outcome ('postalCode') for different countries. You can combine them into a single parameterized test using test.each to reduce repetition and improve readability.

Suggested change
test('should use default postalCode label for GB in partial mode', () => {
expect(partialSpecifications.getKeyForField('postalCode', 'GB')).toBe('postalCode');
});
test('should use default postalCode label for CA in partial mode', () => {
expect(partialSpecifications.getKeyForField('postalCode', 'CA')).toBe('postalCode');
});
test('should use default postalCode label for AU in partial mode', () => {
expect(partialSpecifications.getKeyForField('postalCode', 'AU')).toBe('postalCode');
});
test('should use default postalCode label for BR in partial mode', () => {
expect(partialSpecifications.getKeyForField('postalCode', 'BR')).toBe('postalCode');
});
test('should use default postalCode label for unspecified countries in partial mode', () => {
expect(partialSpecifications.getKeyForField('postalCode', 'FR')).toBe('postalCode');
expect(partialSpecifications.getKeyForField('postalCode', 'DE')).toBe('postalCode');
expect(partialSpecifications.getKeyForField('postalCode', 'NL')).toBe('postalCode');
});
test.each(['GB', 'CA', 'AU', 'BR', 'FR', 'DE', 'NL'])('should use default postalCode label for %s in partial mode', countryCode => {
expect(partialSpecifications.getKeyForField('postalCode', countryCode)).toBe('postalCode');
});

Comment on lines 99 to 103
test('partial schema should only contain postalCode field', () => {
expect(partialSpecifications.getAddressSchemaForCountryFlat('US')).toStrictEqual(['postalCode']);
expect(partialSpecifications.getAddressSchemaForCountryFlat('GB')).toStrictEqual(['postalCode']);
expect(partialSpecifications.getAddressSchemaForCountryFlat('FR')).toStrictEqual(['postalCode']);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This test can also be parameterized using test.each to avoid repeating assertions for different countries, making the test suite more concise.

    test.each(['US', 'GB', 'FR'])('partial schema for %s should only contain postalCode field', countryCode => {
        expect(partialSpecifications.getAddressSchemaForCountryFlat(countryCode)).toStrictEqual(['postalCode']);
    });

- Dynamically generate PARTIAL_ADDRESS_SCHEMA from ADDRESS_SPECIFICATIONS
- Use test.each for parameterized tests to reduce duplication
- Ensures future countries added to ADDRESS_SPECIFICATIONS are automatically included
@ScottiBR
Copy link
Contributor

Great job on the improvements, @bimsonz !

To finalize the PR, could you please beef up the description? We need to add:

  • Manual test scenarios (with screenshots) to show it working and how to test it.
  • The country list affect by this patch, so we can correctly note it in the changelog.

- Store merchant country in useRef, pass to FieldContainer for labels
- Include country in onChange output so parent maintains the value

In partial mode the form schema is [postalCode] only - adding country
would render an unwanted dropdown. Labels need country for regionalization
but it was not being passed through since it is not in form state.
@bimsonz
Copy link
Author

bimsonz commented Dec 16, 2025

Hey @ScottiBR i found an additional fix that was required to persist the country in partial mode when i was testing it in the playground.

I've updated the description and added manual testing steps along with screenshots.

Let me know if you need anything else.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants