credit-card-type
credit-card-type copied to clipboard
Fix incorrect typings
The README shows an addCard
example that uses a pattern not currently valid with the CreditCardType.patterns
type.
[number[]]
should be number[][]
This accurately represents credit-card-type's pattern functionality and allows the README example to work:
creditCardType.addCard({
niceType: "Visa with Custom Nice Type",
type: creditCardType.types.VISA,
patterns: [41111, [44, 47]],
gaps: [4, 8, 12],
lengths: [13, 16, 19], // add support for old, deprecated 13 digit visas
code: {
name: "CVV",
size: 3,
},
});
👋 @uPaymeiFixit thanks for the PR! We'll take a look and provide feedback or merge, unfortunately I can't provide an ETA. For internal reference, ticket 1890
In case it helps, this is the code I'm currently using as a workaround. When this type definition is fixed the as any
should be able to be removed. Please reach out if I can provide any more context.
CardValidator.creditCardType.addCard({
niceType: 'Deprecated 13 Digit Visa',
type: 'visa-deprecated',
// eslint-disable-next-line @typescript-eslint/no-explicit-any
patterns: [41111, [44, 47]] as any, // Required until this gets merged: https://github.com/braintree/credit-card-type/pull/147
gaps: [4, 8, 12],
lengths: [13, 16, 19], // add support for old, deprecated 13 digit visas
code: {
name: 'CVV',
size: 3,
},
});