@getopenpay/openpay-js-react 0.0.11 → 0.0.12

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.
Files changed (3) hide show
  1. package/README.md +91 -4
  2. package/dist/index.js +152 -150
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -33,12 +33,68 @@ The library provides separate card elements (Card number, expiry, CVV) and a com
33
33
  - `<CardCvcElement />`
34
34
  - `<CardElement />` (Combined)
35
35
 
36
+ <br />
37
+
38
+ ### Callbacks
39
+
40
+ `ElementsForm` component, which is responsible for managing the form elements involved in the payment checkout process. This provides optional callback functions and properties that help customize the behavior of the form.
41
+
42
+ `onFocus?: (elementId: string) => void`
43
+ Triggered when a form element gains focus.
44
+ Parameters:
45
+ `elementId`: The ID of the element that gained focus.
46
+
47
+ `onBlur?: (elementId: string) => void`
48
+ Triggered when a form element loses focus.
49
+ Parameters:
50
+ `elementId`: The ID of the element that lost focus.
51
+
52
+ `onChange?: (elementId: string) => void`
53
+ Triggered when a form element's value changes.
54
+ Parameters:
55
+ `elementId`: The ID of the element whose value changed.
56
+
57
+ `onLoad?: (totalAmountAtoms: number, currency?: string) => void`
58
+ Triggered when the form is successfully loaded.
59
+ Parameters:
60
+ `totalAmountAtoms`: The total amount to be processed in atomic units (usually the smallest denomination of the currency).
61
+ `currency`: (Optional) The currency code in which the transaction is being processed.
62
+
63
+ `onLoadError?: (message: string) => void`
64
+ Triggered if there is an error loading the form.
65
+ Parameters:
66
+ `message`: A string describing the error that occurred during form loading.
67
+
68
+ `onValidationError?: (field: FieldNames, errors: string[], elementId?: string) => void`
69
+ Triggered when there is a validation error in any of the form fields.
70
+ Parameters:
71
+ `field`: The name of the field that failed validation.
72
+ `errors:` An array of error messages describing the validation issues.
73
+ `elementId:` (Optional) The ID of the element where the validation error occurred.
74
+
75
+ `onCheckoutStarted?: () => void`
76
+ Triggered when the checkout process begins.
77
+
78
+ `onCheckoutSuccess?: (invoiceUrls: string[], subscriptionIds: string[], customerId: string) => void`
79
+ Triggered when the checkout process is successfully completed.
80
+ Parameters:
81
+ `invoiceUrls`: An array of URLs to the generated invoices.
82
+
83
+ `onCheckoutError?: (message: string) => void`
84
+ Triggered when an error occurs during the checkout process.
85
+ Parameters:
86
+ `message`: A string describing the error that occurred during checkout.
87
+
88
+ <br />
89
+
36
90
  ### Billing information
37
91
 
38
92
  Customer billing information is required to proceed checkout. You can implement the input fields for billing information in your own way. Since you're in control of these fields, you can perform custom validations, custom styling and auto-fill with user account information.
39
- For OpenPay to access the input fields, please include `data-opid` attribute with predefined field names which can be accessed via `FieldName`.
93
+ For OpenPay to access the input fields, please include `data-opid` attribute with predefined field names which can be accessed via `FieldName`.
40
94
 
41
- Available field names:
95
+ Fields must be rendered inside `<ElementsForm>`
96
+
97
+ Available field names:
42
98
 
43
99
  - `FieldName.FIRST_NAME`
44
100
  - `FieldName.LAST_NAME`
@@ -49,17 +105,48 @@ Available field names:
49
105
  - `FieldName.COUNTRY`
50
106
  - `FieldName.ADDRESS`
51
107
  - `FieldName.PHONE`
108
+ - `FieldName.PROMOTION_CODE`
109
+
110
+ <br />
52
111
 
53
112
  ### Styling
54
113
 
55
114
  By default, the elements provided are "Unstyled". They will have transparent background and text color adaptive to system's color scheme. You can wrap an element inside a container to which you can apply customized styling ([Examples](doc:examples)).
56
115
 
57
- If you want to customize the styling of the element itself you can apply via the optional `styles` prop. The following are supported properties. These support any valid CSS values.
116
+ If you want to customize the styling of the element itself you can apply via the optional `styles` prop. The following are supported properties. These support any valid CSS values.
58
117
 
59
- - `backgroundColor`
118
+ - `backgroundColor`
60
119
  - `color`
61
120
  - `fontFamily`
62
121
  - `fontSize`
63
122
  - `fontWeight`
64
123
  - `margin`
65
124
  - `padding`
125
+
126
+ Optionally, placeholder can be configured via a property of `styles`.
127
+
128
+ - `placeholder` : `string | { cardNumber: string, expiry: string, cvc: string }`
129
+
130
+ For individual card elements: placeholder accepts a `string`
131
+ For the combined`<CardElement>`: placeholder accepts an object `{ cardNumber: string, expiry: string, cvc: string }`
132
+
133
+
134
+ ## Release | Publish
135
+
136
+ ### Alpha version
137
+
138
+ Default CDE environment for alpha version is `staging`
139
+
140
+ A new alpha version is automatically released when a commit is pushed to main.
141
+
142
+ ### Stable version
143
+
144
+ Default CDE environment for stable version is `production`
145
+
146
+ To release a new version:
147
+ - the version in `package.json` need to be upgraded
148
+ - merge the commit containing the version update to main
149
+ - create a new release in github
150
+ - create new tag with updated version (e.g. if version in package.json is `0.0.10`, create a tag named `v0.0.10`)
151
+ - publish the release
152
+ It will publish a new stable version to npm
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import vr, { createContext as gr, useContext as _r, useState as I, useMemo as Oe, useCallback as Te, useRef as Pt, useEffect as He } from "react";
1
+ import vr, { createContext as gr, useContext as _r, useState as I, useMemo as Oe, useCallback as Te, useRef as Zt, useEffect as He } from "react";
2
2
  import { jsx as oe } from "react/jsx-runtime";
