Skip to content

Commit f9a911b

Browse files
authored
Merge pull request #370 from 4site-interactive-studios/vgs-card-brands
VGS - Add support for valid card brands
2 parents 77dcbef + 286cdbe commit f9a911b

4 files changed

Lines changed: 22 additions & 0 deletions

File tree

packages/scripts/dist/interfaces/options.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ export interface Options {
109109
};
110110
ariaLabel?: string;
111111
placeholder?: string;
112+
validCardBrands?: {
113+
type: string;
114+
}[] | null;
112115
};
113116
"transaction.ccvv"?: {
114117
showCardIcon?: boolean | object;

packages/scripts/dist/vgs.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export class VGS {
141141
// Autocomplete is not customizable
142142
autoComplete: "cc-number",
143143
validations: ["required", "validCardNumber"],
144+
validCardBrands: null
144145
},
145146
"transaction.ccvv": {
146147
showCardIcon: false,
@@ -158,6 +159,12 @@ export class VGS {
158159
css: styles,
159160
},
160161
};
162+
// Override the validCardBrands if set in the theme options, as this should not be deep merged.
163+
if (options &&
164+
options["transaction.ccnumber"] &&
165+
options["transaction.ccnumber"].validCardBrands) {
166+
defaultOptions["transaction.ccnumber"].validCardBrands = options["transaction.ccnumber"].validCardBrands;
167+
}
161168
// Deep merge the default options with the options set in the theme
162169
this.options = ENGrid.deepMerge(defaultOptions, options);
163170
this.logger.log("Options", this.options);

packages/scripts/src/interfaces/options.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ export interface Options {
112112
};
113113
ariaLabel?: string;
114114
placeholder?: string;
115+
validCardBrands?: {
116+
type: string;
117+
}[] | null;
115118
};
116119
"transaction.ccvv"?: {
117120
showCardIcon?: boolean | object;

packages/scripts/src/vgs.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export class VGS {
113113
// Autocomplete is not customizable
114114
autoComplete: "cc-number",
115115
validations: ["required", "validCardNumber"],
116+
validCardBrands: <{ type: string }[]|null>null
116117
},
117118
"transaction.ccvv": {
118119
showCardIcon: false,
@@ -130,6 +131,14 @@ export class VGS {
130131
css: styles,
131132
},
132133
};
134+
// Override the validCardBrands if set in the theme options, as this should not be deep merged.
135+
if (
136+
options &&
137+
options["transaction.ccnumber"] &&
138+
options["transaction.ccnumber"].validCardBrands
139+
) {
140+
defaultOptions["transaction.ccnumber"].validCardBrands = options["transaction.ccnumber"].validCardBrands;
141+
}
133142
// Deep merge the default options with the options set in the theme
134143
this.options = ENGrid.deepMerge(defaultOptions, options);
135144
this.logger.log("Options", this.options);

0 commit comments

Comments
 (0)