Skip to content

chore(POCP-1226): support 8-digit IINs in card event - #279

Draft
lukasz-k-bieszczad-cko wants to merge 10 commits into
masterfrom
chore/POCP-1226/allow-8-digin-inns-v2
Draft

chore(POCP-1226): support 8-digit IINs in card event#279
lukasz-k-bieszczad-cko wants to merge 10 commits into
masterfrom
chore/POCP-1226/allow-8-digin-inns-v2

Conversation

@lukasz-k-bieszczad-cko

Copy link
Copy Markdown
Contributor

Alternative to #270

Card.getIIN emitted a flat 8-digit IIN for every scheme, over-exposing
the BIN for schemes the backend caps at 6 (notably Amex). Mirror the
allow-list in api (controllers/card_inn.go): only visa, mastercard,
discover, jcb, union-pay and carte bancaire surface 8 digits; every
other scheme - plus unknown or co-badged/ambiguous prefixes - falls
back to 6.

Applies to both consumers of getIIN: the emitted card_iin field event
and the Dynamic Checkout restrict_to_iins prefix match.

Note: the backend api-deactivate-eight-digit-bin LaunchDarkly flag is
per-project and server-side, so the client cap is scheme-based only.
@datadog-eu-processout

Copy link
Copy Markdown

Pipelines

⚠️ Warnings

🚦 1 Pipeline job failed

Copilot | copilot-pull-request-reviewer

View in Datadog · View in GitHub Actions

CAPI proxy request failed with status 502 during job processing.

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 2534e2d | Docs | View more details | Give us feedback!

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

Note

Copilot was unable to run its full agentic suite in this review.

Add optional support for 8-digit IIN/BIN handling to improve issuer/scheme accuracy while keeping compatibility with 6-digit IIN flows.

Changes:

  • Extend IIN extraction / matching logic to handle 8-digit values (and prefix matching for restrictions).
  • Introduce exposeIIN8 option and add card helpers (getIIN8, canExpose8DigitIIN) to enforce when 8 digits may be surfaced.
  • Update example usage and bump package version.

Reviewed changes

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

Show a summary per file
File Description
src/processout/processout.ts Changes IIN extraction used for iins/${iin} API calls to 8 digits.
src/processout/cardfield.ts Adds exposeIIN8 option and propagates it through options parsing; formatting cleanups.
src/processout/card.ts Adds helpers and allow-list logic to decide when 8-digit IIN can be exposed.
src/dynamic-checkout/payment-methods/card.ts Updates restriction matching to support mixed 6/8-digit configured IINs via prefix logic.
package.json Bumps version to 1.9.11.
examples/card-form/index.html Demonstrates enabling exposeIIN8 and adjusts event trigger threshold.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +1679 to +1682
// Support up to 8-digit IINs (some networks issue 8-digit IINs, which
// yield more accurate issuer information); fall back to whatever is
// available when fewer digits were provided.
const iin = cardNumber.substring(0, 8)
Comment thread src/processout/card.ts
Comment on lines +464 to +471
/**
* GetIIN8 returns the IIN of the card number, exposing up to 8 digits
* when PCI rules allow it (scheme in the allow-list and a 16-digit
* PAN) and 6 digits otherwise.
* @param {string} number
* @return {string}
*/
public static getIIN8(number: string): string {
Comment thread src/processout/card.ts
* scheme key "union-pay" maps to the backend's "china union pay".
*/
private static iin8DigitSchemes: Array<string> = [
"visa", "mastercard", "discover", "jcb", "union-pay", "carte bancaire"
Comment thread src/processout/card.ts

/**
* Schemes permitted to surface an 8-digit IIN, mirroring the backend
* allow-list in api (controllers/card_inn.go). Every other scheme -
color: "#ababab",
},
},
exposeIIN8: true,
Comment on lines +59 to 61
if (e.card_number_length == 8) {
client.getCardInformation(
e.card_iin,
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.

2 participants