chore(POCP-1226): support 8-digit IINs in card event - #270
chore(POCP-1226): support 8-digit IINs in card event#270lukasz-k-bieszczad-cko wants to merge 9 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the SDK’s card IIN handling to support up to 8-digit IINs, enabling more accurate issuer lookups (notably for MercadoPago installments) while preserving compatibility with existing 6-digit behavior.
Changes:
- Increase IIN extraction cap from 6 → 8 digits in
Card.getIIN. - Update
ProcessOut.getCardInformationto use up to 8 digits for theiins/{iin}lookup (minimum length remains 6). - Adjust Dynamic Checkout
restrict_to_iinsmatching from exact equality to prefix-based matching.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/processout/processout.ts | Expands IIN lookup in getCardInformation from 6 to 8 digits. |
| src/processout/card.ts | Raises Card.getIIN maximum returned length from 6 to 8 digits. |
| src/dynamic-checkout/payment-methods/card.ts | Changes restrict_to_iins allowlist evaluation to use prefix matching. |
| package.json | Bumps package version to 1.9.8. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6245d86 to
42ac592
Compare
Tests |
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.
42ac592 to
eb08085
Compare
eb08085 to
51e82b8
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (2)
src/processout/card.ts:516
canExpose8DigitIIN()usesCard.getPossibleSchemes(number)and requires all matches to be allow-listed. BecausegetPossibleSchemes()includes very broad prefixes (e.g.maestromatches any PAN starting with"6"via the"6"option), 16-digit PANs for Discover/UnionPay will always includemaestroin the match set, makingcanExpose8DigitIIN()return false even though"discover"/"union-pay"are iniin8DigitSchemes. This makes 8-digit IIN exposure effectively unreachable for those schemes.
var schemes = Card.getPossibleSchemes(number);
if (schemes.length == 0)
return false;
for (var i = 0; i < schemes.length; i++) {
if (Card.iin8DigitSchemes.indexOf(schemes[i]) === -1)
return false;
}
examples/card-form/index.html:60
- The example now calls
getCardInformation(e.card_iin8, ...)unconditionally whencard_number_length == 8. Ifcard_iin8isn’t present (e.g., older embedded card form / checkout-cdn), this will always hit the error callback withcard.invalid-number. Adding a fallback tocard_iinkeeps the example compatible while still preferring the 8-digit field when available.
if (e.card_number_length == 8) {
client.getCardInformation(
e.card_iin8,
5a2de15 to
f5b627b
Compare
|
Open question on the name of the new field: |
Thinking out loud, are there any "settings" merchants can apply to this? e.g. we have a setting for enabling this functionality on the existing field TBD if this is a good idea as the less the merchant has to do the better - and at some point the eight will become the norm |
We could use const client = new ProcessOut.ProcessOut(projectId)
const formElement = document.getElementById("card-form")
client.setupForm(
formElement,
{
(...)
exposeIIN8: true,
},
function (form) {
form.getNumberField().on("input", function (e) {
e.card_iin <---- returns 6 or 8 digits depending on exposeIIN8
(...)
},
function (err) { console.error(err) }
)The weird thing might be that even though merchant enables that in po.js we won't return 8-digits if the FF is not enabled. POC: #279 |
Description
The PO.JS card event exposes a card's IIN capped at 6 digits (
card_iin). Civitatis needs 8 digits to call MercadoPago'sGET /installmentsdirectly. Rather than widening the existing field (a breaking change for merchantsexpecting 6 digits), this adds a new 8-digit field alongside the untouched 6-digit one, letting merchants migrate at their own pace.
Solution
Card.getIIN8: returns 8 digits only when the PAN is exactly 16 digits and the scheme is in the allow-list; Amex, non-16-digit PANs, unknown or co-badged/ambiguous prefixes fall back to 6 (never empty, so merchants need no empty-value fallback).Card.getIINunchanged (still capped at 6). The legacycard_iinevent field keeps its exact current behaviour -legacy merchants are unaffected.card_iin8event field can be emitted from the card form'sgetFieldData()alongsidecard_iin.restrict_to_iins) now matches oncard_iin8when present, falling back tocard_iin, using prefix match so 6- or 8-digit allowlist entries both work.getCardInformationstill passes up to 8 digits to theiins/{iin}lookup. Minimum-length guard (6) unchanged.Notes
card_iin8.Checklist
Jira Issue
POCP-1226