Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "processout.js",
"version": "1.9.6",
"version": "1.9.7",
"description": "ProcessOut.js is a JavaScript library for ProcessOut's payment processing API.",
"scripts": {
"build:processout": "tsc -p src/processout && uglifyjs --compress --keep-fnames --ie8 dist/processout.js -o dist/processout.js",
Expand Down
12 changes: 12 additions & 0 deletions src/dynamic-checkout/config/card-networks-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,16 @@ module ProcessOut {
visa: "visa",
vpay: "vpay",
}

// The card field detects schemes via Card.getPossibleSchemes(), which uses
// hyphenated codes (e.g. "american-express"). The rest of the platform
// (dashboard restrict_to_schemes, router, api) uses space-separated values
// (e.g. "american express"). This maps the SDK's multi-word codes to their
// platform equivalents so scheme restrictions match. Only schemes whose two
// spellings differ need an entry; single-word schemes already align.
export const schemeRestrictionAliases: { [key: string]: string } = {
"american-express": "american express",
"union-pay": "china union pay",
"diners-club": "diners club",
}
}
18 changes: 15 additions & 3 deletions src/dynamic-checkout/payment-methods/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -917,12 +917,24 @@ module ProcessOut {
return
}

// The backend matches schemes case-insensitively (EqualFold), so we
// lowercase the allowlist to mirror that behaviour.
const allowedSchemes = restrictToSchemes.map(function (scheme) {
return scheme.toLowerCase()
})

var hasAllowedScheme = false

schemes.forEach(function (scheme) {
if (restrictToSchemes.indexOf(scheme) !== -1) {
hasAllowedScheme = true
}
// Compare both the detected (hyphenated) code and its platform alias
// (space-separated), e.g. "american-express" and "american express".
const candidates = [scheme, schemeRestrictionAliases[scheme]]

candidates.forEach(function (candidate) {
if (candidate && allowedSchemes.indexOf(candidate.toLowerCase()) !== -1) {
hasAllowedScheme = true
}
})
})

this.setCardRestrictionState(!hasAllowedScheme)
Expand Down
Loading