Skip to content

Commit 25cf56a

Browse files
chore(POCP-1226): support 8-digit IINs in card event
1 parent dac0ad1 commit 25cf56a

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/dynamic-checkout/payment-methods/card.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,12 @@ module ProcessOut {
918918
return
919919
}
920920

921-
const isAllowedIin = restrictToIins.indexOf(iin) !== -1
921+
// card_iin may carry more digits than the configured entries (IINs can
922+
// be 6 or 8 digits), so match on prefix: an allowed entry matches when
923+
// the detected IIN starts with it.
924+
const isAllowedIin = restrictToIins.some(function (allowedIin) {
925+
return allowedIin.length > 0 && iin.substring(0, allowedIin.length) === allowedIin
926+
})
922927

923928
this.setCardRestrictionState(!isAllowedIin)
924929
}

src/processout/card.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,8 @@ module ProcessOut {
456456
number = Card.parseNumber(number); // Remove potential spaces
457457

458458
var l = number.length;
459-
if (l > 6)
460-
l = 6;
459+
if (l > 8)
460+
l = 8;
461461
return number.substring(0, l);
462462
}
463463

src/processout/processout.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,10 @@ module ProcessOut {
16761676
return
16771677
}
16781678

1679-
const iin = cardNumber.substring(0, 6)
1679+
// Support up to 8-digit IINs (some networks issue 8-digit IINs, which
1680+
// yield more accurate issuer information); fall back to whatever is
1681+
// available when fewer digits were provided.
1682+
const iin = cardNumber.substring(0, 8)
16801683
const apiEndpoint = `iins/${iin}`
16811684

16821685
this.apiRequest(

0 commit comments

Comments
 (0)