3
- const Zt = gr({
3
+ const jt = gr({
4
4
  formId: "",
5
5
  formHeight: "",
6
6
  referer: void 0,
@@ -9,14 +9,14 @@ const Zt = gr({
9
9
  },
10
10
  baseUrl: ""
11
11
  }), xr = () => {
12
- const r = _r(Zt);
12
+ const r = _r(jt);
13
13
  if (!r)
14
14
  throw new Error("useOpenPayElements must be used within an OpenPayElementsProvider");
15
15
  return r;
16
16
  };
17
17
  var R = [];
18
- for (var dt = 0; dt < 256; ++dt)
19
- R.push((dt + 256).toString(16).slice(1));
18
+ for (var ut = 0; ut < 256; ++ut)
19
+ R.push((ut + 256).toString(16).slice(1));
20
20
  function br(r, e = 0) {
21
21
  return (R[r[e + 0]] + R[r[e + 1]] + R[r[e + 2]] + R[r[e + 3]] + "-" + R[r[e + 4]] + R[r[e + 5]] + "-" + R[r[e + 6]] + R[r[e + 7]] + "-" + R[r[e + 8]] + R[r[e + 9]] + "-" + R[r[e + 10]] + R[r[e + 11]] + R[r[e + 12]] + R[r[e + 13]] + R[r[e + 14]] + R[r[e + 15]]).toLowerCase();
22
22
  }
@@ -27,12 +27,12 @@ function wr() {
27
27
  return We(kr);
28
28
  }
29
29
  var Er = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
30
- const Ct = {
30
+ const Ot = {
31
31
  randomUUID: Er
32
32
  };
33
- function jt(r, e, t) {
34
- if (Ct.randomUUID && !e && !r)
35
- return Ct.randomUUID();
33
+ function Mt(r, e, t) {
34
+ if (Ot.randomUUID && !e && !r)
35
+ return Ot.randomUUID();
36
36
  r = r || {};
37
37
  var n = r.random || (r.rng || wr)();
38
38
  return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, br(n);
@@ -73,14 +73,14 @@ var x;
73
73
  }
74
74
  r.joinValues = n, r.jsonStringifyReplacer = (s, a) => typeof a == "bigint" ? a.toString() : a;
75
75
  })(x || (x = {}));
76
- var lt;
76
+ var ft;
77
77
  (function(r) {
78
78
  r.mergeShapes = (e, t) => ({
79
79
  ...e,
80
80
  ...t
81
81
  // second overwrites first
82
82
  });
83
- })(lt || (lt = {}));
83
+ })(ft || (ft = {}));
84
84
  const h = x.arrayToEnum([
85
85
  "string",
86
86
  "nan",
@@ -257,12 +257,12 @@ const _e = (r, e) => {
257
257
  }
258
258
  return { message: t };
259
259
  };
260
- let Mt = _e;
261
- function Sr(r) {
262
- Mt = r;
260
+ let Dt = _e;
261
+ function Cr(r) {
262
+ Dt = r;
263
263
  }
264
264
  function Ke() {
265
- return Mt;
265
+ return Dt;
266
266
  }
267
267
  const Ye = (r) => {
268
268
  const { data: e, path: t, errorMaps: n, issueData: s } = r, a = [...t, ...s.path || []], i = {
@@ -284,7 +284,7 @@ const Ye = (r) => {
284
284
  path: a,
285
285
  message: o
286
286
  };
287
- }, Cr = [];
287
+ }, Sr = [];
288
288
  function l(r, e) {
289
289
  const t = Ke(), n = Ye({
290
290
  issueData: e,
@@ -343,12 +343,12 @@ class N {
343
343
  }
344
344
  const v = Object.freeze({
345
345
  status: "aborted"
346
- }), ve = (r) => ({ status: "dirty", value: r }), P = (r) => ({ status: "valid", value: r }), ft = (r) => r.status === "aborted", ht = (r) => r.status === "dirty", Re = (r) => r.status === "valid", Ie = (r) => typeof Promise < "u" && r instanceof Promise;
346
+ }), ve = (r) => ({ status: "dirty", value: r }), P = (r) => ({ status: "valid", value: r }), ht = (r) => r.status === "aborted", pt = (r) => r.status === "dirty", Re = (r) => r.status === "valid", Ie = (r) => typeof Promise < "u" && r instanceof Promise;
347
347
  function Je(r, e, t, n) {
348
348
  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");
349
349
  return e.get(r);
350
350
  }
351
- function Dt(r, e, t, n, s) {
351
+ function Lt(r, e, t, n, s) {
352
352
  if (typeof e == "function" ? r !== e || !s : !e.has(r)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
353
353
  return e.set(r, t), t;
354
354
  }
@@ -356,7 +356,7 @@ var m;
356
356
  (function(r) {
357
357
  r.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, r.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
358
358
  })(m || (m = {}));
359
- var Se, Ce;
359
+ var Ce, Se;
360
360
  class Y {
361
361
  constructor(e, t, n, s) {
362
362
  this._cachedPath = [], this.parent = e, this.data = t, this._path = n, this._key = s;
@@ -365,7 +365,7 @@ class Y {
365
365
  return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
366
366
  }
367
367
  }
368
- const Ot = (r, e) => {
368
+ const Rt = (r, e) => {
369
369
  if (Re(e))
370
370
  return { success: !0, data: e.value };
371
371
  if (!r.common.issues.length)
@@ -455,7 +455,7 @@ class _ {
455
455
  data: e,
456
456
  parsedType: ie(e)
457
457
  }, a = this._parseSync({ data: e, path: s.path, parent: s });
458
- return Ot(s, a);
458
+ return Rt(s, a);
459
459
  }
460
460
  async parseAsync(e, t) {
461
461
  const n = await this.safeParseAsync(e, t);
@@ -476,7 +476,7 @@ class _ {
476
476
  data: e,
477
477
  parsedType: ie(e)
478
478
  }, s = this._parse({ data: e, path: n.path, parent: n }), a = await (Ie(s) ? s : Promise.resolve(s));
479
- return Ot(n, a);
479
+ return Rt(n, a);
480
480
  }
481
481
  refine(e, t) {
482
482
  const n = (s) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(s) : t;
@@ -540,7 +540,7 @@ class _ {
540
540
  });
541
541
  }
542
542
  brand() {
543
- return new yt({
543
+ return new vt({
544
544
  typeName: y.ZodBranded,
545
545
  type: this,
546
546
  ...g(this._def)
@@ -576,17 +576,17 @@ class _ {
576
576
  }
577
577
  }
578
578
  const Or = /^c[^\s-]{8,}$/i, Rr = /^[0-9a-z]+$/, Ir = /^[0-9A-HJKMNP-TV-Z]{26}$/, Nr = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, Ar = /^[a-z0-9_-]{21}$/i, Pr = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, Zr = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, jr = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
579
- let ut;
580
- const Mr = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, Dr = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/, Lr = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Lt = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", Ur = new RegExp(`^${Lt}$`);
581
- function Ut(r) {
579
+ let lt;
580
+ const Mr = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, Dr = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/, Lr = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Ut = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", Ur = new RegExp(`^${Ut}$`);
581
+ function $t(r) {
582
582
  let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
583
583
  return r.precision ? e = `${e}\\.\\d{${r.precision}}` : r.precision == null && (e = `${e}(\\.\\d+)?`), e;
584
584
  }
585
585
  function $r(r) {
586
- return new RegExp(`^${Ut(r)}$`);
586
+ return new RegExp(`^${$t(r)}$`);
587
587
  }
588
- function $t(r) {
589
- let e = `${Lt}T${Ut(r)}`;
588
+ function Vt(r) {
589
+ let e = `${Ut}T${$t(r)}`;
590
590
  const t = [];
591
591
  return t.push(r.local ? "Z?" : "Z"), r.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
592
592
  }
@@ -648,7 +648,7 @@ class z extends _ {
648
648
  message: a.message
649
649
  }), n.dirty());
650
650
  else if (a.kind === "emoji")
651
- ut || (ut = new RegExp(jr, "u")), ut.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
651
+ lt || (lt = new RegExp(jr, "u")), lt.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
652
652
  validation: "emoji",
653
653
  code: d.invalid_string,
654
654
  message: a.message
@@ -709,7 +709,7 @@ class z extends _ {
709
709
  code: d.invalid_string,
710
710
  validation: { endsWith: a.value },
711
711
  message: a.message
712
- }), n.dirty()) : a.kind === "datetime" ? $t(a).test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
712
+ }), n.dirty()) : a.kind === "datetime" ? Vt(a).test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
713
713
  code: d.invalid_string,
714
714
  validation: "datetime",
715
715
  message: a.message
@@ -1809,7 +1809,7 @@ class E extends _ {
1809
1809
  });
1810
1810
  }
1811
1811
  keyof() {
1812
- return Vt(x.objectKeys(this.shape));
1812
+ return zt(x.objectKeys(this.shape));
1813
1813
  }
1814
1814
  }
1815
1815
  E.create = (r, e) => new E({
@@ -1906,8 +1906,8 @@ Ze.create = (r, e) => new Ze({
1906
1906
  typeName: y.ZodUnion,
1907
1907
  ...g(e)
1908
1908
  });
1909
- const re = (r) => r instanceof De ? re(r.schema) : r instanceof B ? re(r.innerType()) : r instanceof Le ? [r.value] : r instanceof ue ? r.options : r instanceof Ue ? x.objectValues(r.enum) : r instanceof $e ? re(r._def.innerType) : r instanceof Ae ? [void 0] : r instanceof Pe ? [null] : r instanceof K ? [void 0, ...re(r.unwrap())] : r instanceof le ? [null, ...re(r.unwrap())] : r instanceof yt || r instanceof ze ? re(r.unwrap()) : r instanceof Ve ? re(r._def.innerType) : [];
1910
- class tt extends _ {
1909
+ const re = (r) => r instanceof De ? re(r.schema) : r instanceof B ? re(r.innerType()) : r instanceof Le ? [r.value] : r instanceof ue ? r.options : r instanceof Ue ? x.objectValues(r.enum) : r instanceof $e ? re(r._def.innerType) : r instanceof Ae ? [void 0] : r instanceof Pe ? [null] : r instanceof K ? [void 0, ...re(r.unwrap())] : r instanceof le ? [null, ...re(r.unwrap())] : r instanceof vt || r instanceof ze ? re(r.unwrap()) : r instanceof Ve ? re(r._def.innerType) : [];
1910
+ class rt extends _ {
1911
1911
  _parse(e) {
1912
1912
  const { ctx: t } = this._processInputParams(e);
1913
1913
  if (t.parsedType !== h.object)
@@ -1960,7 +1960,7 @@ class tt extends _ {
1960
1960
  s.set(o, a);
1961
1961
  }
1962
1962
  }
1963
- return new tt({
1963
+ return new rt({
1964
1964
  typeName: y.ZodDiscriminatedUnion,
1965
1965
  discriminator: e,
1966
1966
  options: t,
@@ -1969,14 +1969,14 @@ class tt extends _ {
1969
1969
  });
1970
1970
  }
1971
1971
  }
1972
- function pt(r, e) {
1972
+ function mt(r, e) {
1973
1973
  const t = ie(r), n = ie(e);
1974
1974
  if (r === e)
1975
1975
  return { valid: !0, data: r };
1976
1976
  if (t === h.object && n === h.object) {
1977
1977
  const s = x.objectKeys(e), a = x.objectKeys(r).filter((o) => s.indexOf(o) !== -1), i = { ...r, ...e };
1978
1978
  for (const o of a) {
1979
- const u = pt(r[o], e[o]);
1979
+ const u = mt(r[o], e[o]);
1980
1980
  if (!u.valid)
1981
1981
  return { valid: !1 };
1982
1982
  i[o] = u.data;
@@ -1987,7 +1987,7 @@ function pt(r, e) {
1987
1987
  return { valid: !1 };
1988
1988
  const s = [];
1989
1989
  for (let a = 0; a < r.length; a++) {
1990
- const i = r[a], o = e[a], u = pt(i, o);
1990
+ const i = r[a], o = e[a], u = mt(i, o);
1991
1991
  if (!u.valid)
1992
1992
  return { valid: !1 };
1993
1993
  s.push(u.data);
@@ -1998,10 +1998,10 @@ function pt(r, e) {
1998
1998
  class je extends _ {
1999
1999
  _parse(e) {
2000
2000
  const { status: t, ctx: n } = this._processInputParams(e), s = (a, i) => {
2001
- if (ft(a) || ft(i))
2001
+ if (ht(a) || ht(i))
2002
2002
  return v;
2003
- const o = pt(a.value, i.value);
2004
- return o.valid ? ((ht(a) || ht(i)) && t.dirty(), { status: t.value, value: o.data }) : (l(n, {
2003
+ const o = mt(a.value, i.value);
2004
+ return o.valid ? ((pt(a) || pt(i)) && t.dirty(), { status: t.value, value: o.data }) : (l(n, {
2005
2005
  code: d.invalid_intersection_types
2006
2006
  }), v);
2007
2007
  };
@@ -2372,7 +2372,7 @@ Le.create = (r, e) => new Le({
2372
2372
  typeName: y.ZodLiteral,
2373
2373
  ...g(e)
2374
2374
  });
2375
- function Vt(r, e) {
2375
+ function zt(r, e) {
2376
2376
  return new ue({
2377
2377
  values: r,
2378
2378
  typeName: y.ZodEnum,
@@ -2381,7 +2381,7 @@ function Vt(r, e) {
2381
2381
  }
2382
2382
  class ue extends _ {
2383
2383
  constructor() {
2384
- super(...arguments), Se.set(this, void 0);
2384
+ super(...arguments), Ce.set(this, void 0);
2385
2385
  }
2386
2386
  _parse(e) {
2387
2387
  if (typeof e.data != "string") {
@@ -2392,7 +2392,7 @@ class ue extends _ {
2392
2392
  code: d.invalid_type
2393
2393
  }), v;
2394
2394
  }
2395
- if (Je(this, Se) || Dt(this, Se, new Set(this._def.values)), !Je(this, Se).has(e.data)) {
2395
+ if (Je(this, Ce) || Lt(this, Ce, new Set(this._def.values)), !Je(this, Ce).has(e.data)) {
2396
2396
  const t = this._getOrReturnCtx(e), n = this._def.values;
2397
2397
  return l(t, {
2398
2398
  received: t.data,
@@ -2436,11 +2436,11 @@ class ue extends _ {
2436
2436
  });
2437
2437
  }
2438
2438
  }
2439
- Se = /* @__PURE__ */ new WeakMap();
2440
- ue.create = Vt;
2439
+ Ce = /* @__PURE__ */ new WeakMap();
2440
+ ue.create = zt;
2441
2441
  class Ue extends _ {
2442
2442
  constructor() {
2443
- super(...arguments), Ce.set(this, void 0);
2443
+ super(...arguments), Se.set(this, void 0);
2444
2444
  }
2445
2445
  _parse(e) {
2446
2446
  const t = x.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
@@ -2452,7 +2452,7 @@ class Ue extends _ {
2452
2452
  code: d.invalid_type
2453
2453
  }), v;
2454
2454
  }
2455
- if (Je(this, Ce) || Dt(this, Ce, new Set(x.getValidEnumValues(this._def.values))), !Je(this, Ce).has(e.data)) {
2455
+ if (Je(this, Se) || Lt(this, Se, new Set(x.getValidEnumValues(this._def.values))), !Je(this, Se).has(e.data)) {
2456
2456
  const s = x.objectValues(t);
2457
2457
  return l(n, {
2458
2458
  received: n.data,
@@ -2466,7 +2466,7 @@ class Ue extends _ {
2466
2466
  return this._def.values;
2467
2467
  }
2468
2468
  }
2469
- Ce = /* @__PURE__ */ new WeakMap();
2469
+ Se = /* @__PURE__ */ new WeakMap();
2470
2470
  Ue.create = (r, e) => new Ue({
2471
2471
  values: r,
2472
2472
  typeName: y.ZodNativeEnum,
@@ -2692,7 +2692,7 @@ et.create = (r) => new et({
2692
2692
  ...g(r)
2693
2693
  });
2694
2694
  const Fr = Symbol("zod_brand");
2695
- class yt extends _ {
2695
+ class vt extends _ {
2696
2696
  _parse(e) {
2697
2697
  const { ctx: t } = this._processInputParams(e), n = t.data;
2698
2698
  return this._def.type._parse({
@@ -2759,7 +2759,7 @@ ze.create = (r, e) => new ze({
2759
2759
  typeName: y.ZodReadonly,
2760
2760
  ...g(e)
2761
2761
  });
2762
- function zt(r, e = {}, t) {
2762
+ function Ft(r, e = {}, t) {
2763
2763
  return r ? xe.create().superRefine((n, s) => {
2764
2764
  var a, i;
2765
2765
  if (!r(n)) {
@@ -2777,7 +2777,7 @@ var y;
2777
2777
  })(y || (y = {}));
2778
2778
  const Wr = (r, e = {
2779
2779
  message: `Input not instance of ${r.name}`
2780
- }) => zt((t) => t instanceof r, e), Ft = z.create, Bt = ce.create, qr = et.create, Hr = de.create, Wt = Ne.create, Kr = he.create, Yr = Ge.create, Jr = Ae.create, Gr = Pe.create, Xr = xe.create, Qr = fe.create, en = ne.create, tn = Xe.create, rn = F.create, nn = E.create, sn = E.strictCreate, an = Ze.create, on = tt.create, cn = je.create, dn = J.create, un = Me.create, ln = Qe.create, fn = pe.create, hn = ge.create, pn = De.create, mn = Le.create, yn = ue.create, vn = Ue.create, gn = be.create, Rt = B.create, _n = K.create, xn = le.create, bn = B.createWithPreprocess, kn = Fe.create, wn = () => Ft().optional(), En = () => Bt().optional(), Tn = () => Wt().optional(), Sn = {
2780
+ }) => Ft((t) => t instanceof r, e), Bt = z.create, Wt = ce.create, qr = et.create, Hr = de.create, qt = Ne.create, Kr = he.create, Yr = Ge.create, Jr = Ae.create, Gr = Pe.create, Xr = xe.create, Qr = fe.create, en = ne.create, tn = Xe.create, rn = F.create, nn = E.create, sn = E.strictCreate, an = Ze.create, on = rt.create, cn = je.create, dn = J.create, un = Me.create, ln = Qe.create, fn = pe.create, hn = ge.create, pn = De.create, mn = Le.create, yn = ue.create, vn = Ue.create, gn = be.create, It = B.create, _n = K.create, xn = le.create, bn = B.createWithPreprocess, kn = Fe.create, wn = () => Bt().optional(), En = () => Wt().optional(), Tn = () => qt().optional(), Cn = {
2781
2781
  string: (r) => z.create({ ...r, coerce: !0 }),
2782
2782
  number: (r) => ce.create({ ...r, coerce: !0 }),
2783
2783
  boolean: (r) => Ne.create({
@@ -2786,33 +2786,33 @@ const Wr = (r, e = {
2786
2786
  }),
2787
2787
  bigint: (r) => de.create({ ...r, coerce: !0 }),
2788
2788
  date: (r) => he.create({ ...r, coerce: !0 })
2789
- }, Cn = v;
2789
+ }, Sn = v;
2790
2790
  var f = /* @__PURE__ */ Object.freeze({
2791
2791
  __proto__: null,
2792
2792
  defaultErrorMap: _e,
2793
- setErrorMap: Sr,
2793
+ setErrorMap: Cr,
2794
2794
  getErrorMap: Ke,
2795
2795
  makeIssue: Ye,
2796
- EMPTY_PATH: Cr,
2796
+ EMPTY_PATH: Sr,
2797
2797
  addIssueToContext: l,
2798
2798
  ParseStatus: N,
2799
2799
  INVALID: v,
2800
2800
  DIRTY: ve,
2801
2801
  OK: P,
2802
- isAborted: ft,
2803
- isDirty: ht,
2802
+ isAborted: ht,
2803
+ isDirty: pt,
2804
2804
  isValid: Re,
2805
2805
  isAsync: Ie,
2806
2806
  get util() {
2807
2807
  return x;
2808
2808
  },
2809
2809
  get objectUtil() {
2810
- return lt;
2810
+ return ft;
2811
2811
  },
2812
2812
  ZodParsedType: h,
2813
2813
  getParsedType: ie,
2814
2814
  ZodType: _,
2815
- datetimeRegex: $t,
2815
+ datetimeRegex: Vt,
2816
2816
  ZodString: z,
2817
2817
  ZodNumber: ce,
2818
2818
  ZodBigInt: de,
@@ -2828,7 +2828,7 @@ var f = /* @__PURE__ */ Object.freeze({
2828
2828
  ZodArray: F,
2829
2829
  ZodObject: E,
2830
2830
  ZodUnion: Ze,
2831
- ZodDiscriminatedUnion: tt,
2831
+ ZodDiscriminatedUnion: rt,
2832
2832
  ZodIntersection: je,
2833
2833
  ZodTuple: J,
2834
2834
  ZodRecord: Me,
@@ -2848,24 +2848,24 @@ var f = /* @__PURE__ */ Object.freeze({
2848
2848
  ZodCatch: Ve,
2849
2849
  ZodNaN: et,
2850
2850
  BRAND: Fr,
2851
- ZodBranded: yt,
2851
+ ZodBranded: vt,
2852
2852
  ZodPipeline: Fe,
2853
2853
  ZodReadonly: ze,
2854
- custom: zt,
2854
+ custom: Ft,
2855
2855
  Schema: _,
2856
2856
  ZodSchema: _,
2857
2857
  late: Br,
2858
2858
  get ZodFirstPartyTypeKind() {
2859
2859
  return y;
2860
2860
  },
2861
- coerce: Sn,
2861
+ coerce: Cn,
2862
2862
  any: Xr,
2863
2863
  array: rn,
2864
2864
  bigint: Hr,
2865
- boolean: Wt,
2865
+ boolean: qt,
2866
2866
  date: Kr,
2867
2867
  discriminatedUnion: on,
2868
- effect: Rt,
2868
+ effect: It,
2869
2869
  enum: yn,
2870
2870
  function: hn,
2871
2871
  instanceof: Wr,
@@ -2878,7 +2878,7 @@ var f = /* @__PURE__ */ Object.freeze({
2878
2878
  never: en,
2879
2879
  null: Gr,
2880
2880
  nullable: xn,
2881
- number: Bt,
2881
+ number: Wt,
2882
2882
  object: nn,
2883
2883
  oboolean: Tn,
2884
2884
  onumber: En,
@@ -2890,27 +2890,27 @@ var f = /* @__PURE__ */ Object.freeze({
2890
2890
  record: un,
2891
2891
  set: fn,
2892
2892
  strictObject: sn,
2893
- string: Ft,
2893
+ string: Bt,
2894
2894
  symbol: Yr,
2895
- transformer: Rt,
2895
+ transformer: It,
2896
2896
  tuple: dn,
2897
2897
  undefined: Jr,
2898
2898
  union: an,
2899
2899
  unknown: Qr,
2900
2900
  void: tn,
2901
- NEVER: Cn,
2901
+ NEVER: Sn,
2902
2902
  ZodIssueCode: d,
2903
2903
  quotelessJson: Tr,
2904
2904
  ZodError: M
2905
2905
  });
2906
- const U = f.string().trim().min(1, { message: "Cannot be blank" }), j = f.string().trim().optional(), It = (r) => f.nullable(r.optional());
2907
- var qt = /* @__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.PROMOTION_CODE = "promotionCode", r))(qt || {});
2908
- const Ht = f.nativeEnum(qt);
2906
+ const U = f.string().trim().min(1, { message: "Cannot be blank" }), j = f.string().trim().optional(), Nt = (r) => f.nullable(r.optional());
2907
+ var tt = /* @__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.PROMOTION_CODE = "promotionCode", r))(tt || {});
2908
+ const Ht = f.nativeEnum(tt);
2909
2909
  var Kt = /* @__PURE__ */ ((r) => (r.CARD_NUMBER = "cardNumber", r.CARD_EXPIRY = "cardExpiry", r.CARD_CVC = "cardCvc", r))(Kt || {});
2910
2910
  const Yt = f.nativeEnum(Kt), On = f.union([Ht, Yt]), Jt = f.object({
2911
2911
  provider: f.string(),
2912
- processor_name: It(f.string()),
2913
- metadata: It(f.record(f.string(), f.any()))
2912
+ processor_name: Nt(f.string()),
2913
+ metadata: Nt(f.record(f.string(), f.any()))
2914
2914
  });
2915
2915
  f.object({
2916
2916
  cardNumber: j,
@@ -3030,7 +3030,9 @@ const Wn = (r) => {
3030
3030
  checkoutPaymentMethod: s,
3031
3031
  paymentFlowMetadata: i,
3032
3032
  doNotUseLegacyCCFlow: a
3033
- }), u = Gt.safeParse(o);
3033
+ });
3034
+ (s.provider === "apple_pay" || s.provider === "google_pay") && (o[tt.ZIP_CODE] || (o[tt.ZIP_CODE] = "00000"));
3035
+ const u = Gt.safeParse(o);
3034
3036
  if (u.success)
3035
3037
  return u.data;
3036
3038
  {
@@ -3048,7 +3050,7 @@ const Wn = (r) => {
3048
3050
  }, Ee = (r, e, t, n, s) => {
3049
3051
  const a = {
3050
3052
  payload: n,
3051
- nonce: jt(),
3053
+ nonce: Mt(),
3052
3054
  formId: e,
3053
3055
  elementId: t
3054
3056
  };
@@ -3056,14 +3058,14 @@ const Wn = (r) => {
3056
3058
  }, Hn = "https://cde.getopenpay.com", Kn = {
3057
3059
  usd: "usd",
3058
3060
  brl: "brl"
3059
- }, vt = (r) => {
3061
+ }, gt = async (r) => {
3060
3062
  for (let t = 0; t < 10; t++)
3061
- Nt() || Jn(200);
3062
- if (!Nt())
3063
+ At() || await Jn(500);
3064
+ if (!At())
3063
3065
  throw new Error("Stripe JS not found.");
3064
3066
  return new Stripe(r);
3065
3067
  }, Yn = async (r, e, t) => {
3066
- const n = vt(r), s = Kn[t];
3068
+ const n = await gt(r), s = Kn[t];
3067
3069
  return n.paymentRequest({
3068
3070
  // TODO: replace this with stripe account country as soon as we support it
3069
3071
  country: "US",
@@ -3077,7 +3079,7 @@ const Wn = (r) => {
3077
3079
  });
3078
3080
  }, Jn = (r) => new Promise((e) => {
3079
3081
  setTimeout(e, r);
3080
- }), Nt = () => "Stripe" in window, Gn = async (r) => new Promise((e, t) => {
3082
+ }), At = () => "Stripe" in window, Gn = async (r) => new Promise((e, t) => {
3081
3083
  try {
3082
3084
  r.on("paymentmethod", async (n) => {
3083
3085
  e(n);
@@ -3100,7 +3102,7 @@ const Wn = (r) => {
3100
3102
  throw new Error(`Invalid next action metadata format: ${JSON.stringify(t)}`);
3101
3103
  if (e.paymentMethod.id !== r.paymentFlowMetadata.stripePmId)
3102
3104
  throw new Error(`PM ID mismatch: ${e.paymentMethod.id} != ${r.paymentFlowMetadata.stripePmId}`);
3103
- const s = await vt(t.stripe_pk).confirmCardSetup(t.client_secret, {
3105
+ const s = await (await gt(t.stripe_pk)).confirmCardSetup(t.client_secret, {
3104
3106
  payment_method: r.paymentFlowMetadata.stripePmId
3105
3107
  });
3106
3108
  if (s.error)
@@ -3108,7 +3110,7 @@ const Wn = (r) => {
3108
3110
  e.complete("success");
3109
3111
  }, es = async (r) => {
3110
3112
  var a, i, o, u;
3111
- const e = r.nextActionMetadata, n = await vt(e.stripe_pk).confirmCardSetup(e.client_secret, {
3113
+ const e = r.nextActionMetadata, n = await (await gt(e.stripe_pk)).confirmCardSetup(e.client_secret, {
3112
3114
  payment_method: e.stripe_pm_id
3113
3115
  }), s = (a = n.setupIntent) == null ? void 0 : a.status;
3114
3116
  if (s !== "succeeded") throw s === "canceled" ? new Error("Payment cancelled, please click Submit again to pay") : new Error(
@@ -3145,7 +3147,7 @@ const Wn = (r) => {
3145
3147
  function rs(r) {
3146
3148
  return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
3147
3149
  }
3148
- var gt = { exports: {} }, ns = vr;
3150
+ var _t = { exports: {} }, ns = vr;
3149
3151
  function Qt(r, e, t) {
3150
3152
  var n = typeof e == "function";
3151
3153
  ns.useEffect(function() {
@@ -3159,9 +3161,9 @@ function Qt(r, e, t) {
3159
3161
  };
3160
3162
  }, n ? t : e);
3161
3163
  }
3162
- gt.exports = Qt;
3163
- gt.exports.useAsyncEffect = Qt;
3164
- var ss = gt.exports;
3164
+ _t.exports = Qt;
3165
+ _t.exports.useAsyncEffect = Qt;
3166
+ var ss = _t.exports;
3165
3167
  const as = /* @__PURE__ */ rs(ss), is = f.object({
3166
3168
  type: f.string(),
3167
3169
  loc: f.array(f.string()),
@@ -3173,7 +3175,7 @@ const as = /* @__PURE__ */ rs(ss), is = f.object({
3173
3175
  path: f.array(f.string())
3174
3176
  }), ds = f.array(cs), us = {
3175
3177
  "failed to fetch": "Connection error: please double check if you are connected to the internet, then try again"
3176
- }, mt = (r) => {
3178
+ }, yt = (r) => {
3177
3179
  const e = r.toLowerCase().trim();
3178
3180
  return us[e] ?? r;
3179
3181
  }, ls = (r) => {
@@ -3182,8 +3184,8 @@ const as = /* @__PURE__ */ rs(ss), is = f.object({
3182
3184
  } catch {
3183
3185
  return !1;
3184
3186
  }
3185
- }, fs = (r) => r.length === 1 ? mt(r[0].msg) : `Please fix the following errors:
3186
- ${r.map((t) => `• ${mt(t.msg)}`).join(`
3187
+ }, fs = (r) => r.length === 1 ? yt(r[0].msg) : `Please fix the following errors:
3188
+ ${r.map((t) => `• ${yt(t.msg)}`).join(`
3187
3189
  `)}`, hs = (r) => `Encountered the following errors:
3188
3190
  ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3189
3191
  `)}`, er = (r) => {
@@ -3192,7 +3194,7 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3192
3194
  const e = JSON.parse(r.message);
3193
3195
  return os.safeParse(e).success ? fs(e) : ds.safeParse(e).success ? hs(e) : r.message;
3194
3196
  } else
3195
- return mt(r.message);
3197
+ return yt(r.message);
3196
3198
  if (typeof r == "object")
3197
3199
  try {
3198
3200
  return JSON.stringify(r);
@@ -3204,7 +3206,7 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3204
3206
  }, ps = f.enum(["apple_pay", "google_pay"]), ms = {
3205
3207
  apple_pay: "applePay",
3206
3208
  google_pay: "googlePay"
3207
- }, At = {
3209
+ }, Pt = {
3208
3210
  isLoading: !0,
3209
3211
  isAvailable: !1,
3210
3212
  startFlow: () => {
@@ -3216,8 +3218,8 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3216
3218
  }
3217
3219
  }, vs = (r, e, t, n, s, a, i) => {
3218
3220
  const [o, u] = ts({
3219
- apple_pay: At,
3220
- google_pay: At
3221
+ apple_pay: Pt,
3222
+ google_pay: Pt
3221
3223
  }), c = r === void 0 || e === void 0 || t === void 0 || !n;
3222
3224
  return as(async () => {
3223
3225
  if (!c)
@@ -3230,7 +3232,7 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3230
3232
  const G = Xn(T.metadata), A = await Yn(G, r, e), W = await A.canMakePayment();
3231
3233
  if (!W)
3232
3234
  throw new Error(`Cannot make payment with ${b} for this session`);
3233
- const nt = async () => {
3235
+ const st = async () => {
3234
3236
  try {
3235
3237
  if (Xt(n, {}), a && !qe(
3236
3238
  k.enum.START_PAYMENT_FLOW,
@@ -3252,7 +3254,7 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3252
3254
  u.set(p, {
3253
3255
  isLoading: !1,
3254
3256
  isAvailable: W[ms[p]],
3255
- startFlow: nt
3257
+ startFlow: st
3256
3258
  });
3257
3259
  } catch {
3258
3260
  u.set(p, ys);
@@ -3274,63 +3276,63 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3274
3276
  onCheckoutSuccess: b,
3275
3277
  onCheckoutError: T,
3276
3278
  baseUrl: G
3277
- } = r, A = G ?? Hn, [W, nt] = I(void 0), [X, _t] = I([]), [tr, rr] = I("1px"), [xt, nr] = I(!1), [Q, ke] = I(void 0), [bt, we] = I(!1), [me, sr] = I([]), [se, ar] = I({}), [kt, wt] = I(0), [Et, ae] = I(!1), [q, ir] = I(void 0), [st, or] = I(void 0), [Be, cr] = I(void 0), [ee, dr] = I(void 0), [at, ur] = I(void 0), te = Oe(() => `opjs-form-${jt()}`, []), H = Pt(null), it = Te(
3279
+ } = r, A = G ?? Hn, [W, st] = I(void 0), [X, xt] = I([]), [tr, rr] = I("1px"), [bt, nr] = I(!1), [Q, ke] = I(void 0), [kt, we] = I(!1), [me, sr] = I([]), [se, ar] = I({}), [wt, Et] = I(0), [Tt, ae] = I(!1), [q, ir] = I(void 0), [at, or] = I(void 0), [Be, cr] = I(void 0), [ee, dr] = I(void 0), [it, ur] = I(void 0), te = Oe(() => `opjs-form-${Mt()}`, []), H = Zt(null), ot = Te(
3278
3280
  (O) => {
3279
3281
  if (O.origin !== A || !O.source) return;
3280
- const D = O.source, S = qn(JSON.parse(O.data)), $ = S.elementId;
3281
- if (S.formId !== te || !$ || S.nonce in X)
3282
+ const D = O.source, C = qn(JSON.parse(O.data)), $ = C.elementId;
3283
+ if (C.formId !== te || !$ || C.nonce in X)
3282
3284
  return;
3283
- _t((Z) => [...Z, S.nonce]);
3284
- const w = S.payload, L = w.type;
3285
+ xt((Z) => [...Z, C.nonce]);
3286
+ const w = C.payload, L = w.type;
3285
3287
  if (L === k.enum.FOCUS && s)
3286
- s(S.elementId);
3288
+ s(C.elementId);
3287
3289
  else if (L === k.enum.BLUR && a)
3288
- a(S.elementId);
3290
+ a(C.elementId);
3289
3291
  else if (L === k.enum.CHANGE && i)
3290
- i(S.elementId);
3292
+ i(C.elementId);
3291
3293
  else if (L === k.enum.LOADED) {
3292
3294
  const Z = me.find((V) => V.contentWindow === D);
3293
3295
  if (we(!1), !Z)
3294
3296
  return;
3295
3297
  ar((V) => ({ ...V, [$]: D }));
3296
- const C = w.height ? `${w.height}px` : "100%";
3297
- rr(C), cr(w.totalAmountAtoms), or(w.currency), dr(w.checkoutPaymentMethods), q || ir(w.sessionId);
3298
+ const S = w.height ? `${w.height}px` : "100%";
3299
+ rr(S), cr(w.totalAmountAtoms), or(w.currency), dr(w.checkoutPaymentMethods), q || ir(w.sessionId);
3298
3300
  } else if (L === k.enum.TOKENIZE_STARTED)
3299
3301
  we(!0), p && p();
3300
3302
  else if (L === k.enum.PAYMENT_FLOW_STARTED) {
3301
3303
  if (!Q)
3302
3304
  throw new Error("extraData not populated");
3303
3305
  (async () => {
3304
- const C = w.nextActionMetadata.type;
3305
- if (C !== void 0) if (C === "stripe_3ds")
3306
+ const S = w.nextActionMetadata.type;
3307
+ if (S !== void 0) if (S === "stripe_3ds")
3306
3308
  await es(w);
3307
- else if (C === "stripe_payment_request") {
3308
- if (!at)
3309
+ else if (S === "stripe_payment_request") {
3310
+ if (!it)
3309
3311
  throw new Error("Stripe PM not set");
3310
- await Qn(w, at);
3312
+ await Qn(w, it);
3311
3313
  } else
3312
- throw new Error(`Unknown next action type: ${C}`);
3314
+ throw new Error(`Unknown next action type: ${S}`);
3313
3315
  })().then(() => {
3314
3316
  var V;
3315
- let C;
3316
- if (Q.checkoutPaymentMethod.provider === "credit_card" && (C = (V = w.startPFMetadata) == null ? void 0 : V.cc_pm_id, !C))
3317
+ let S;
3318
+ if (Q.checkoutPaymentMethod.provider === "credit_card" && (S = (V = w.startPFMetadata) == null ? void 0 : V.cc_pm_id, !S))
3317
3319
  throw new Error("CC PM ID not found");
3318
3320
  Ee(
3319
3321
  D,
3320
3322
  te,
3321
3323
  $,
3322
- { ...Q, type: "CHECKOUT", doNotUseLegacyCCFlow: !0, existingCCPMId: C },
3324
+ { ...Q, type: "CHECKOUT", doNotUseLegacyCCFlow: !0, existingCCPMId: S },
3323
3325
  A
3324
3326
  ), ae(!0), ke(void 0), p && p();
3325
- }).catch((C) => {
3326
- const V = er(C);
3327
+ }).catch((S) => {
3328
+ const V = er(S);
3327
3329
  we(!1), ae(!1), T && T(V);
3328
3330
  });
3329
3331
  } else if (L === k.enum.TOKENIZE_SUCCESS && Q) {
3330
- const Z = kt + 1, C = Z === Object.keys(se).length;
3331
- !Et && (C || w.isReadyForCheckout) ? (Ee(D, te, $, Q, A), ae(!0), ke(void 0)) : wt(Z);
3332
+ const Z = wt + 1, S = Z === Object.keys(se).length;
3333
+ !Tt && (S || w.isReadyForCheckout) ? (Ee(D, te, $, Q, A), ae(!0), ke(void 0)) : Et(Z);
3332
3334
  } else if (L === k.enum.CHECKOUT_SUCCESS)
3333
- we(!1), wt(0), ae(!1), b && b(w.invoiceUrls, w.subscriptionIds, w.customerId);
3335
+ we(!1), Et(0), ae(!1), b && b(w.invoiceUrls, w.subscriptionIds, w.customerId);
3334
3336
  else if (L === k.enum.LOAD_ERROR)
3335
3337
  u && u(w.message);
3336
3338
  else if (L === k.enum.VALIDATION_ERROR) {
@@ -3338,11 +3340,11 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3338
3340
  (Z === "credit_card" || Z === void 0) && c && c(w.elementType, w.errors, $);
3339
3341
  } else if (L === k.enum.TOKENIZE_ERROR || L === k.enum.CHECKOUT_ERROR)
3340
3342
  if (w.message === "3DS_REQUIRED") {
3341
- const Z = ee == null ? void 0 : ee.find((C) => C.provider === "credit_card");
3343
+ const Z = ee == null ? void 0 : ee.find((S) => S.provider === "credit_card");
3342
3344
  if (!q || !H.current || !c || !Z) return;
3343
- for (const [C, V] of Object.entries(se)) {
3345
+ for (const [S, V] of Object.entries(se)) {
3344
3346
  if (!V) continue;
3345
- const ct = qe(
3347
+ const dt = qe(
3346
3348
  k.enum.START_PAYMENT_FLOW,
3347
3349
  q,
3348
3350
  H.current,
@@ -3352,8 +3354,8 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3352
3354
  { ...Z, processor_name: "stripe" },
3353
3355
  !1
3354
3356
  );
3355
- if (ct) {
3356
- ae(!0), ke(ct), Ee(V, te, C, ct, A);
3357
+ if (dt) {
3358
+ ae(!0), ke(dt), Ee(V, te, S, dt, A);
3357
3359
  break;
3358
3360
  }
3359
3361
  }
@@ -3367,8 +3369,8 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3367
3369
  Q,
3368
3370
  me,
3369
3371
  se,
3370
- kt,
3371
- Et,
3372
+ wt,
3373
+ Tt,
3372
3374
  a,
3373
3375
  i,
3374
3376
  s,
@@ -3378,12 +3380,12 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3378
3380
  T,
3379
3381
  c,
3380
3382
  A,
3381
- at,
3383
+ it,
3382
3384
  ee
3383
3385
  ]
3384
3386
  ), lr = Te(() => {
3385
3387
  if (!H.current || !c || !q || !ee) return;
3386
- const O = ee.find((S) => S.provider === "credit_card");
3388
+ const O = ee.find((C) => C.provider === "credit_card");
3387
3389
  if (!O)
3388
3390
  throw new Error("Card not available as a payment method in checkout");
3389
3391
  const D = qe(
@@ -3395,29 +3397,29 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3395
3397
  !1
3396
3398
  );
3397
3399
  if (D) {
3398
- for (const [S, $] of Object.entries(se))
3399
- $ && Ee($, te, S, D, A);
3400
+ for (const [C, $] of Object.entries(se))
3401
+ $ && Ee($, te, C, D, A);
3400
3402
  D.type = k.enum.CHECKOUT, ke(D);
3401
3403
  }
3402
- }, [H, se, te, c, q, A, ee]), ot = Te(
3404
+ }, [H, se, te, c, q, A, ee]), ct = Te(
3403
3405
  (O) => {
3404
- bt && O.preventDefault();
3406
+ kt && O.preventDefault();
3405
3407
  },
3406
- [bt]
3408
+ [kt]
3407
3409
  );
3408
3410
  He(() => {
3409
- xt || !H.current || !Be || me.length === Object.keys(se).length && (nr(!0), o && o(Be, st));
3410
- }, [me, se, xt, o, Be, st]), He(() => (nt(window.location.origin), window.addEventListener("message", it), window.addEventListener("beforeunload", ot), () => {
3411
- window.removeEventListener("beforeunload", ot), window.removeEventListener("message", it);
3412
- }), [q, it, ot]);
3411
+ bt || !H.current || !Be || me.length === Object.keys(se).length && (nr(!0), o && o(Be, at));
3412
+ }, [me, se, bt, o, Be, at]), He(() => (st(window.location.origin), window.addEventListener("message", ot), window.addEventListener("beforeunload", ct), () => {
3413
+ window.removeEventListener("beforeunload", ct), window.removeEventListener("message", ot);
3414
+ }), [q, ot, ct]);
3413
3415
  const fr = Te(
3414
3416
  (O) => {
3415
- me.find((S) => S.contentWindow === O.contentWindow) || sr((S) => [...S, O]);
3417
+ me.find((C) => C.contentWindow === O.contentWindow) || sr((C) => [...C, O]);
3416
3418
  },
3417
3419
  [me]
3418
3420
  ), hr = async (O, D) => {
3419
3421
  if (!(!H.current || !c || !q || !ee))
3420
- for (const [S, $] of Object.entries(se)) {
3422
+ for (const [C, $] of Object.entries(se)) {
3421
3423
  if (!$) continue;
3422
3424
  const St = {
3423
3425
  stripePmId: O.paymentMethod.id
@@ -3431,7 +3433,7 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3431
3433
  St
3432
3434
  );
3433
3435
  if (w) {
3434
- ur(O), ae(!0), ke(w), Ee($, te, S, w, A);
3436
+ ur(O), ae(!0), ke(w), Ee($, te, C, w, A);
3435
3437
  break;
3436
3438
  }
3437
3439
  }
@@ -3444,9 +3446,9 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3444
3446
  checkoutSecureToken: t,
3445
3447
  registerIframe: fr,
3446
3448
  baseUrl: A
3447
- }, Tt = vs(
3449
+ }, Ct = vs(
3448
3450
  Be,
3449
- st,
3451
+ at,
3450
3452
  ee,
3451
3453
  H.current,
3452
3454
  hr,
@@ -3454,12 +3456,12 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3454
3456
  pr
3455
3457
  ), yr = {
3456
3458
  submit: lr,
3457
- applePay: Tt.apple_pay,
3458
- googlePay: Tt.google_pay
3459
+ applePay: Ct.apple_pay,
3460
+ googlePay: Ct.google_pay
3459
3461
  };
3460
- return /* @__PURE__ */ oe(Zt.Provider, { value: mr, children: /* @__PURE__ */ oe("div", { className: n, ref: H, children: e(yr) }) });
3461
- }, gs = (r) => JSON.stringify(r), rt = (r) => {
3462
- const { subPath: e, styles: t } = r, { formId: n, referer: s, formHeight: a, checkoutSecureToken: i, registerIframe: o, baseUrl: u } = xr(), [c, p] = I(!1), b = Pt(null), T = Oe(() => t ? gs(t) : "", [t]), G = Oe(() => ({
3462
+ return /* @__PURE__ */ oe(jt.Provider, { value: mr, children: /* @__PURE__ */ oe("div", { className: n, ref: H, children: e(yr) }) });
3463
+ }, gs = (r) => JSON.stringify(r), nt = (r) => {
3464
+ const { subPath: e, styles: t } = r, { formId: n, referer: s, formHeight: a, checkoutSecureToken: i, registerIframe: o, baseUrl: u } = xr(), [c, p] = I(!1), b = Zt(null), T = Oe(() => t ? gs(t) : "", [t]), G = Oe(() => ({
3463
3465
  border: "none",
3464
3466
  width: "100%",
3465
3467
  height: a
@@ -3479,13 +3481,13 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
3479
3481
  ref: b
3480
3482
  }
3481
3483
  ) : /* @__PURE__ */ oe("div", {});
3482
- }, ks = ({ styles: r }) => /* @__PURE__ */ oe(rt, { styles: r, subPath: "card-cvc" }), ws = ({ styles: r }) => /* @__PURE__ */ oe(rt, { styles: r, subPath: "card" }), Es = ({ styles: r }) => /* @__PURE__ */ oe(rt, { styles: r, subPath: "card-expiry" }), Ts = ({ styles: r }) => /* @__PURE__ */ oe(rt, { styles: r, subPath: "card-number" });
3484
+ }, ks = ({ styles: r }) => /* @__PURE__ */ oe(nt, { styles: r, subPath: "card-cvc" }), ws = ({ styles: r }) => /* @__PURE__ */ oe(nt, { styles: r, subPath: "card" }), Es = ({ styles: r }) => /* @__PURE__ */ oe(nt, { styles: r, subPath: "card-expiry" }), Ts = ({ styles: r }) => /* @__PURE__ */ oe(nt, { styles: r, subPath: "card-number" });
3483
3485
  export {
3484
3486
  ks as CardCvcElement,
3485
3487
  ws as CardElement,
3486
3488
  Es as CardExpiryElement,
3487
3489
  Ts as CardNumberElement,
3488
3490
  bs as ElementsForm,
3489
- qt as FieldName,
3491
+ tt as FieldName,
3490
3492
  xr as useOpenPayElements
3491
3493
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getopenpay/openpay-js-react",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
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",