Skip to content

fix: fix amex card payments in dc#267

Merged
jakubjasinsky merged 2 commits into
masterfrom
fix-amex-cards-in-dc
Jul 2, 2026
Merged

fix: fix amex card payments in dc#267
jakubjasinsky merged 2 commits into
masterfrom
fix-amex-cards-in-dc

Conversation

@jakubjasinsky

Copy link
Copy Markdown
Collaborator

Summary

Fix Amex (and other multi-word scheme) card payments being incorrectly blocked in Dynamic Checkout when restrict_to_schemes is set.

Changes

  • Add schemeRestrictionAliases map translating the SDK's hyphenated scheme codes (american-express, union-pay, diners-club) to the platform's space-separated equivalents (american express, china union pay, diners club).
  • In the card restriction check, match a detected scheme against both its hyphenated code and its platform alias, and compare case-insensitively to mirror the backend's EqualFold matching.

Additional Context

  • Root cause: Card.getPossibleSchemes() returns hyphenated codes, but restrict_to_schemes (dashboard/router/API) uses space-separated values, so multi-word schemes never matched and valid cards were rejected. Single-word schemes already align and need no alias.

Copilot AI review requested due to automatic review settings June 30, 2026 20:42

Copilot AI left a comment

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.

Pull request overview

This PR fixes Dynamic Checkout card scheme restrictions so multi-word schemes (e.g., American Express) are not incorrectly rejected when restrict_to_schemes is configured using the platform’s space-separated naming.

Changes:

  • Added a schemeRestrictionAliases map to translate SDK-detected hyphenated scheme codes to the platform’s space-separated scheme names.
  • Updated the card restriction logic to match detected schemes against both the raw detected code and its platform alias.
  • Made scheme restriction matching case-insensitive to mirror backend behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/dynamic-checkout/payment-methods/card.ts Updates scheme allowlist matching to be case-insensitive and to consider platform aliases for multi-word schemes.
src/dynamic-checkout/config/card-networks-map.ts Adds the schemeRestrictionAliases mapping from hyphenated SDK scheme codes to space-separated platform scheme names.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jakubjasinsky jakubjasinsky merged commit a1bb8f2 into master Jul 2, 2026
5 checks passed
@jakubjasinsky jakubjasinsky deleted the fix-amex-cards-in-dc branch July 2, 2026 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants