@getopenpay/openpay-js-react 0.0.5-alpha.c8e4dd5 → 0.0.6-alpha.2dd4240

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/index.d.ts CHANGED
@@ -45,7 +45,7 @@ export declare type ElementsFormProps = {
45
45
  onLoadError?: (message: string) => void;
46
46
  onValidationError?: (field: AllFieldNames, errors: string[], elementId?: string) => void;
47
47
  onCheckoutStarted?: () => void;
48
- onCheckoutSuccess?: (invoiceUrls: string[]) => void;
48
+ onCheckoutSuccess?: (invoiceUrls: string[], subscriptionIds: string[], customerId: string) => void;
49
49
  onCheckoutError?: (message: string) => void;
50
50
  baseUrl?: string;
51
51
  };
package/dist/index.js CHANGED
@@ -38,7 +38,7 @@ function Tt(r, e, t) {
38
38
  var n = r.random || (r.rng || ir)();
39
39
  return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, sr(n);
40
40
  }
41
- var _;
41
+ var x;
42
42
  (function(r) {
43
43
  r.assertEqual = (s) => s;
44
44
  function e(s) {
@@ -73,7 +73,7 @@ var _;
73
73
  return s.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
74
74
  }
75
75
  r.joinValues = n, r.jsonStringifyReplacer = (s, a) => typeof a == "bigint" ? a.toString() : a;
76
- })(_ || (_ = {}));
76
+ })(x || (x = {}));
77
77
  var nt;
78
78
  (function(r) {
79
79
  r.mergeShapes = (e, t) => ({
@@ -82,7 +82,7 @@ var nt;
82
82
  // second overwrites first
83
83
  });
84
84
  })(nt || (nt = {}));
85
- const f = _.arrayToEnum([
85
+ const f = x.arrayToEnum([
86
86
  "string",
87
87
  "nan",
88
88
  "number",
@@ -124,7 +124,7 @@ const f = _.arrayToEnum([
124
124
  default:
125
125
  return f.unknown;
126
126
  }
127
- }, c = _.arrayToEnum([
127
+ }, c = x.arrayToEnum([
128
128
  "invalid_type",
129
129
  "invalid_literal",
130
130
  "custom",
@@ -186,7 +186,7 @@ class Z extends Error {
186
186
  return this.message;
187
187
  }
188
188
  get message() {
189
- return JSON.stringify(this.issues, _.jsonStringifyReplacer, 2);
189
+ return JSON.stringify(this.issues, x.jsonStringifyReplacer, 2);
190
190
  }
191
191
  get isEmpty() {
192
192
  return this.issues.length === 0;
@@ -209,19 +209,19 @@ const le = (r, e) => {
209
209
  r.received === f.undefined ? t = "Required" : t = `Expected ${r.expected}, received ${r.received}`;
210
210
  break;
211
211
  case c.invalid_literal:
212
- t = `Invalid literal value, expected ${JSON.stringify(r.expected, _.jsonStringifyReplacer)}`;
212
+ t = `Invalid literal value, expected ${JSON.stringify(r.expected, x.jsonStringifyReplacer)}`;
213
213
  break;
214
214
  case c.unrecognized_keys:
215
- t = `Unrecognized key(s) in object: ${_.joinValues(r.keys, ", ")}`;
215
+ t = `Unrecognized key(s) in object: ${x.joinValues(r.keys, ", ")}`;
216
216
  break;
217
217
  case c.invalid_union:
218
218
  t = "Invalid input";
219
219
  break;
220
220
  case c.invalid_union_discriminator:
221
- t = `Invalid discriminator value. Expected ${_.joinValues(r.options)}`;
221
+ t = `Invalid discriminator value. Expected ${x.joinValues(r.options)}`;
222
222
  break;
223
223
  case c.invalid_enum_value:
224
- t = `Invalid enum value. Expected ${_.joinValues(r.options)}, received '${r.received}'`;
224
+ t = `Invalid enum value. Expected ${x.joinValues(r.options)}, received '${r.received}'`;
225
225
  break;
226
226
  case c.invalid_arguments:
227
227
  t = "Invalid function arguments";
@@ -233,7 +233,7 @@ const le = (r, e) => {
233
233
  t = "Invalid date";
234
234
  break;
235
235
  case c.invalid_string:
236
- typeof r.validation == "object" ? "includes" in r.validation ? (t = `Invalid input: must include "${r.validation.includes}"`, typeof r.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${r.validation.position}`)) : "startsWith" in r.validation ? t = `Invalid input: must start with "${r.validation.startsWith}"` : "endsWith" in r.validation ? t = `Invalid input: must end with "${r.validation.endsWith}"` : _.assertNever(r.validation) : r.validation !== "regex" ? t = `Invalid ${r.validation}` : t = "Invalid";
236
+ typeof r.validation == "object" ? "includes" in r.validation ? (t = `Invalid input: must include "${r.validation.includes}"`, typeof r.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${r.validation.position}`)) : "startsWith" in r.validation ? t = `Invalid input: must start with "${r.validation.startsWith}"` : "endsWith" in r.validation ? t = `Invalid input: must end with "${r.validation.endsWith}"` : x.assertNever(r.validation) : r.validation !== "regex" ? t = `Invalid ${r.validation}` : t = "Invalid";
237
237
  break;
238
238
  case c.too_small:
239
239
  r.type === "array" ? t = `Array must contain ${r.exact ? "exactly" : r.inclusive ? "at least" : "more than"} ${r.minimum} element(s)` : r.type === "string" ? t = `String must contain ${r.exact ? "exactly" : r.inclusive ? "at least" : "over"} ${r.minimum} character(s)` : r.type === "number" ? t = `Number must be ${r.exact ? "exactly equal to " : r.inclusive ? "greater than or equal to " : "greater than "}${r.minimum}` : r.type === "date" ? t = `Date must be ${r.exact ? "exactly equal to " : r.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(r.minimum))}` : t = "Invalid input";
@@ -254,7 +254,7 @@ const le = (r, e) => {
254
254
  t = "Number must be finite";
255
255
  break;
256
256
  default:
257
- t = e.defaultError, _.assertNever(r);
257
+ t = e.defaultError, x.assertNever(r);
258
258
  }
259
259
  return { message: t };
260
260
  };
@@ -344,7 +344,7 @@ class S {
344
344
  }
345
345
  const y = Object.freeze({
346
346
  status: "aborted"
347
- }), de = (r) => ({ status: "dirty", value: r }), R = (r) => ({ status: "valid", value: r }), st = (r) => r.status === "aborted", at = (r) => r.status === "dirty", ge = (r) => r.status === "valid", _e = (r) => typeof Promise < "u" && r instanceof Promise;
347
+ }), de = (r) => ({ status: "dirty", value: r }), O = (r) => ({ status: "valid", value: r }), st = (r) => r.status === "aborted", at = (r) => r.status === "dirty", ge = (r) => r.status === "valid", _e = (r) => typeof Promise < "u" && r instanceof Promise;
348
348
  function ze(r, e, t, n) {
349
349
  if (typeof e == "function" ? r !== e || !n : !e.has(r)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
350
350
  return e.get(r);
@@ -734,7 +734,7 @@ class j extends g {
734
734
  validation: "base64",
735
735
  code: c.invalid_string,
736
736
  message: a.message
737
- }), n.dirty()) : _.assertNever(a);
737
+ }), n.dirty()) : x.assertNever(a);
738
738
  return { status: n.value, value: e.data };
739
739
  }
740
740
  _regex(e, t, n) {
@@ -972,7 +972,7 @@ class W extends g {
972
972
  let n;
973
973
  const s = new S();
974
974
  for (const a of this._def.checks)
975
- a.kind === "int" ? _.isInteger(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
975
+ a.kind === "int" ? x.isInteger(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
976
976
  code: c.invalid_type,
977
977
  expected: "integer",
978
978
  received: "float",
@@ -998,7 +998,7 @@ class W extends g {
998
998
  }), s.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
999
999
  code: c.not_finite,
1000
1000
  message: a.message
1001
- }), s.dirty()) : _.assertNever(a);
1001
+ }), s.dirty()) : x.assertNever(a);
1002
1002
  return { status: s.value, value: e.data };
1003
1003
  }
1004
1004
  gte(e, t) {
@@ -1110,7 +1110,7 @@ class W extends g {
1110
1110
  return e;
1111
1111
  }
1112
1112
  get isInt() {
1113
- return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && _.isInteger(e.value));
1113
+ return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && x.isInteger(e.value));
1114
1114
  }
1115
1115
  get isFinite() {
1116
1116
  let e = null, t = null;
@@ -1160,7 +1160,7 @@ class J extends g {
1160
1160
  code: c.not_multiple_of,
1161
1161
  multipleOf: a.value,
1162
1162
  message: a.message
1163
- }), s.dirty()) : _.assertNever(a);
1163
+ }), s.dirty()) : x.assertNever(a);
1164
1164
  return { status: s.value, value: e.data };
1165
1165
  }
1166
1166
  gte(e, t) {
@@ -1266,7 +1266,7 @@ class xe extends g {
1266
1266
  received: n.parsedType
1267
1267
  }), y;
1268
1268
  }
1269
- return R(e.data);
1269
+ return O(e.data);
1270
1270
  }
1271
1271
  }
1272
1272
  xe.create = (r) => new xe({
@@ -1307,7 +1307,7 @@ class ee extends g {
1307
1307
  exact: !1,
1308
1308
  maximum: a.value,
1309
1309
  type: "date"
1310
- }), n.dirty()) : _.assertNever(a);
1310
+ }), n.dirty()) : x.assertNever(a);
1311
1311
  return {
1312
1312
  status: n.value,
1313
1313
  value: new Date(e.data.getTime())
@@ -1362,7 +1362,7 @@ class Be extends g {
1362
1362
  received: n.parsedType
1363
1363
  }), y;
1364
1364
  }
1365
- return R(e.data);
1365
+ return O(e.data);
1366
1366
  }
1367
1367
  }
1368
1368
  Be.create = (r) => new Be({
@@ -1379,7 +1379,7 @@ class be extends g {
1379
1379
  received: n.parsedType
1380
1380
  }), y;
1381
1381
  }
1382
- return R(e.data);
1382
+ return O(e.data);
1383
1383
  }
1384
1384
  }
1385
1385
  be.create = (r) => new be({
@@ -1396,7 +1396,7 @@ class ke extends g {
1396
1396
  received: n.parsedType
1397
1397
  }), y;
1398
1398
  }
1399
- return R(e.data);
1399
+ return O(e.data);
1400
1400
  }
1401
1401
  }
1402
1402
  ke.create = (r) => new ke({
@@ -1408,7 +1408,7 @@ class fe extends g {
1408
1408
  super(...arguments), this._any = !0;
1409
1409
  }
1410
1410
  _parse(e) {
1411
- return R(e.data);
1411
+ return O(e.data);
1412
1412
  }
1413
1413
  }
1414
1414
  fe.create = (r) => new fe({
@@ -1420,7 +1420,7 @@ class Q extends g {
1420
1420
  super(...arguments), this._unknown = !0;
1421
1421
  }
1422
1422
  _parse(e) {
1423
- return R(e.data);
1423
+ return O(e.data);
1424
1424
  }
1425
1425
  }
1426
1426
  Q.create = (r) => new Q({
@@ -1451,7 +1451,7 @@ class qe extends g {
1451
1451
  received: n.parsedType
1452
1452
  }), y;
1453
1453
  }
1454
- return R(e.data);
1454
+ return O(e.data);
1455
1455
  }
1456
1456
  }
1457
1457
  qe.create = (r) => new qe({
@@ -1554,7 +1554,7 @@ class b extends g {
1554
1554
  _getCached() {
1555
1555
  if (this._cached !== null)
1556
1556
  return this._cached;
1557
- const e = this._def.shape(), t = _.objectKeys(e);
1557
+ const e = this._def.shape(), t = x.objectKeys(e);
1558
1558
  return this._cached = { shape: e, keys: t };
1559
1559
  }
1560
1560
  _parse(e) {
@@ -1761,7 +1761,7 @@ class b extends g {
1761
1761
  }
1762
1762
  pick(e) {
1763
1763
  const t = {};
1764
- return _.objectKeys(e).forEach((n) => {
1764
+ return x.objectKeys(e).forEach((n) => {
1765
1765
  e[n] && this.shape[n] && (t[n] = this.shape[n]);
1766
1766
  }), new b({
1767
1767
  ...this._def,
@@ -1770,7 +1770,7 @@ class b extends g {
1770
1770
  }
1771
1771
  omit(e) {
1772
1772
  const t = {};
1773
- return _.objectKeys(this.shape).forEach((n) => {
1773
+ return x.objectKeys(this.shape).forEach((n) => {
1774
1774
  e[n] || (t[n] = this.shape[n]);
1775
1775
  }), new b({
1776
1776
  ...this._def,
@@ -1785,7 +1785,7 @@ class b extends g {
1785
1785
  }
1786
1786
  partial(e) {
1787
1787
  const t = {};
1788
- return _.objectKeys(this.shape).forEach((n) => {
1788
+ return x.objectKeys(this.shape).forEach((n) => {
1789
1789
  const s = this.shape[n];
1790
1790
  e && !e[n] ? t[n] = s : t[n] = s.optional();
1791
1791
  }), new b({
@@ -1795,7 +1795,7 @@ class b extends g {
1795
1795
  }
1796
1796
  required(e) {
1797
1797
  const t = {};
1798
- return _.objectKeys(this.shape).forEach((n) => {
1798
+ return x.objectKeys(this.shape).forEach((n) => {
1799
1799
  if (e && !e[n])
1800
1800
  t[n] = this.shape[n];
1801
1801
  else {
@@ -1810,7 +1810,7 @@ class b extends g {
1810
1810
  });
1811
1811
  }
1812
1812
  keyof() {
1813
- return It(_.objectKeys(this.shape));
1813
+ return It(x.objectKeys(this.shape));
1814
1814
  }
1815
1815
  }
1816
1816
  b.create = (r, e) => new b({
@@ -1907,7 +1907,7 @@ we.create = (r, e) => new we({
1907
1907
  typeName: m.ZodUnion,
1908
1908
  ...v(e)
1909
1909
  });
1910
- const V = (r) => r instanceof Se ? V(r.schema) : r instanceof D ? V(r.innerType()) : r instanceof Ce ? [r.value] : r instanceof Y ? r.options : r instanceof Re ? _.objectValues(r.enum) : r instanceof Oe ? V(r._def.innerType) : r instanceof be ? [void 0] : r instanceof ke ? [null] : r instanceof U ? [void 0, ...V(r.unwrap())] : r instanceof G ? [null, ...V(r.unwrap())] : r instanceof ot || r instanceof Ze ? V(r.unwrap()) : r instanceof Ie ? V(r._def.innerType) : [];
1910
+ const V = (r) => r instanceof Se ? V(r.schema) : r instanceof D ? V(r.innerType()) : r instanceof Ce ? [r.value] : r instanceof Y ? r.options : r instanceof Re ? x.objectValues(r.enum) : r instanceof Oe ? V(r._def.innerType) : r instanceof be ? [void 0] : r instanceof ke ? [null] : r instanceof U ? [void 0, ...V(r.unwrap())] : r instanceof G ? [null, ...V(r.unwrap())] : r instanceof ot || r instanceof Ze ? V(r.unwrap()) : r instanceof Ie ? V(r._def.innerType) : [];
1911
1911
  class We extends g {
1912
1912
  _parse(e) {
1913
1913
  const { ctx: t } = this._processInputParams(e);
@@ -1975,7 +1975,7 @@ function it(r, e) {
1975
1975
  if (r === e)
1976
1976
  return { valid: !0, data: r };
1977
1977
  if (t === f.object && n === f.object) {
1978
- const s = _.objectKeys(e), a = _.objectKeys(r).filter((o) => s.indexOf(o) !== -1), i = { ...r, ...e };
1978
+ const s = x.objectKeys(e), a = x.objectKeys(r).filter((o) => s.indexOf(o) !== -1), i = { ...r, ...e };
1979
1979
  for (const o of a) {
1980
1980
  const u = it(r[o], e[o]);
1981
1981
  if (!u.valid)
@@ -2284,7 +2284,7 @@ class ue extends g {
2284
2284
  const a = { errorMap: t.common.contextualErrorMap }, i = t.data;
2285
2285
  if (this._def.returns instanceof he) {
2286
2286
  const o = this;
2287
- return R(async function(...u) {
2287
+ return O(async function(...u) {
2288
2288
  const d = new Z([]), p = await o._def.args.parseAsync(u, a).catch((F) => {
2289
2289
  throw d.addIssue(n(u, F)), d;
2290
2290
  }), w = await Reflect.apply(i, this, p);
@@ -2294,7 +2294,7 @@ class ue extends g {
2294
2294
  });
2295
2295
  } else {
2296
2296
  const o = this;
2297
- return R(function(...u) {
2297
+ return O(function(...u) {
2298
2298
  const d = o._def.args.safeParse(u, a);
2299
2299
  if (!d.success)
2300
2300
  throw new Z([n(u, d.error)]);
@@ -2388,7 +2388,7 @@ class Y extends g {
2388
2388
  if (typeof e.data != "string") {
2389
2389
  const t = this._getOrReturnCtx(e), n = this._def.values;
2390
2390
  return l(t, {
2391
- expected: _.joinValues(n),
2391
+ expected: x.joinValues(n),
2392
2392
  received: t.parsedType,
2393
2393
  code: c.invalid_type
2394
2394
  }), y;
@@ -2401,7 +2401,7 @@ class Y extends g {
2401
2401
  options: n
2402
2402
  }), y;
2403
2403
  }
2404
- return R(e.data);
2404
+ return O(e.data);
2405
2405
  }
2406
2406
  get options() {
2407
2407
  return this._def.values;
@@ -2444,24 +2444,24 @@ class Re extends g {
2444
2444
  super(...arguments), ye.set(this, void 0);
2445
2445
  }
2446
2446
  _parse(e) {
2447
- const t = _.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
2447
+ const t = x.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
2448
2448
  if (n.parsedType !== f.string && n.parsedType !== f.number) {
2449
- const s = _.objectValues(t);
2449
+ const s = x.objectValues(t);
2450
2450
  return l(n, {
2451
- expected: _.joinValues(s),
2451
+ expected: x.joinValues(s),
2452
2452
  received: n.parsedType,
2453
2453
  code: c.invalid_type
2454
2454
  }), y;
2455
2455
  }
2456
- if (ze(this, ye) || St(this, ye, new Set(_.getValidEnumValues(this._def.values))), !ze(this, ye).has(e.data)) {
2457
- const s = _.objectValues(t);
2456
+ if (ze(this, ye) || St(this, ye, new Set(x.getValidEnumValues(this._def.values))), !ze(this, ye).has(e.data)) {
2457
+ const s = x.objectValues(t);
2458
2458
  return l(n, {
2459
2459
  received: n.data,
2460
2460
  code: c.invalid_enum_value,
2461
2461
  options: s
2462
2462
  }), y;
2463
2463
  }
2464
- return R(e.data);
2464
+ return O(e.data);
2465
2465
  }
2466
2466
  get enum() {
2467
2467
  return this._def.values;
@@ -2486,7 +2486,7 @@ class he extends g {
2486
2486
  received: t.parsedType
2487
2487
  }), y;
2488
2488
  const n = t.parsedType === f.promise ? t.data : Promise.resolve(t.data);
2489
- return R(n.then((s) => this._def.type.parseAsync(s, {
2489
+ return O(n.then((s) => this._def.type.parseAsync(s, {
2490
2490
  path: t.path,
2491
2491
  errorMap: t.common.contextualErrorMap
2492
2492
  })));
@@ -2571,7 +2571,7 @@ class D extends g {
2571
2571
  return { status: t.value, value: o };
2572
2572
  } else
2573
2573
  return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((i) => ge(i) ? Promise.resolve(s.transform(i.value, a)).then((o) => ({ status: t.value, value: o })) : i);
2574
- _.assertNever(s);
2574
+ x.assertNever(s);
2575
2575
  }
2576
2576
  }
2577
2577
  D.create = (r, e, t) => new D({
@@ -2588,7 +2588,7 @@ D.createWithPreprocess = (r, e, t) => new D({
2588
2588
  });
2589
2589
  class U extends g {
2590
2590
  _parse(e) {
2591
- return this._getType(e) === f.undefined ? R(void 0) : this._def.innerType._parse(e);
2591
+ return this._getType(e) === f.undefined ? O(void 0) : this._def.innerType._parse(e);
2592
2592
  }
2593
2593
  unwrap() {
2594
2594
  return this._def.innerType;
@@ -2601,7 +2601,7 @@ U.create = (r, e) => new U({
2601
2601
  });
2602
2602
  class G extends g {
2603
2603
  _parse(e) {
2604
- return this._getType(e) === f.null ? R(null) : this._def.innerType._parse(e);
2604
+ return this._getType(e) === f.null ? O(null) : this._def.innerType._parse(e);
2605
2605
  }
2606
2606
  unwrap() {
2607
2607
  return this._def.innerType;
@@ -2788,7 +2788,7 @@ const Rr = (r, e = {
2788
2788
  bigint: (r) => J.create({ ...r, coerce: !0 }),
2789
2789
  date: (r) => ee.create({ ...r, coerce: !0 })
2790
2790
  }, un = y;
2791
- var x = /* @__PURE__ */ Object.freeze({
2791
+ var _ = /* @__PURE__ */ Object.freeze({
2792
2792
  __proto__: null,
2793
2793
  defaultErrorMap: le,
2794
2794
  setErrorMap: dr,
@@ -2799,13 +2799,13 @@ var x = /* @__PURE__ */ Object.freeze({
2799
2799
  ParseStatus: S,
2800
2800
  INVALID: y,
2801
2801
  DIRTY: de,
2802
- OK: R,
2802
+ OK: O,
2803
2803
  isAborted: st,
2804
2804
  isDirty: at,
2805
2805
  isValid: ge,
2806
2806
  isAsync: _e,
2807
2807
  get util() {
2808
- return _;
2808
+ return x;
2809
2809
  },
2810
2810
  get objectUtil() {
2811
2811
  return nt;
@@ -2904,12 +2904,12 @@ var x = /* @__PURE__ */ Object.freeze({
2904
2904
  quotelessJson: cr,
2905
2905
  ZodError: Z
2906
2906
  });
2907
- const N = x.string().trim().min(1, { message: "Cannot be blank" }), q = x.string().trim().optional();
2907
+ const N = _.string().trim().min(1, { message: "Cannot be blank" }), q = _.string().trim().optional();
2908
2908
  var Pt = /* @__PURE__ */ ((r) => (r.FIRST_NAME = "firstName", r.LAST_NAME = "lastName", r.EMAIL = "email", r.ZIP_CODE = "zipCode", r.CITY = "city", r.STATE = "state", r.COUNTRY = "country", r.ADDRESS = "address", r.PHONE = "phone", r))(Pt || {});
2909
- const Dt = x.nativeEnum(Pt);
2909
+ const Dt = _.nativeEnum(Pt);
2910
2910
  var Ut = /* @__PURE__ */ ((r) => (r.CARD_NUMBER = "cardNumber", r.CARD_EXPIRY = "cardExpiry", r.CARD_CVC = "cardCvc", r))(Ut || {});
2911
- const Lt = x.nativeEnum(Ut), ln = x.union([Dt, Lt]);
2912
- x.object({
2911
+ const Lt = _.nativeEnum(Ut), ln = _.union([Dt, Lt]);
2912
+ _.object({
2913
2913
  backgroundColor: q,
2914
2914
  color: q,
2915
2915
  fontFamily: q,
@@ -2918,7 +2918,7 @@ x.object({
2918
2918
  margin: q,
2919
2919
  padding: q
2920
2920
  });
2921
- const k = x.enum([
2921
+ const k = _.enum([
2922
2922
  // Element -> Form
2923
2923
  "LOADED",
2924
2924
  "BLUR",
@@ -2935,24 +2935,24 @@ const k = x.enum([
2935
2935
  // Form -> Element
2936
2936
  "TOKENIZE",
2937
2937
  "CHECKOUT"
2938
- ]), fn = k.extract(["TOKENIZE_STARTED", "CHECKOUT_STARTED"]), hn = x.object({ type: fn }), pn = k.extract(["BLUR", "FOCUS", "CHANGE"]), mn = x.object({
2938
+ ]), fn = k.extract(["TOKENIZE_STARTED", "CHECKOUT_STARTED"]), hn = _.object({ type: fn }), pn = k.extract(["BLUR", "FOCUS", "CHANGE"]), mn = _.object({
2939
2939
  type: pn,
2940
2940
  elementType: Lt
2941
- }), yn = k.extract(["LOAD_ERROR", "TOKENIZE_ERROR", "CHECKOUT_ERROR"]), vn = x.object({
2941
+ }), yn = k.extract(["LOAD_ERROR", "TOKENIZE_ERROR", "CHECKOUT_ERROR"]), vn = _.object({
2942
2942
  type: yn,
2943
2943
  message: N
2944
- }), gn = k.extract(["VALIDATION_ERROR"]), _n = x.object({
2944
+ }), gn = k.extract(["VALIDATION_ERROR"]), _n = _.object({
2945
2945
  type: gn,
2946
2946
  elementType: ln,
2947
- errors: x.array(x.string())
2948
- }), xn = x.object({
2949
- type: x.literal(k.enum.LOADED),
2947
+ errors: _.array(_.string())
2948
+ }), xn = _.object({
2949
+ type: _.literal(k.enum.LOADED),
2950
2950
  sessionId: N,
2951
2951
  height: N,
2952
- totalAmountAtoms: x.number(),
2952
+ totalAmountAtoms: _.number(),
2953
2953
  currency: q,
2954
- stripePubKey: x.nullable(x.string())
2955
- }), bn = k.extract(["TOKENIZE", "CHECKOUT"]), Mt = x.object({
2954
+ stripePubKey: _.nullable(_.string())
2955
+ }), bn = k.extract(["TOKENIZE", "CHECKOUT"]), Mt = _.object({
2956
2956
  type: bn,
2957
2957
  sessionId: N,
2958
2958
  firstName: N,
@@ -2960,13 +2960,15 @@ const k = x.enum([
2960
2960
  email: N,
2961
2961
  zipCode: N,
2962
2962
  country: N
2963
- }), kn = x.object({
2964
- type: x.literal(k.enum.TOKENIZE_SUCCESS),
2965
- isReadyForCheckout: x.boolean()
2966
- }), wn = x.object({
2967
- type: x.literal(k.enum.CHECKOUT_SUCCESS),
2968
- invoiceUrls: x.array(x.string())
2969
- }), Tn = x.discriminatedUnion("type", [
2963
+ }), kn = _.object({
2964
+ type: _.literal(k.enum.TOKENIZE_SUCCESS),
2965
+ isReadyForCheckout: _.boolean()
2966
+ }), wn = _.object({
2967
+ type: _.literal(k.enum.CHECKOUT_SUCCESS),
2968
+ invoiceUrls: _.array(_.string()),
2969
+ subscriptionIds: _.array(_.string()),
2970
+ customerId: _.string()
2971
+ }), Tn = _.discriminatedUnion("type", [
2970
2972
  hn,
2971
2973
  mn,
2972
2974
  vn,
@@ -2975,16 +2977,16 @@ const k = x.enum([
2975
2977
  Mt,
2976
2978
  kn,
2977
2979
  wn
2978
- ]), En = x.object({
2980
+ ]), En = _.object({
2979
2981
  payload: Tn,
2980
2982
  nonce: N,
2981
2983
  formId: N,
2982
2984
  elementId: N
2983
2985
  });
2984
- x.object({
2985
- isLoading: x.boolean(),
2986
- isAvailable: x.boolean(),
2987
- startFlow: x.function(x.tuple([]), x.void())
2986
+ _.object({
2987
+ isLoading: _.boolean(),
2988
+ isAvailable: _.boolean(),
2989
+ startFlow: _.function(_.tuple([]), _.void())
2988
2990
  });
2989
2991
  const Sn = (r) => {
2990
2992
  const e = {};
@@ -3100,13 +3102,13 @@ const Sn = (r) => {
3100
3102
  onCheckoutError: $,
3101
3103
  baseUrl: F
3102
3104
  } = r, B = F ?? On, [X, $t] = E(void 0), [ct, Vt] = E([]), [zt, Bt] = E("1px"), [dt, qt] = E(!1), [Ye, ut] = E(void 0), [lt, Ae] = E(!1), [re, Ht] = E([]), [ne, Kt] = E({}), [ft, ht] = E(0), [pt, mt] = E(!1), [se, Wt] = E(void 0), [Ge, Jt] = E(void 0), [je, Yt] = E(void 0), [Pe, Gt] = E(null), Ft = Dn(Pe == null ? void 0 : Pe.stripePubKey, je, Ge), ae = Me(() => `opjs-form-${Tt()}`, []), pe = kt(null), Fe = Ue(
3103
- (O) => {
3104
- if (O.origin !== B || !O.source) return;
3105
- const ie = O.source, C = Rn(JSON.parse(O.data)), De = C.elementId;
3105
+ (I) => {
3106
+ if (I.origin !== B || !I.source) return;
3107
+ const ie = I.source, C = Rn(JSON.parse(I.data)), De = C.elementId;
3106
3108
  if (C.formId !== ae || !De || C.nonce in ct)
3107
3109
  return;
3108
3110
  Vt((oe) => [...oe, C.nonce]);
3109
- const I = C.payload, A = I.type;
3111
+ const R = C.payload, A = R.type;
3110
3112
  if (A === k.enum.FOCUS && s)
3111
3113
  s(C.elementId);
3112
3114
  else if (A === k.enum.BLUR && a)
@@ -3118,14 +3120,14 @@ const Sn = (r) => {
3118
3120
  if (Ae(!1), !oe)
3119
3121
  return;
3120
3122
  Kt((et) => ({ ...et, [De]: ie }));
3121
- const Qe = I.height ? `${I.height}px` : "100%";
3122
- Bt(Qe), Yt(I.totalAmountAtoms), Jt(I.currency), Gt(Zn(I)), se || Wt(I.sessionId);
3123
+ const Qe = R.height ? `${R.height}px` : "100%";
3124
+ Bt(Qe), Yt(R.totalAmountAtoms), Jt(R.currency), Gt(Zn(R)), se || Wt(R.sessionId);
3123
3125
  } else if (A === k.enum.TOKENIZE_STARTED)
3124
3126
  Ae(!0), p && p();
3125
3127
  else if (A === k.enum.TOKENIZE_SUCCESS && Ye) {
3126
3128
  const oe = ft + 1, Qe = oe === Object.keys(ne).length;
3127
- !pt && (Qe || I.isReadyForCheckout) ? (_t(ie, ae, De, Ye, B), mt(!0), ut(void 0)) : ht(oe);
3128
- } else A === k.enum.CHECKOUT_SUCCESS ? (Ae(!1), ht(0), mt(!1), w && w(I.invoiceUrls)) : A === k.enum.LOAD_ERROR ? u && u(I.message) : A === k.enum.VALIDATION_ERROR ? d && d(I.elementType, I.errors, De) : (A === k.enum.TOKENIZE_ERROR || A === k.enum.CHECKOUT_ERROR) && (Ae(!1), $ && $(I.message));
3129
+ !pt && (Qe || R.isReadyForCheckout) ? (_t(ie, ae, De, Ye, B), mt(!0), ut(void 0)) : ht(oe);
3130
+ } else A === k.enum.CHECKOUT_SUCCESS ? (Ae(!1), ht(0), mt(!1), w && w(R.invoiceUrls, R.subscriptionIds, R.customerId)) : A === k.enum.LOAD_ERROR ? u && u(R.message) : A === k.enum.VALIDATION_ERROR ? d && d(R.elementType, R.errors, De) : (A === k.enum.TOKENIZE_ERROR || A === k.enum.CHECKOUT_ERROR) && (Ae(!1), $ && $(R.message));
3129
3131
  },
3130
3132
  [
3131
3133
  ae,
@@ -3148,15 +3150,15 @@ const Sn = (r) => {
3148
3150
  ]
3149
3151
  ), Xt = Ue(() => {
3150
3152
  if (!pe.current || !d || !se) return;
3151
- const O = Cn(se, pe.current, d);
3152
- if (O) {
3153
+ const I = Cn(se, pe.current, d);
3154
+ if (I) {
3153
3155
  for (const [ie, C] of Object.entries(ne))
3154
- C && _t(C, ae, ie, O, B);
3155
- O.type = k.enum.CHECKOUT, ut(O);
3156
+ C && _t(C, ae, ie, I, B);
3157
+ I.type = k.enum.CHECKOUT, ut(I);
3156
3158
  }
3157
3159
  }, [pe, ne, ae, d, se, B]), Xe = Ue(
3158
- (O) => {
3159
- lt && O.preventDefault();
3160
+ (I) => {
3161
+ lt && I.preventDefault();
3160
3162
  },
3161
3163
  [lt]
3162
3164
  );
@@ -3166,8 +3168,8 @@ const Sn = (r) => {
3166
3168
  window.removeEventListener("beforeunload", Xe), window.removeEventListener("message", Fe);
3167
3169
  }), [se, Fe, Xe]);
3168
3170
  const Qt = Ue(
3169
- (O) => {
3170
- re.find((C) => C.contentWindow === O.contentWindow) || Ht((C) => [...C, O]);
3171
+ (I) => {
3172
+ re.find((C) => C.contentWindow === I.contentWindow) || Ht((C) => [...C, I]);
3171
3173
  },
3172
3174
  [re]
3173
3175
  ), er = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getopenpay/openpay-js-react",
3
- "version": "0.0.5-alpha.c8e4dd5",
3
+ "version": "0.0.6-alpha.2dd4240",
4
4
  "description": "Accept payments through OpenPay, right on your site",
5
5
  "author": "OpenPay <info@getopenpay.com> (https://getopenpay.com)",
6
6
  "type": "module",