Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(payment): CHECKOUT-4655 Add support for additional card types whe…
…n validating hosted payment form
- Loading branch information
Showing
8 changed files
with
74 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'card-validator'; | ||
|
||
// Merge @types/card-validator with missing methods. We probably don't need this | ||
// once the official package is updated with the latest type definitions. | ||
declare module 'card-validator' { | ||
type CardBrand = | ||
| 'american-express' | ||
| 'diners-club' | ||
| 'discover' | ||
| 'jcb' | ||
| 'maestro' | ||
| 'mastercard' | ||
| 'unionpay' | ||
| 'visa'; | ||
|
||
interface CreditCardTypeInfo { | ||
patterns?: Array<number | [number, number]>; | ||
niceType?: string; | ||
type?: CardBrand; | ||
prefixPattern?: RegExp; | ||
exactPattern?: RegExp; | ||
gaps?: number[]; | ||
lengths?: number[]; | ||
code?: { | ||
name?: string; | ||
size?: number; | ||
}; | ||
} | ||
|
||
interface CreditCardType { | ||
types: { [type: string]: string }; | ||
(cardNumber: string): CreditCardTypeInfo[]; | ||
getTypeInfo(type: string): CreditCardTypeInfo; | ||
updateCard(type: string, updates: Partial<CreditCardTypeInfo>): void; | ||
} | ||
|
||
export const creditCardType: CreditCardType; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
"target": "es5" | ||
}, | ||
"include": [ | ||
"src/common/types/card-validator.d.ts", | ||
"src/**/*.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
"src/**/*.ts" | ||
], | ||
"files": [ | ||
"src/common/types/card-validator.d.ts", | ||
"src/common/types/webpack.d.ts" | ||
] | ||
} |