@idonatedev/idonate-sdk 1.1.0-dev1 → 1.1.0-dev11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,10 +20,11 @@ const styles_1 = require("./styles");
20
20
  const tokenizer_constants_1 = require("./tokenizer-constants");
21
21
  const tokenizer_utils_1 = require("./tokenizer-utils");
22
22
  class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
23
- constructor(iframe, iframeUrl, containerId, mode = 'credit_card', enableTestMode = false) {
23
+ constructor(iframe, iframeUrl, containerId, mode = 'credit_card', enableTestMode = false, layout = 'single-line') {
24
24
  super();
25
25
  this.iframeUrl = iframeUrl;
26
26
  this.containerId = containerId;
27
+ this.layout = layout;
27
28
  this.isReady = false;
28
29
  this.enableTestMode = false;
29
30
  this.mode = mode;
@@ -44,14 +45,12 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
44
45
  if (container.mode === 'bank_account' && container.bankCountry === 'CA') {
45
46
  throw new Error('CardConnect does not support Canadian bank accounts');
46
47
  }
47
- const baseUrl = (_a = gateway.config) === null || _a === void 0 ? void 0 : _a.base_url;
48
- if (!baseUrl) {
49
- throw new Error('CardConnect base URL not configured');
50
- }
48
+ let baseUrl = ((_a = gateway.config) === null || _a === void 0 ? void 0 : _a.base_url) || config.clientConfig.cardConnectBaseUrl;
49
+ config.cardConnectBaseUrl = baseUrl;
51
50
  const mergedStyles = (0, styles_1.mergeStyles)(styles_1.DEFAULT_UNIFIED_STYLES, container.styling);
52
51
  const iframeUrl = CardConnectTokenizer.generateIframeUrl(baseUrl, container);
53
52
  const iframe = CardConnectTokenizer.createIframe(iframeUrl, mergedStyles);
54
- const tokenizer = new CardConnectTokenizer(iframe, iframeUrl, container.containerId, container.mode || 'credit_card', container.enableTestMode || false);
53
+ const tokenizer = new CardConnectTokenizer(iframe, iframeUrl, container.containerId, container.mode || 'credit_card', container.enableTestMode || false, container.layout || 'single-line');
55
54
  tokenizer.createInternalElements(container);
56
55
  yield tokenizer.init();
57
56
  return tokenizer;
@@ -64,7 +63,7 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
64
63
  }
65
64
  this.containerEl = containerEl;
66
65
  containerEl.innerHTML = '';
67
- const mergedStyles = (0, styles_1.mergeStyles)(styles_1.DEFAULT_UNIFIED_STYLES, container.styling);
66
+ const mergedStyles = (0, styles_1.getContainerStylesForLayout)((0, styles_1.mergeStyles)(styles_1.DEFAULT_UNIFIED_STYLES, container.styling), this.layout);
68
67
  Object.assign(containerEl.style, mergedStyles.container);
69
68
  if (this.mode === 'bank_account') {
70
69
  this.createBankAccountFields(containerEl, mergedStyles);
@@ -75,34 +74,66 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
75
74
  }
76
75
  createCreditCardFields(containerEl, mergedStyles) {
77
76
  this.iframe.style.width = '100%';
78
- this.iframe.style.height = mergedStyles.input.height || '40px';
77
+ if (this.layout === 'two-line') {
78
+ const inputHeight = mergedStyles.input.height || '40px';
79
+ this.iframe.style.height = `calc((${inputHeight}) * 2 + 10px)`;
80
+ }
81
+ else {
82
+ this.iframe.style.height = mergedStyles.input.height || '40px';
83
+ }
79
84
  this.iframe.style.border = 'none';
80
85
  this.iframe.style.display = 'block';
81
86
  containerEl.appendChild(this.iframe);
82
87
  }
83
88
  createBankAccountFields(containerEl, mergedStyles) {
84
89
  this.iframe.style.display = 'none';
85
- this.routingNumberEl = (0, tokenizer_utils_1.createInputElement)(`${this.containerId}-routing`, 'text', 'Routing *', 9);
86
- Object.assign(this.routingNumberEl.style, {
87
- flex: tokenizer_constants_1.BANK_FIELD_FLEX.routingNumber.flex,
88
- minWidth: tokenizer_constants_1.BANK_FIELD_FLEX.routingNumber.minWidth,
89
- });
90
- this.applyInputStyles(this.routingNumberEl, mergedStyles, 'left');
91
- containerEl.appendChild(this.routingNumberEl);
92
- this.accountNumberEl = (0, tokenizer_utils_1.createInputElement)(`${this.containerId}-account`, 'text', 'Account Number *', 17);
93
- Object.assign(this.accountNumberEl.style, {
94
- flex: tokenizer_constants_1.BANK_FIELD_FLEX.accountNumber.flex,
95
- minWidth: tokenizer_constants_1.BANK_FIELD_FLEX.accountNumber.minWidth,
96
- });
97
- this.applyInputStyles(this.accountNumberEl, mergedStyles, 'middle');
98
- containerEl.appendChild(this.accountNumberEl);
99
- this.accountTypeEl = (0, tokenizer_utils_1.createAccountTypeSelect)(`${this.containerId}-account-type`);
100
- Object.assign(this.accountTypeEl.style, {
101
- flex: tokenizer_constants_1.BANK_FIELD_FLEX.accountType.flex,
102
- minWidth: tokenizer_constants_1.BANK_FIELD_FLEX.accountType.minWidth,
103
- });
104
- this.applyInputStyles(this.accountTypeEl, mergedStyles, 'right');
105
- containerEl.appendChild(this.accountTypeEl);
90
+ if (this.layout === 'two-line') {
91
+ this.accountTypeEl = (0, tokenizer_utils_1.createAccountTypeSelect)(`${this.containerId}-account-type`);
92
+ Object.assign(this.accountTypeEl.style, {
93
+ flex: '1',
94
+ minWidth: tokenizer_constants_1.BANK_FIELD_FLEX.accountType.minWidth,
95
+ });
96
+ this.applyInputStyles(this.accountTypeEl, mergedStyles, 'left');
97
+ containerEl.appendChild(this.accountTypeEl);
98
+ this.routingNumberEl = (0, tokenizer_utils_1.createInputElement)(`${this.containerId}-routing`, 'text', 'Routing *', 9);
99
+ Object.assign(this.routingNumberEl.style, {
100
+ flex: '1',
101
+ minWidth: tokenizer_constants_1.BANK_FIELD_FLEX.routingNumber.minWidth,
102
+ });
103
+ this.applyInputStyles(this.routingNumberEl, mergedStyles, 'right');
104
+ containerEl.appendChild(this.routingNumberEl);
105
+ this.accountNumberEl = (0, tokenizer_utils_1.createInputElement)(`${this.containerId}-account`, 'text', 'Account Number *', 17);
106
+ Object.assign(this.accountNumberEl.style, {
107
+ flex: '1',
108
+ flexBasis: '100%',
109
+ minWidth: tokenizer_constants_1.BANK_FIELD_FLEX.accountNumber.minWidth,
110
+ });
111
+ this.applyInputStyles(this.accountNumberEl, mergedStyles);
112
+ containerEl.appendChild(this.accountNumberEl);
113
+ }
114
+ else {
115
+ this.routingNumberEl = (0, tokenizer_utils_1.createInputElement)(`${this.containerId}-routing`, 'text', 'Routing *', 9);
116
+ Object.assign(this.routingNumberEl.style, {
117
+ flex: tokenizer_constants_1.BANK_FIELD_FLEX.routingNumber.flex,
118
+ minWidth: tokenizer_constants_1.BANK_FIELD_FLEX.routingNumber.minWidth,
119
+ });
120
+ this.applyInputStyles(this.routingNumberEl, mergedStyles, 'left');
121
+ containerEl.appendChild(this.routingNumberEl);
122
+ this.accountNumberEl = (0, tokenizer_utils_1.createInputElement)(`${this.containerId}-account`, 'text', 'Account Number *', 17);
123
+ Object.assign(this.accountNumberEl.style, {
124
+ flex: tokenizer_constants_1.BANK_FIELD_FLEX.accountNumber.flex,
125
+ minWidth: tokenizer_constants_1.BANK_FIELD_FLEX.accountNumber.minWidth,
126
+ });
127
+ this.applyInputStyles(this.accountNumberEl, mergedStyles, 'middle');
128
+ containerEl.appendChild(this.accountNumberEl);
129
+ this.accountTypeEl = (0, tokenizer_utils_1.createAccountTypeSelect)(`${this.containerId}-account-type`);
130
+ Object.assign(this.accountTypeEl.style, {
131
+ flex: tokenizer_constants_1.BANK_FIELD_FLEX.accountType.flex,
132
+ minWidth: tokenizer_constants_1.BANK_FIELD_FLEX.accountType.minWidth,
133
+ });
134
+ this.applyInputStyles(this.accountTypeEl, mergedStyles, 'right');
135
+ containerEl.appendChild(this.accountTypeEl);
136
+ }
106
137
  }
107
138
  init() {
108
139
  return __awaiter(this, void 0, void 0, function* () {
@@ -142,7 +173,6 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
142
173
  clearTimeout(timeout);
143
174
  this.isReady = true;
144
175
  if (this.enableTestMode && this.mode === 'credit_card') {
145
- console.log('CardConnect test mode enabled - manual entry required for card fields');
146
176
  }
147
177
  this.emit('ready');
148
178
  resolve();
@@ -159,6 +189,12 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
159
189
  if (!this.isReady) {
160
190
  throw new Error('Tokenizer not initialized');
161
191
  }
192
+ if (this.mode === 'credit_card' && this.hasToken()) {
193
+ const cachedToken = this.getToken();
194
+ if (cachedToken) {
195
+ return cachedToken;
196
+ }
197
+ }
162
198
  if (this.mode === 'bank_account' || this.isBankAccountData(paymentData)) {
163
199
  return this.tokenizeBankAccountInternal(paymentData);
164
200
  }
@@ -177,35 +213,33 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
177
213
  provider: 'cardconnect',
178
214
  };
179
215
  }
180
- return new Promise((resolve, reject) => {
216
+ if (this.tokenizationPromise) {
217
+ return this.tokenizationPromise;
218
+ }
219
+ this.tokenizationPromise = new Promise((resolve, reject) => {
220
+ this.tokenizationResolve = resolve;
221
+ this.tokenizationReject = reject;
181
222
  const timeout = setTimeout(() => {
223
+ this.tokenizationPromise = undefined;
224
+ this.tokenizationResolve = undefined;
225
+ this.tokenizationReject = undefined;
182
226
  reject(new types_1.TokenizationError('Tokenization timeout - ensure all card fields are filled in iframe', 'TIMEOUT'));
183
227
  }, tokenizer_constants_1.TOKENIZE_TIMEOUT);
184
228
  const tokenizationHandler = (data) => {
185
229
  clearTimeout(timeout);
186
230
  this.off('tokenization', tokenizationHandler);
187
- if (data.errorCode === '0') {
188
- resolve({
189
- token: data.token,
190
- lastFour: data.token.slice(-4),
191
- cardType: this.normalizeCardType('unknown'),
192
- provider: 'cardconnect',
193
- });
194
- }
195
- else {
196
- reject(new types_1.TokenizationError(data.errorMessage || 'Tokenization failed', data.errorCode || 'UNKNOWN'));
197
- }
198
231
  };
199
232
  this.on('tokenization', tokenizationHandler);
200
233
  });
234
+ return this.tokenizationPromise;
201
235
  });
202
236
  }
203
237
  tokenizeBankAccountInternal(bankData) {
204
238
  return __awaiter(this, void 0, void 0, function* () {
205
239
  var _a, _b, _c;
206
- const routingNumber = ((_a = this.routingNumberEl) === null || _a === void 0 ? void 0 : _a.value) || bankData.routingNumber;
207
- const accountNumber = ((_b = this.accountNumberEl) === null || _b === void 0 ? void 0 : _b.value) || bankData.accountNumber;
208
- const accountType = ((_c = this.accountTypeEl) === null || _c === void 0 ? void 0 : _c.value) || bankData.accountType;
240
+ const routingNumber = (_a = this.routingNumberEl) === null || _a === void 0 ? void 0 : _a.value;
241
+ const accountNumber = (_b = this.accountNumberEl) === null || _b === void 0 ? void 0 : _b.value;
242
+ const accountType = ((_c = this.accountTypeEl) === null || _c === void 0 ? void 0 : _c.value) || 'checking';
209
243
  const accountHolderType = 'personal';
210
244
  if (!routingNumber || !accountNumber) {
211
245
  throw new types_1.TokenizationError('Routing number and account number are required', 'VALIDATION_ERROR');
@@ -245,28 +279,64 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
245
279
  validateCardInternal() {
246
280
  return __awaiter(this, void 0, void 0, function* () {
247
281
  const errors = [];
248
- if (this.currentValidationState.cardNumber &&
249
- !this.currentValidationState.cardNumber.isValid &&
250
- !this.currentValidationState.cardNumber.isEmpty) {
282
+ if (this.currentValidationState.cardNumber) {
283
+ if (this.currentValidationState.cardNumber.isEmpty) {
284
+ errors.push({
285
+ field: 'cardNumber',
286
+ message: 'Card number is required',
287
+ });
288
+ }
289
+ else if (!this.currentValidationState.cardNumber.isValid) {
290
+ errors.push({
291
+ field: 'cardNumber',
292
+ message: 'Invalid card number',
293
+ });
294
+ }
295
+ }
296
+ else {
251
297
  errors.push({
252
298
  field: 'cardNumber',
253
- message: 'Invalid card number',
299
+ message: 'Card number is required',
254
300
  });
255
301
  }
256
- if (this.currentValidationState.expiry &&
257
- !this.currentValidationState.expiry.isValid &&
258
- !this.currentValidationState.expiry.isEmpty) {
302
+ if (this.currentValidationState.expiry) {
303
+ if (this.currentValidationState.expiry.isEmpty) {
304
+ errors.push({
305
+ field: 'expiry',
306
+ message: 'Expiry date is required',
307
+ });
308
+ }
309
+ else if (!this.currentValidationState.expiry.isValid) {
310
+ errors.push({
311
+ field: 'expiry',
312
+ message: 'Invalid expiry date',
313
+ });
314
+ }
315
+ }
316
+ else {
259
317
  errors.push({
260
318
  field: 'expiry',
261
- message: 'Invalid expiry date',
319
+ message: 'Expiry date is required',
262
320
  });
263
321
  }
264
- if (this.currentValidationState.cvv &&
265
- !this.currentValidationState.cvv.isValid &&
266
- !this.currentValidationState.cvv.isEmpty) {
322
+ if (this.currentValidationState.cvv) {
323
+ if (this.currentValidationState.cvv.isEmpty) {
324
+ errors.push({
325
+ field: 'cvv',
326
+ message: 'CVV is required',
327
+ });
328
+ }
329
+ else if (!this.currentValidationState.cvv.isValid) {
330
+ errors.push({
331
+ field: 'cvv',
332
+ message: 'Invalid CVV',
333
+ });
334
+ }
335
+ }
336
+ else {
267
337
  errors.push({
268
338
  field: 'cvv',
269
- message: 'Invalid CVV',
339
+ message: 'CVV is required',
270
340
  });
271
341
  }
272
342
  return {
@@ -369,12 +439,66 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
369
439
  }
370
440
  this.eventHandlers.clear();
371
441
  }
442
+ hasToken() {
443
+ var _a, _b;
444
+ if (this.mode === 'credit_card') {
445
+ return (((_a = this.cachedTokenResult) === null || _a === void 0 ? void 0 : _a.errorCode) === '0' &&
446
+ !!((_b = this.cachedTokenResult) === null || _b === void 0 ? void 0 : _b.token));
447
+ }
448
+ return false;
449
+ }
450
+ getToken() {
451
+ var _a;
452
+ if (this.mode === 'credit_card' &&
453
+ ((_a = this.cachedTokenResult) === null || _a === void 0 ? void 0 : _a.errorCode) === '0') {
454
+ return {
455
+ token: this.cachedTokenResult.token,
456
+ lastFour: this.cachedTokenResult.token.slice(-4),
457
+ cardType: this.normalizeCardType('unknown'),
458
+ provider: 'cardconnect',
459
+ };
460
+ }
461
+ return null;
462
+ }
463
+ get tokenizationMode() {
464
+ return this.mode === 'credit_card' ? 'auto' : 'manual';
465
+ }
372
466
  handleMessage(event) {
373
467
  try {
374
468
  const data = typeof event.data === 'string' ? JSON.parse(event.data) : event.data;
375
469
  if (data.token && data.errorCode !== undefined) {
376
470
  this.cachedTokenResult = data;
377
471
  this.emit('tokenization', data);
472
+ if (data.errorCode === '0') {
473
+ const token = {
474
+ token: data.token,
475
+ lastFour: data.token.slice(-4),
476
+ cardType: this.normalizeCardType('unknown'),
477
+ provider: 'cardconnect',
478
+ };
479
+ if (this.tokenizationResolve) {
480
+ this.tokenizationResolve(token);
481
+ this.tokenizationPromise = undefined;
482
+ this.tokenizationResolve = undefined;
483
+ this.tokenizationReject = undefined;
484
+ }
485
+ this.currentValidationState = {
486
+ isValid: true,
487
+ cardNumber: { isValid: true, isEmpty: false },
488
+ cvv: { isValid: true, isEmpty: false },
489
+ expiry: { isValid: true, isEmpty: false },
490
+ };
491
+ this.emit('validation', { isValid: true });
492
+ this.emit('tokenReady', token);
493
+ }
494
+ else {
495
+ if (this.tokenizationReject) {
496
+ this.tokenizationReject(new types_1.TokenizationError(data.errorMessage || 'Tokenization failed', data.errorCode || 'UNKNOWN'));
497
+ this.tokenizationPromise = undefined;
498
+ this.tokenizationResolve = undefined;
499
+ this.tokenizationReject = undefined;
500
+ }
501
+ }
378
502
  }
379
503
  if (data.event === 'validation' || data.validationError !== undefined) {
380
504
  this.handleValidationMessage(data);
@@ -397,38 +521,23 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
397
521
  this.currentValidationState.cardNumber = {
398
522
  isValid: false,
399
523
  isEmpty: false,
400
- error: data.validationError,
401
524
  };
402
525
  }
403
526
  else if (errorLower.includes('cvv') ||
404
527
  errorLower.includes('security')) {
405
- this.currentValidationState.cvv = {
406
- isValid: false,
407
- isEmpty: false,
408
- error: data.validationError,
409
- };
528
+ this.currentValidationState.cvv = { isValid: false, isEmpty: false };
410
529
  }
411
530
  else if (errorLower.includes('expir') ||
412
- errorLower.includes('exp') ||
413
531
  errorLower.includes('month') ||
414
532
  errorLower.includes('year')) {
415
- this.currentValidationState.expiry = {
416
- isValid: false,
417
- isEmpty: false,
418
- error: data.validationError,
419
- };
533
+ this.currentValidationState.expiry = { isValid: false, isEmpty: false };
420
534
  }
421
- }
422
- else if (data.event === 'validation') {
535
+ this.emit('error', new types_1.TokenizationError(data.validationError));
423
536
  }
424
537
  this.currentValidationState.isValid =
425
538
  ((_b = (_a = this.currentValidationState.cardNumber) === null || _a === void 0 ? void 0 : _a.isValid) !== null && _b !== void 0 ? _b : false) &&
426
539
  ((_d = (_c = this.currentValidationState.cvv) === null || _c === void 0 ? void 0 : _c.isValid) !== null && _d !== void 0 ? _d : false) &&
427
540
  ((_f = (_e = this.currentValidationState.expiry) === null || _e === void 0 ? void 0 : _e.isValid) !== null && _f !== void 0 ? _f : false);
428
- this.emit('validation', this.currentValidationState);
429
- if (data.validationError) {
430
- this.emit('error', new types_1.TokenizationError(data.validationError));
431
- }
432
541
  }
433
542
  static generateIframeUrl(baseUrl, container) {
434
543
  const params = new URLSearchParams({
@@ -436,20 +545,28 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
436
545
  enhancedresponse: 'true',
437
546
  useexpiry: 'true',
438
547
  usecvv: 'true',
439
- orientation: 'horizontal',
440
548
  formatinput: 'true',
441
549
  unique: 'true',
442
550
  norsa: 'true',
443
551
  placeholder: 'Card Number *',
444
- placeholdermonth: 'MM',
445
- placeholderyear: 'YYYY',
446
552
  placeholdercvv: 'CVV',
447
553
  invalidcreditcardevent: 'true',
448
554
  invalidexpiry: 'true',
449
555
  invalidcvv: 'true',
450
556
  });
557
+ if (container.layout === 'two-line') {
558
+ params.set('useexpiryfield', 'true');
559
+ params.set('orientation', 'horizontal');
560
+ params.set('placeholdermonth', 'MM');
561
+ params.set('placeholderyear', 'YYYY');
562
+ }
563
+ else {
564
+ params.set('orientation', 'horizontal');
565
+ params.set('placeholdermonth', 'MM');
566
+ params.set('placeholderyear', 'YYYY');
567
+ }
451
568
  const mergedStyles = (0, styles_1.mergeStyles)(styles_1.DEFAULT_UNIFIED_STYLES, container.styling);
452
- const cssString = CardConnectTokenizer.generateCardConnectCss(mergedStyles);
569
+ const cssString = CardConnectTokenizer.generateCardConnectCss(mergedStyles, container.layout || 'single-line');
453
570
  const queryPairs = [];
454
571
  params.forEach((value, key) => {
455
572
  queryPairs.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
@@ -482,13 +599,20 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
482
599
  iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-forms');
483
600
  return iframe;
484
601
  }
485
- static generateCardConnectCss(styles) {
486
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
602
+ static generateCardConnectCss(styles, layout = 'single-line') {
603
+ var _a, _b, _c;
487
604
  const css = [];
488
- css.push('body{margin:0;padding:0;display:flex;align-items:center;}');
489
- css.push('form{margin:0;padding:0;display:flex;width:100%;align-items:center;}');
490
- css.push('label{display:none;}');
491
- css.push('br{display:none;}');
605
+ if (layout === 'two-line') {
606
+ css.push('html,form,body{margin:0;padding:0;}');
607
+ css.push('label{display:none;}');
608
+ css.push('br{display:none;}');
609
+ }
610
+ else {
611
+ css.push('body{margin:0;padding:0;display:flex;align-items:center;}');
612
+ css.push('form{margin:0;padding:0;display:flex;width:100%;align-items:center;}');
613
+ css.push('label{display:none;}');
614
+ css.push('br{display:none;}');
615
+ }
492
616
  const isConnected = styles.container.gap === '0';
493
617
  const gap = isConnected ? '0' : styles.container.gap || '1rem';
494
618
  if (styles.input) {
@@ -512,80 +636,49 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
512
636
  css.push(`input{${baseStyles};}`);
513
637
  css.push(`select{${baseStyles};}`);
514
638
  }
515
- if (isConnected) {
516
- const cardNumStyles = ['width:60%', 'margin:0'];
639
+ if (layout === 'two-line') {
640
+ css.push('input#ccnumfield{width:100%;display:block;margin-bottom:8px;}');
641
+ css.push('input#ccexpiryfieldmonth{width:20%;}');
642
+ css.push('input#ccexpiryfieldyear{width:24%;}');
643
+ css.push('input#cccvvfield{width:calc(56% - 20px);}');
517
644
  if ((_a = styles.input) === null || _a === void 0 ? void 0 : _a.borderRadius) {
518
- cardNumStyles.push(`border-radius:${styles.input.borderRadius} 0 0 ${styles.input.borderRadius}`);
519
- }
520
- cardNumStyles.push('border-right:none');
521
- css.push(`input#ccnumfield{${cardNumStyles.join(';')};}`);
522
- const monthStyles = [
523
- 'width:10%',
524
- 'margin:0',
525
- 'margin-right:-12px',
526
- 'border-radius:0',
527
- `border-left:${((_b = styles.input) === null || _b === void 0 ? void 0 : _b.border) || '1px solid #ccc'}`,
528
- 'border-right:none',
529
- ];
530
- css.push(`select#ccexpirymonth{${monthStyles.join(';')};}`);
531
- const yearStyles = [
532
- 'width:10%',
533
- 'border-radius:0',
534
- `border-left:${((_c = styles.input) === null || _c === void 0 ? void 0 : _c.border) || '1px solid #ccc'}`,
535
- 'border-right:none',
536
- ];
537
- css.push(`select#ccexpiryyear{${yearStyles.join(';')};}`);
538
- const cvvStyles = [
539
- 'width:20%',
540
- 'margin:0',
541
- 'margin-left:-12px',
542
- ];
543
- if ((_d = styles.input) === null || _d === void 0 ? void 0 : _d.borderRadius) {
544
- cvvStyles.push(`border-radius:0 ${styles.input.borderRadius} ${styles.input.borderRadius} 0`);
545
- }
546
- cvvStyles.push(`border-left:${((_e = styles.input) === null || _e === void 0 ? void 0 : _e.border) || '1px solid #ccc'}`);
547
- css.push(`input#cccvvfield{${cvvStyles.join(';')};}`);
645
+ css.push(`input{border-radius:${styles.input.borderRadius};}`);
646
+ }
647
+ }
648
+ else if (isConnected) {
649
+ css.push('input#ccnumfield{width:60%;margin:0;}');
650
+ css.push('select#ccexpirymonth{width:10%;margin:0;margin-right:-12px;}');
651
+ css.push('select#ccexpiryyear{width:10%;}');
652
+ css.push('input#cccvvfield{width:20%;margin:0;margin-left:-12px;}');
653
+ if ((_b = styles.input) === null || _b === void 0 ? void 0 : _b.borderRadius) {
654
+ css.push(`input#ccnumfield{border-radius:${styles.input.borderRadius} 0 0 ${styles.input.borderRadius};border-right:none;}`);
655
+ css.push('select#ccexpirymonth{border-radius:0;border-right:none;}');
656
+ css.push('select#ccexpiryyear{border-radius:0;border-right:none;}');
657
+ css.push(`input#cccvvfield{border-radius:0 ${styles.input.borderRadius} ${styles.input.borderRadius} 0;}`);
658
+ }
659
+ else {
660
+ css.push('input#ccnumfield{border-right:none;}');
661
+ css.push('select#ccexpirymonth{border-right:none;}');
662
+ css.push('select#ccexpiryyear{border-right:none;}');
663
+ }
548
664
  }
549
665
  else {
550
- const gapValue = gap.replace(/[^\d.]/g, '');
551
- const gapUnit = gap.replace(/[\d.]/g, '');
552
- const halfGapValue = parseFloat(gapValue) / 2;
553
- const cardNumStyles = [
554
- `width:calc(60% - ${gapValue}${gapUnit})`,
555
- `margin-right:${gap}`,
556
- ];
557
- if ((_f = styles.input) === null || _f === void 0 ? void 0 : _f.borderRadius) {
558
- cardNumStyles.push(`border-radius:${styles.input.borderRadius}`);
559
- }
560
- css.push(`input#ccnumfield{${cardNumStyles.join(';')};}`);
561
- const monthStyles = [
562
- `width:calc(10% - ${halfGapValue}${gapUnit})`,
563
- `margin-right:calc(${gap} / 2)`,
564
- ];
565
- if ((_g = styles.input) === null || _g === void 0 ? void 0 : _g.borderRadius) {
566
- monthStyles.push(`border-radius:${styles.input.borderRadius}`);
567
- }
568
- css.push(`select#ccexpirymonth{${monthStyles.join(';')};}`);
569
- const yearStyles = [
570
- `width:calc(10% - ${halfGapValue}${gapUnit})`,
571
- `margin-right:${gap}`,
572
- ];
573
- if ((_h = styles.input) === null || _h === void 0 ? void 0 : _h.borderRadius) {
574
- yearStyles.push(`border-radius:${styles.input.borderRadius}`);
575
- }
576
- css.push(`select#ccexpiryyear{${yearStyles.join(';')};}`);
577
- const cvvStyles = ['width:20%'];
578
- if ((_j = styles.input) === null || _j === void 0 ? void 0 : _j.borderRadius) {
579
- cvvStyles.push(`border-radius:${styles.input.borderRadius}`);
580
- }
581
- css.push(`input#cccvvfield{${cvvStyles.join(';')};}`);
666
+ const marginRight = gap === '0' ? '0' : '8px';
667
+ css.push(`input#ccnumfield{width:60%;margin-right:${marginRight};}`);
668
+ css.push(`select#ccexpirymonth{width:10%;margin-right:${marginRight};}`);
669
+ css.push(`select#ccexpiryyear{width:10%;margin-right:${marginRight};}`);
670
+ css.push('input#cccvvfield{width:20%;}');
671
+ if ((_c = styles.input) === null || _c === void 0 ? void 0 : _c.borderRadius) {
672
+ css.push(`input,select{border-radius:${styles.input.borderRadius};}`);
673
+ }
582
674
  }
583
675
  if (styles.focus) {
584
676
  const focusStyles = [];
585
677
  if (styles.focus.borderColor)
586
678
  focusStyles.push(`border-color:${styles.focus.borderColor}`);
587
- if (styles.focus.outline)
588
- focusStyles.push(`outline:${styles.focus.outline}`);
679
+ if (styles.focus.outline) {
680
+ focusStyles.push(`outline:none`);
681
+ }
589
682
  if (styles.focus.boxShadow)
590
683
  focusStyles.push(`box-shadow:${styles.focus.boxShadow}`);
591
684
  if (focusStyles.length > 0) {
@@ -5,6 +5,7 @@ import ConfigHandler from '../config-handler';
5
5
  export declare class SpreedlyTokenizer extends Tokenizer {
6
6
  private environmentKey;
7
7
  private containerId;
8
+ private layout;
8
9
  private spreedly;
9
10
  private isReady;
10
11
  private currentValidationState;
@@ -14,8 +15,9 @@ export declare class SpreedlyTokenizer extends Tokenizer {
14
15
  private cvvEl;
15
16
  private expiryId;
16
17
  private containerEl?;
17
- private organizationId?;
18
- private embedId?;
18
+ private organizationId;
19
+ private embedId;
20
+ private clientConfig;
19
21
  private bankCountry;
20
22
  private routingNumberEl?;
21
23
  private accountNumberEl?;
@@ -24,9 +26,10 @@ export declare class SpreedlyTokenizer extends Tokenizer {
24
26
  private transitNumberEl?;
25
27
  private enableTestMode;
26
28
  private constructor();
27
- static create(gateway: PaymentGateway, container: TokenizerContainer, config?: {
29
+ static create(gateway: PaymentGateway, container: TokenizerContainer, config: {
28
30
  organizationId: string;
29
31
  embedId: string;
32
+ clientConfig: ConfigHandler;
30
33
  }): Promise<SpreedlyTokenizer>;
31
34
  private init;
32
35
  tokenize(paymentData: PaymentData): Promise<PaymentToken>;
@@ -41,6 +44,10 @@ export declare class SpreedlyTokenizer extends Tokenizer {
41
44
  clear(): void;
42
45
  focus(field: 'cardNumber' | 'cvv' | 'expiry' | 'routingNumber' | 'accountNumber'): void;
43
46
  destroy(): void;
47
+ hasToken(): boolean;
48
+ getToken(): PaymentToken | null;
49
+ get tokenizationMode(): 'auto' | 'manual';
50
+ private updateOverallValidation;
44
51
  private handleFieldEvent;
45
52
  private createInternalElements;
46
53
  private createCreditCardFields;