@idonatedev/idonate-sdk 1.2.0-dev1 → 1.2.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.
package/dist/recaptcha.js CHANGED
@@ -1,8 +1,18 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.RecaptchaElement = void 0;
4
13
  exports.injectScript = injectScript;
5
14
  exports.wrapElement = wrapElement;
15
+ exports.wrapElementWithThrow = wrapElementWithThrow;
6
16
  function resolveLib() {
7
17
  const startWait = new Date();
8
18
  return new Promise((resolve, reject) => {
@@ -93,3 +103,11 @@ function wrapElement(container, sitekey, extraParams) {
93
103
  captcha.render();
94
104
  return captcha;
95
105
  }
106
+ function wrapElementWithThrow(container, sitekey, extraParams) {
107
+ return __awaiter(this, void 0, void 0, function* () {
108
+ const params = Object.assign(Object.assign({}, (extraParams || {})), { sitekey });
109
+ const captcha = new RecaptchaElement(container, params);
110
+ yield captcha.render();
111
+ return captcha;
112
+ });
113
+ }
@@ -44,13 +44,25 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
44
44
  if (container.mode === 'bank_account' && container.bankCountry === 'CA') {
45
45
  throw new Error('CardConnect does not support Canadian bank accounts');
46
46
  }
47
+ let effectiveLayout = 'single-line';
48
+ if (container.layout === 'responsive') {
49
+ const containerEl = document.getElementById(container.containerId);
50
+ const containerWidth = (containerEl === null || containerEl === void 0 ? void 0 : containerEl.offsetWidth) || 0;
51
+ const breakpoint = container.responsiveBreakpoint || tokenizer_constants_1.RESPONSIVE_BREAKPOINT;
52
+ effectiveLayout =
53
+ containerWidth < breakpoint ? 'two-line' : 'single-line';
54
+ }
55
+ else if (container.layout === 'two-line') {
56
+ effectiveLayout = 'two-line';
57
+ }
58
+ const resolvedContainer = Object.assign(Object.assign({}, container), { layout: effectiveLayout });
47
59
  let baseUrl = ((_a = gateway.config) === null || _a === void 0 ? void 0 : _a.base_url) || config.clientConfig.cardConnectBaseUrl;
48
60
  config.cardConnectBaseUrl = baseUrl;
49
61
  const mergedStyles = (0, styles_1.mergeStyles)(styles_1.DEFAULT_UNIFIED_STYLES, container.styling);
50
- const iframeUrl = CardConnectTokenizer.generateIframeUrl(baseUrl, container);
62
+ const iframeUrl = CardConnectTokenizer.generateIframeUrl(baseUrl, resolvedContainer);
51
63
  const iframe = CardConnectTokenizer.createIframe(iframeUrl, mergedStyles);
52
- const tokenizer = new CardConnectTokenizer(iframe, iframeUrl, container.containerId, container.mode || 'credit_card', container.enableTestMode || false, container.layout || 'single-line');
53
- tokenizer.createInternalElements(container);
64
+ const tokenizer = new CardConnectTokenizer(iframe, iframeUrl, container.containerId, container.mode || 'credit_card', container.enableTestMode || false, effectiveLayout);
65
+ tokenizer.createInternalElements(resolvedContainer);
54
66
  yield tokenizer.init();
55
67
  return tokenizer;
56
68
  });
@@ -73,7 +85,7 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
73
85
  }
74
86
  createCreditCardFields(containerEl, mergedStyles) {
75
87
  this.iframe.style.width = '100%';
76
- if (this.layout === 'two-line') {
88
+ if (this.layout === 'two-line' || this.layout === 'responsive') {
77
89
  const inputHeight = mergedStyles.input.height || '40px';
78
90
  this.iframe.style.height = `calc((${inputHeight}) * 2 + 10px)`;
79
91
  }
@@ -453,7 +465,8 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
453
465
  : this.normalizeCardType('unknown');
454
466
  return {
455
467
  token: this.cachedTokenResult.token,
456
- lastFour: this.cachedTokenResult.last4 || this.cachedTokenResult.token.slice(-4),
468
+ lastFour: this.cachedTokenResult.last4 ||
469
+ this.cachedTokenResult.token.slice(-4),
457
470
  cardType,
458
471
  provider: 'cardconnect',
459
472
  };
@@ -546,12 +559,15 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
546
559
  errorLower.includes('year')) {
547
560
  this.currentValidationState.expiry = { isValid: false, isEmpty: false };
548
561
  }
549
- this.emit('error', new types_1.TokenizationError(data.validationError));
562
+ this.currentValidationState.isValid = false;
563
+ this.emit('validation', this.currentValidationState);
564
+ }
565
+ else {
566
+ this.currentValidationState.isValid =
567
+ ((_b = (_a = this.currentValidationState.cardNumber) === null || _a === void 0 ? void 0 : _a.isValid) !== null && _b !== void 0 ? _b : false) &&
568
+ ((_d = (_c = this.currentValidationState.cvv) === null || _c === void 0 ? void 0 : _c.isValid) !== null && _d !== void 0 ? _d : false) &&
569
+ ((_f = (_e = this.currentValidationState.expiry) === null || _e === void 0 ? void 0 : _e.isValid) !== null && _f !== void 0 ? _f : false);
550
570
  }
551
- this.currentValidationState.isValid =
552
- ((_b = (_a = this.currentValidationState.cardNumber) === null || _a === void 0 ? void 0 : _a.isValid) !== null && _b !== void 0 ? _b : false) &&
553
- ((_d = (_c = this.currentValidationState.cvv) === null || _c === void 0 ? void 0 : _c.isValid) !== null && _d !== void 0 ? _d : false) &&
554
- ((_f = (_e = this.currentValidationState.expiry) === null || _e === void 0 ? void 0 : _e.isValid) !== null && _f !== void 0 ? _f : false);
555
571
  }
556
572
  static generateIframeUrl(baseUrl, container) {
557
573
  const params = new URLSearchParams({
@@ -580,7 +596,12 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
580
596
  params.set('placeholderyear', 'YYYY');
581
597
  }
582
598
  const mergedStyles = (0, styles_1.mergeStyles)(styles_1.DEFAULT_UNIFIED_STYLES, container.styling);
583
- const cssString = CardConnectTokenizer.generateCardConnectCss(mergedStyles, container.layout || 'single-line');
599
+ const isDesktopSafari = typeof navigator !== 'undefined' &&
600
+ /Safari/.test(navigator.userAgent) &&
601
+ /Apple Computer/.test(navigator.vendor) &&
602
+ !/Chrome/.test(navigator.userAgent) &&
603
+ !/Mobile/.test(navigator.userAgent);
604
+ const cssString = CardConnectTokenizer.generateCardConnectCss(mergedStyles, (container.layout || 'single-line'), isDesktopSafari);
584
605
  const queryPairs = [];
585
606
  params.forEach((value, key) => {
586
607
  queryPairs.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
@@ -613,8 +634,8 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
613
634
  iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-forms');
614
635
  return iframe;
615
636
  }
616
- static generateCardConnectCss(styles, layout = 'single-line') {
617
- var _a, _b, _c, _d;
637
+ static generateCardConnectCss(styles, layout = 'single-line', isDesktopSafari = false) {
638
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
618
639
  const css = [];
619
640
  if (layout === 'two-line') {
620
641
  css.push('html,form,body{margin:0;padding:0;}');
@@ -648,14 +669,22 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
648
669
  commonStyles.push('box-sizing:border-box');
649
670
  const baseStyles = commonStyles.join(';');
650
671
  css.push(`input{${baseStyles};}`);
651
- css.push(`select{${baseStyles};}`);
672
+ if (isDesktopSafari) {
673
+ css.push(`select{${baseStyles};-webkit-appearance:none;appearance:none;}`);
674
+ }
675
+ else {
676
+ css.push(`select{${baseStyles};}`);
677
+ }
652
678
  }
653
679
  if (layout === 'two-line') {
654
680
  css.push('input#ccnumfield{width:100%;display:block;margin-bottom:8px;}');
655
- css.push('input#ccexpiryfieldmonth{width:20%;}');
656
- css.push('input#ccexpiryfieldyear{width:24%;}');
657
- css.push('input#cccvvfield{width:calc(56% - 20px);}');
658
- if ((_a = styles.input) === null || _a === void 0 ? void 0 : _a.borderRadius) {
681
+ const twoLinePadding = ((_a = styles.twoLine) === null || _a === void 0 ? void 0 : _a.padding) || ((_b = styles.input) === null || _b === void 0 ? void 0 : _b.padding) || '10px';
682
+ const twoLineFontSize = ((_c = styles.twoLine) === null || _c === void 0 ? void 0 : _c.fontSize) || ((_d = styles.input) === null || _d === void 0 ? void 0 : _d.fontSize) || '14px';
683
+ const twoLineTextAlign = ((_e = styles.twoLine) === null || _e === void 0 ? void 0 : _e.textAlign) || 'left';
684
+ css.push(`input#ccexpiryfieldmonth{width:25%;padding:${twoLinePadding};font-size:${twoLineFontSize};text-align:${twoLineTextAlign};}`);
685
+ css.push(`input#ccexpiryfieldyear{width:35%;padding:${twoLinePadding};font-size:${twoLineFontSize};text-align:${twoLineTextAlign};}`);
686
+ css.push(`input#cccvvfield{width:calc(40% - 16px);padding:${twoLinePadding};font-size:${twoLineFontSize};text-align:${twoLineTextAlign};margin-left:-4px;}`);
687
+ if ((_f = styles.input) === null || _f === void 0 ? void 0 : _f.borderRadius) {
659
688
  css.push(`input{border-radius:${styles.input.borderRadius};}`);
660
689
  }
661
690
  }
@@ -664,7 +693,7 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
664
693
  css.push('select#ccexpirymonth{width:16%;margin:0;margin-right:-12px;}');
665
694
  css.push('select#ccexpiryyear{width:20%;}');
666
695
  css.push('input#cccvvfield{width:20%;margin:0;margin-left:-12px;}');
667
- if ((_b = styles.input) === null || _b === void 0 ? void 0 : _b.borderRadius) {
696
+ if ((_g = styles.input) === null || _g === void 0 ? void 0 : _g.borderRadius) {
668
697
  css.push(`input#ccnumfield{border-radius:${styles.input.borderRadius} 0 0 ${styles.input.borderRadius};border-right:none;}`);
669
698
  css.push('select#ccexpirymonth{border-radius:0;border-right:none;}');
670
699
  css.push('select#ccexpiryyear{border-radius:0;border-right:none;}');
@@ -682,7 +711,7 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
682
711
  css.push(`select#ccexpirymonth{width:15%;margin-right:${marginRight};}`);
683
712
  css.push(`select#ccexpiryyear{width:20%;margin-right:${marginRight};}`);
684
713
  css.push('input#cccvvfield{width:15%;}');
685
- if ((_c = styles.input) === null || _c === void 0 ? void 0 : _c.borderRadius) {
714
+ if ((_h = styles.input) === null || _h === void 0 ? void 0 : _h.borderRadius) {
686
715
  css.push(`input,select{border-radius:${styles.input.borderRadius};}`);
687
716
  }
688
717
  }
@@ -698,7 +727,7 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
698
727
  if (focusStyles.length > 0) {
699
728
  css.push(`input:focus{${focusStyles.join(';')};}`);
700
729
  css.push(`select:focus{${focusStyles.join(';')};}`);
701
- if (isConnected && ((_d = styles.input) === null || _d === void 0 ? void 0 : _d.border)) {
730
+ if (isConnected && ((_j = styles.input) === null || _j === void 0 ? void 0 : _j.border)) {
702
731
  css.push(`input#ccnumfield:focus{border:${styles.input.border};${focusStyles.join(';')};}`);
703
732
  css.push(`select#ccexpirymonth:focus{border:${styles.input.border};${focusStyles.join(';')};}`);
704
733
  css.push(`select#ccexpiryyear:focus{border:${styles.input.border};${focusStyles.join(';')};}`);
@@ -31,6 +31,10 @@ interface PayPalApproveData {
31
31
  payerID?: string;
32
32
  facilitatorAccessToken?: string;
33
33
  }
34
+ export interface PayPalCreateOrderData {
35
+ amount: number;
36
+ currency?: string;
37
+ }
34
38
  export declare class PayPalTokenizer extends Tokenizer {
35
39
  private gateway;
36
40
  private containerId;
@@ -49,6 +53,7 @@ export declare class PayPalTokenizer extends Tokenizer {
49
53
  private clientConfig;
50
54
  private paymentTransactionId?;
51
55
  private paymentMethodId?;
56
+ private onCreateOrder?;
52
57
  private constructor();
53
58
  static create(gateway: PaymentGateway, container: TokenizerContainer, config: {
54
59
  organizationId: string;
@@ -33,6 +33,7 @@ class PayPalTokenizer extends Tokenizer_1.Tokenizer {
33
33
  this.amount = config.amount;
34
34
  this.enableVenmo = (_b = config.enableVenmo) !== null && _b !== void 0 ? _b : true;
35
35
  this.locale = config.locale || 'en_US';
36
+ this.onCreateOrder = config.onCreateOrder;
36
37
  this.organizationId = configContext.organizationId;
37
38
  this.embedId = configContext.embedId;
38
39
  this.clientConfig = configContext.clientConfig;
@@ -163,13 +164,26 @@ class PayPalTokenizer extends Tokenizer_1.Tokenizer {
163
164
  }
164
165
  createOrder() {
165
166
  const endpoint = `${this.clientConfig.embedApiBaseUrl}/payment/paypal/create-order`;
167
+ let orderAmount;
168
+ let orderCurrency = this.currency;
169
+ if (this.onCreateOrder) {
170
+ const orderData = this.onCreateOrder();
171
+ orderAmount = orderData.amount;
172
+ orderCurrency = orderData.currency || this.currency;
173
+ }
174
+ else {
175
+ orderAmount = this.amount;
176
+ }
177
+ if (orderAmount === undefined || orderAmount <= 0) {
178
+ const error = new Error('Amount is required to create PayPal order');
179
+ this.handleError(error, 'Order creation failed');
180
+ return Promise.reject(error);
181
+ }
166
182
  const requestBody = {
167
183
  payment_gateway_id: this.gateway.id,
168
- currency: this.currency,
184
+ currency: orderCurrency,
185
+ amount: orderAmount,
169
186
  };
170
- if (this.amount !== undefined) {
171
- requestBody.amount = this.amount;
172
- }
173
187
  return fetch(endpoint, {
174
188
  method: 'POST',
175
189
  headers: {
@@ -24,6 +24,11 @@ export declare class SpreedlyTokenizer extends Tokenizer {
24
24
  private institutionNumberEl?;
25
25
  private transitNumberEl?;
26
26
  private enableTestMode;
27
+ private resizeObserver?;
28
+ private effectiveLayout;
29
+ private cardNumberDiv?;
30
+ private cvvDiv?;
31
+ private responsiveBreakpoint;
27
32
  private constructor();
28
33
  static create(gateway: PaymentGateway, container: TokenizerContainer, config: {
29
34
  organizationId: string;
@@ -42,6 +47,9 @@ export declare class SpreedlyTokenizer extends Tokenizer {
42
47
  private stylesToCssString;
43
48
  clear(): void;
44
49
  focus(field: 'cardNumber' | 'cvv' | 'expiry' | 'routingNumber' | 'accountNumber'): void;
50
+ private determineLayout;
51
+ private setupResizeObserver;
52
+ private applyLayoutStyles;
45
53
  destroy(): void;
46
54
  hasToken(): boolean;
47
55
  getToken(): PaymentToken | null;
@@ -67,7 +75,7 @@ export declare class SpreedlyTokenizer extends Tokenizer {
67
75
  });
68
76
  address: Partial<Address>;
69
77
  account: Partial<ACHAccount> & Pick<ACHAccount, 'accountNumber' | 'routingNumber'>;
70
- }, config: ConfigHandler): Promise<string>;
78
+ }, config: ConfigHandler, environmentKeyOverride?: string): Promise<string>;
71
79
  static tokenizeCreditCard(data: {
72
80
  contact: Partial<Contact> & ({
73
81
  firstName: string;
@@ -21,16 +21,19 @@ const tokenizer_utils_1 = require("./tokenizer-utils");
21
21
  const SPREEDLY_SCRIPT_URL = 'https://core.spreedly.com/iframe/iframe-v1.min.js';
22
22
  const SPREEDLY_SCRIPT_ID = 'spreedly-iframe-script';
23
23
  class SpreedlyTokenizer extends Tokenizer_1.Tokenizer {
24
- constructor(environmentKey, containerId, styles, mode = 'credit_card', bankCountry = 'US', enableTestMode = false, layout = 'single-line') {
24
+ constructor(environmentKey, containerId, styles, mode = 'credit_card', bankCountry = 'US', enableTestMode = false, layout = 'single-line', responsiveBreakpoint = tokenizer_constants_1.RESPONSIVE_BREAKPOINT) {
25
25
  super();
26
26
  this.environmentKey = environmentKey;
27
27
  this.containerId = containerId;
28
28
  this.layout = layout;
29
29
  this.bankCountry = 'US';
30
30
  this.enableTestMode = false;
31
+ this.effectiveLayout = 'single-line';
32
+ this.responsiveBreakpoint = tokenizer_constants_1.RESPONSIVE_BREAKPOINT;
31
33
  this.mode = mode;
32
34
  this.bankCountry = bankCountry;
33
35
  this.enableTestMode = enableTestMode;
36
+ this.responsiveBreakpoint = responsiveBreakpoint;
34
37
  if (mode === 'credit_card') {
35
38
  const SpreedlyFrame = window.SpreedlyPaymentFrame;
36
39
  if (SpreedlyFrame) {
@@ -77,7 +80,7 @@ class SpreedlyTokenizer extends Tokenizer_1.Tokenizer {
77
80
  if (!environmentKey) {
78
81
  environmentKey = '';
79
82
  }
80
- const tokenizer = new SpreedlyTokenizer(environmentKey, container.containerId, container.styling, container.mode || 'credit_card', container.bankCountry || 'US', container.enableTestMode || false, container.layout || 'single-line');
83
+ const tokenizer = new SpreedlyTokenizer(environmentKey, container.containerId, container.styling, container.mode || 'credit_card', container.bankCountry || 'US', container.enableTestMode || false, container.layout || 'single-line', container.responsiveBreakpoint || tokenizer_constants_1.RESPONSIVE_BREAKPOINT);
81
84
  tokenizer.organizationId = config.organizationId;
82
85
  tokenizer.embedId = config.embedId;
83
86
  tokenizer.clientConfig = config.clientConfig;
@@ -244,11 +247,11 @@ class SpreedlyTokenizer extends Tokenizer_1.Tokenizer {
244
247
  year: expiryYear,
245
248
  email: cardData.email,
246
249
  phone_number: cardData.phone,
247
- address1: (_a = cardData.address) === null || _a === void 0 ? void 0 : _a.line1,
248
- address2: (_b = cardData.address) === null || _b === void 0 ? void 0 : _b.line2,
250
+ address1: (_a = cardData.address) === null || _a === void 0 ? void 0 : _a.address1,
251
+ address2: (_b = cardData.address) === null || _b === void 0 ? void 0 : _b.address2,
249
252
  city: (_c = cardData.address) === null || _c === void 0 ? void 0 : _c.city,
250
253
  state: (_d = cardData.address) === null || _d === void 0 ? void 0 : _d.state,
251
- zip: (_e = cardData.address) === null || _e === void 0 ? void 0 : _e.postalCode,
254
+ zip: (_e = cardData.address) === null || _e === void 0 ? void 0 : _e.zip,
252
255
  country: (_f = cardData.address) === null || _f === void 0 ? void 0 : _f.country,
253
256
  });
254
257
  });
@@ -429,11 +432,11 @@ class SpreedlyTokenizer extends Tokenizer_1.Tokenizer {
429
432
  primaryPhone: bankData.phone,
430
433
  },
431
434
  address: {
432
- address1: (_g = bankData.address) === null || _g === void 0 ? void 0 : _g.line1,
433
- address2: (_h = bankData.address) === null || _h === void 0 ? void 0 : _h.line2,
435
+ address1: (_g = bankData.address) === null || _g === void 0 ? void 0 : _g.address1,
436
+ address2: (_h = bankData.address) === null || _h === void 0 ? void 0 : _h.address2,
434
437
  city: (_j = bankData.address) === null || _j === void 0 ? void 0 : _j.city,
435
438
  state: (_k = bankData.address) === null || _k === void 0 ? void 0 : _k.state,
436
- zip: (_l = bankData.address) === null || _l === void 0 ? void 0 : _l.postalCode,
439
+ zip: (_l = bankData.address) === null || _l === void 0 ? void 0 : _l.zip,
437
440
  country: (_m = bankData.address) === null || _m === void 0 ? void 0 : _m.country,
438
441
  },
439
442
  account: {
@@ -442,7 +445,7 @@ class SpreedlyTokenizer extends Tokenizer_1.Tokenizer {
442
445
  accountType: accountType,
443
446
  accountHolderType: accountHolderType,
444
447
  },
445
- }, this.clientConfig);
448
+ }, this.clientConfig, this.environmentKey);
446
449
  return {
447
450
  token: result,
448
451
  lastFour: accountNumber.slice(-4),
@@ -585,8 +588,6 @@ class SpreedlyTokenizer extends Tokenizer_1.Tokenizer {
585
588
  }
586
589
  applyUnifiedStyles() {
587
590
  var _a;
588
- if (!this.isReady)
589
- return;
590
591
  const isConnected = ((_a = this.mergedStyles.container) === null || _a === void 0 ? void 0 : _a.gap) === '0';
591
592
  if (this.mergedStyles.input) {
592
593
  if (isConnected) {
@@ -685,7 +686,64 @@ class SpreedlyTokenizer extends Tokenizer_1.Tokenizer {
685
686
  element === null || element === void 0 ? void 0 : element.focus();
686
687
  }
687
688
  }
689
+ determineLayout(width) {
690
+ return width < this.responsiveBreakpoint ? 'two-line' : 'single-line';
691
+ }
692
+ setupResizeObserver() {
693
+ if (this.layout !== 'responsive')
694
+ return;
695
+ const container = document.getElementById(this.containerId);
696
+ if (!container)
697
+ return;
698
+ let debounceTimer;
699
+ this.resizeObserver = new ResizeObserver((entries) => {
700
+ clearTimeout(debounceTimer);
701
+ debounceTimer = setTimeout(() => {
702
+ const newWidth = entries[0].contentRect.width;
703
+ const newLayout = this.determineLayout(newWidth);
704
+ if (newLayout !== this.effectiveLayout) {
705
+ this.applyLayoutStyles(newLayout);
706
+ }
707
+ }, 100);
708
+ });
709
+ this.resizeObserver.observe(container);
710
+ }
711
+ applyLayoutStyles(newLayout) {
712
+ this.effectiveLayout = newLayout;
713
+ const container = document.getElementById(this.containerId);
714
+ if (!container)
715
+ return;
716
+ if (newLayout === 'two-line') {
717
+ container.style.flexWrap = 'wrap';
718
+ if (this.cardNumberDiv) {
719
+ this.cardNumberDiv.style.flex = '1';
720
+ this.cardNumberDiv.style.flexBasis = '100%';
721
+ }
722
+ if (this.expiryEl) {
723
+ this.expiryEl.style.flex = '1';
724
+ this.expiryEl.style.flexBasis = 'auto';
725
+ }
726
+ if (this.cvvDiv) {
727
+ this.cvvDiv.style.flex = '1';
728
+ this.cvvDiv.style.flexBasis = 'auto';
729
+ }
730
+ }
731
+ else {
732
+ container.style.flexWrap = 'nowrap';
733
+ if (this.cardNumberDiv) {
734
+ this.cardNumberDiv.style.flex = tokenizer_constants_1.FIELD_FLEX.cardNumber.flex;
735
+ }
736
+ if (this.expiryEl) {
737
+ this.expiryEl.style.flex = tokenizer_constants_1.FIELD_FLEX.expiry.flex;
738
+ }
739
+ if (this.cvvDiv) {
740
+ this.cvvDiv.style.flex = tokenizer_constants_1.FIELD_FLEX.cvv.flex;
741
+ }
742
+ }
743
+ }
688
744
  destroy() {
745
+ var _a;
746
+ (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
689
747
  if (this.spreedly && this.spreedly.removeHandlers) {
690
748
  this.spreedly.removeHandlers();
691
749
  }
@@ -762,10 +820,18 @@ class SpreedlyTokenizer extends Tokenizer_1.Tokenizer {
762
820
  }
763
821
  }
764
822
  createCreditCardFields(container) {
765
- if (this.layout === 'two-line') {
823
+ if (this.layout === 'responsive') {
824
+ this.effectiveLayout = this.determineLayout(container.offsetWidth);
825
+ }
826
+ else {
827
+ this.effectiveLayout =
828
+ this.layout === 'two-line' ? 'two-line' : 'single-line';
829
+ }
830
+ if (this.effectiveLayout === 'two-line' && this.layout !== 'responsive') {
766
831
  const cardNumberDiv = (0, tokenizer_utils_1.createFieldContainer)(this.numberEl, '1', tokenizer_constants_1.FIELD_FLEX.cardNumber.minWidth);
767
832
  cardNumberDiv.style.height = this.mergedStyles.input.height;
768
833
  cardNumberDiv.style.flexBasis = '100%';
834
+ this.cardNumberDiv = cardNumberDiv;
769
835
  container.appendChild(cardNumberDiv);
770
836
  this.expiryEl = (0, tokenizer_utils_1.createInputElement)(this.expiryId, 'text', tokenizer_constants_1.PLACEHOLDERS.expiry, tokenizer_constants_1.FIELD_CONSTRAINTS.expiry.maxLength);
771
837
  Object.assign(this.expiryEl.style, {
@@ -786,11 +852,13 @@ class SpreedlyTokenizer extends Tokenizer_1.Tokenizer {
786
852
  container.appendChild(this.expiryEl);
787
853
  const cvvDiv = (0, tokenizer_utils_1.createFieldContainer)(this.cvvEl, '1', tokenizer_constants_1.FIELD_FLEX.cvv.minWidth);
788
854
  cvvDiv.style.height = this.mergedStyles.input.height;
855
+ this.cvvDiv = cvvDiv;
789
856
  container.appendChild(cvvDiv);
790
857
  }
791
858
  else {
792
859
  const cardNumberDiv = (0, tokenizer_utils_1.createFieldContainer)(this.numberEl, tokenizer_constants_1.FIELD_FLEX.cardNumber.flex, tokenizer_constants_1.FIELD_FLEX.cardNumber.minWidth);
793
860
  cardNumberDiv.style.height = this.mergedStyles.input.height;
861
+ this.cardNumberDiv = cardNumberDiv;
794
862
  container.appendChild(cardNumberDiv);
795
863
  this.expiryEl = (0, tokenizer_utils_1.createInputElement)(this.expiryId, 'text', tokenizer_constants_1.PLACEHOLDERS.expiry, tokenizer_constants_1.FIELD_CONSTRAINTS.expiry.maxLength);
796
864
  Object.assign(this.expiryEl.style, {
@@ -811,7 +879,12 @@ class SpreedlyTokenizer extends Tokenizer_1.Tokenizer {
811
879
  container.appendChild(this.expiryEl);
812
880
  const cvvDiv = (0, tokenizer_utils_1.createFieldContainer)(this.cvvEl, tokenizer_constants_1.FIELD_FLEX.cvv.flex, tokenizer_constants_1.FIELD_FLEX.cvv.minWidth);
813
881
  cvvDiv.style.height = this.mergedStyles.input.height;
882
+ this.cvvDiv = cvvDiv;
814
883
  container.appendChild(cvvDiv);
884
+ if (this.layout === 'responsive') {
885
+ this.applyLayoutStyles(this.effectiveLayout);
886
+ this.setupResizeObserver();
887
+ }
815
888
  }
816
889
  }
817
890
  createBankAccountFields(container) {
@@ -1035,13 +1108,14 @@ class SpreedlyTokenizer extends Tokenizer_1.Tokenizer {
1035
1108
  throw new Error(`Timeout waiting for global: ${globalName}`);
1036
1109
  });
1037
1110
  }
1038
- static tokenizeBankAccount(data, config) {
1039
- if (config.spreedlyEnvironmentKey === undefined) {
1111
+ static tokenizeBankAccount(data, config, environmentKeyOverride) {
1112
+ const environmentKey = environmentKeyOverride || config.spreedlyEnvironmentKey;
1113
+ if (!environmentKey) {
1040
1114
  return Promise.reject(new Error('Spreedly is not configured.'));
1041
1115
  }
1042
1116
  return fetch(constants_1.SPREEDLY_TOKENIZER_URL +
1043
1117
  '?' +
1044
- new URLSearchParams({ environment_key: config.spreedlyEnvironmentKey }), {
1118
+ new URLSearchParams({ environment_key: environmentKey }), {
1045
1119
  method: 'POST',
1046
1120
  headers: {
1047
1121
  'Content-Type': 'application/json',
@@ -2,6 +2,6 @@ import * as iats from './iats';
2
2
  export { Tokenizer } from './Tokenizer';
3
3
  export { SpreedlyTokenizer } from './SpreedlyTokenizer';
4
4
  export { CardConnectTokenizer } from './CardConnectTokenizer';
5
- export { PayPalTokenizer } from './PayPalTokenizer';
5
+ export { PayPalTokenizer, PayPalCreateOrderData } from './PayPalTokenizer';
6
6
  export { PaymentMethodType, PaymentGateway, TokenizerContainer, TokenizerStyling, CardData, PaymentData, PaymentToken, CardType, TokenizerEvent, ValidationState, ValidationResult, ValidationError, TokenizationError, } from './types';
7
7
  export { iats };
@@ -1,4 +1,4 @@
1
1
  import { TokenizerStyling, TokenizerStylingComplete } from './types';
2
2
  export declare const DEFAULT_UNIFIED_STYLES: TokenizerStylingComplete;
3
3
  export declare function mergeStyles(defaults: TokenizerStylingComplete, userStyles?: TokenizerStyling): TokenizerStylingComplete;
4
- export declare function getContainerStylesForLayout(baseStyles: TokenizerStylingComplete, layout?: 'single-line' | 'two-line'): TokenizerStylingComplete;
4
+ export declare function getContainerStylesForLayout(baseStyles: TokenizerStylingComplete, layout?: 'single-line' | 'two-line' | 'responsive'): TokenizerStylingComplete;
@@ -32,6 +32,11 @@ exports.DEFAULT_UNIFIED_STYLES = {
32
32
  flexWrap: 'nowrap',
33
33
  rowGap: '1rem',
34
34
  },
35
+ twoLine: {
36
+ padding: '',
37
+ fontSize: '',
38
+ textAlign: '',
39
+ },
35
40
  };
36
41
  function mergeStyles(defaults, userStyles) {
37
42
  if (!userStyles)
@@ -41,6 +46,7 @@ function mergeStyles(defaults, userStyles) {
41
46
  focus: Object.assign(Object.assign({}, defaults.focus), userStyles.focus),
42
47
  error: Object.assign(Object.assign({}, defaults.error), userStyles.error),
43
48
  container: Object.assign(Object.assign({}, defaults.container), userStyles.container),
49
+ twoLine: Object.assign(Object.assign({}, defaults.twoLine), userStyles.twoLine),
44
50
  };
45
51
  }
46
52
  function getContainerStylesForLayout(baseStyles, layout = 'single-line') {
@@ -60,3 +60,4 @@ export declare const FIELD_CONSTRAINTS: {
60
60
  readonly maxLength: 4;
61
61
  };
62
62
  };
63
+ export declare const RESPONSIVE_BREAKPOINT = 400;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FIELD_CONSTRAINTS = exports.PLACEHOLDERS = exports.CANADIAN_BANK_FIELD_FLEX = exports.BANK_FIELD_FLEX = exports.FIELD_FLEX = exports.TOKENIZE_TIMEOUT = exports.INIT_TIMEOUT = void 0;
3
+ exports.RESPONSIVE_BREAKPOINT = exports.FIELD_CONSTRAINTS = exports.PLACEHOLDERS = exports.CANADIAN_BANK_FIELD_FLEX = exports.BANK_FIELD_FLEX = exports.FIELD_FLEX = exports.TOKENIZE_TIMEOUT = exports.INIT_TIMEOUT = void 0;
4
4
  exports.INIT_TIMEOUT = 10000;
5
5
  exports.TOKENIZE_TIMEOUT = 30000;
6
6
  exports.FIELD_FLEX = {
@@ -63,3 +63,4 @@ exports.FIELD_CONSTRAINTS = {
63
63
  maxLength: 4,
64
64
  },
65
65
  };
66
+ exports.RESPONSIVE_BREAKPOINT = 400;
@@ -18,7 +18,8 @@ export interface TokenizerContainer {
18
18
  mode?: PaymentMethodMode;
19
19
  bankCountry?: 'US' | 'CA';
20
20
  enableTestMode?: boolean;
21
- layout?: 'single-line' | 'two-line';
21
+ layout?: 'single-line' | 'two-line' | 'responsive';
22
+ responsiveBreakpoint?: number;
22
23
  }
23
24
  export interface TokenizerStylingComplete {
24
25
  input: {
@@ -52,6 +53,11 @@ export interface TokenizerStylingComplete {
52
53
  flexWrap?: string;
53
54
  rowGap?: string;
54
55
  };
56
+ twoLine: {
57
+ padding: string;
58
+ fontSize: string;
59
+ textAlign: string;
60
+ };
55
61
  }
56
62
  type DeepPartial<T> = T extends object ? {
57
63
  [P in keyof T]?: DeepPartial<T[P]>;
@@ -63,11 +69,11 @@ export interface CardData {
63
69
  email?: string;
64
70
  phone?: string;
65
71
  address?: {
66
- line1?: string;
67
- line2?: string;
72
+ address1?: string;
73
+ address2?: string;
68
74
  city?: string;
69
75
  state?: string;
70
- postalCode?: string;
76
+ zip?: string;
71
77
  country?: string;
72
78
  };
73
79
  }
@@ -77,11 +83,11 @@ export interface BankAccountData {
77
83
  email?: string;
78
84
  phone?: string;
79
85
  address?: {
80
- line1?: string;
81
- line2?: string;
86
+ address1?: string;
87
+ address2?: string;
82
88
  city?: string;
83
89
  state?: string;
84
- postalCode?: string;
90
+ zip?: string;
85
91
  country?: string;
86
92
  };
87
93
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@idonatedev/idonate-sdk",
3
3
  "author": "iDonate",
4
- "version": "1.2.0-dev1",
4
+ "version": "1.2.0-dev11",
5
5
  "sideEffects": false,
6
6
  "description": "iDonate Web SDK",
7
7
  "engines": {
@@ -89,5 +89,6 @@
89
89
  "@types/spreedly-iframe-browser": "^1.0.3",
90
90
  "@types/uuid": "^8.3.1",
91
91
  "uuid": "^8.3.2"
92
- }
92
+ },
93
+ "packageManager": "pnpm@10.15.1+sha512.34e538c329b5553014ca8e8f4535997f96180a1d0f614339357449935350d924e22f8614682191264ec33d1462ac21561aff97f6bb18065351c162c7e8f6de67"
93
94
  }