@getopenpay/openpay-js-react 0.0.21 → 0.0.22-alpha.041cf4f

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
@@ -70,6 +70,7 @@ declare type ElementsFormChildrenProps = {
70
70
  submit: () => void;
71
71
  applePay: PaymentRequestStatus;
72
72
  googlePay: PaymentRequestStatus;
73
+ stripeLink: PaymentRequestStatus;
73
74
  loaded: boolean;
74
75
  preview: DynamicPreview;
75
76
  };
package/dist/index.js CHANGED
@@ -15,8 +15,8 @@ const nr = Kr({
15
15
  return t;
16
16
  };
17
17
  var Z = [];
18
- for (var Tt = 0; Tt < 256; ++Tt)
19
- Z.push((Tt + 256).toString(16).slice(1));
18
+ for (var Ct = 0; Ct < 256; ++Ct)
19
+ Z.push((Ct + 256).toString(16).slice(1));
20
20
  function Gr(t, e = 0) {
21
21
  return (Z[t[e + 0]] + Z[t[e + 1]] + Z[t[e + 2]] + Z[t[e + 3]] + "-" + Z[t[e + 4]] + Z[t[e + 5]] + "-" + Z[t[e + 6]] + Z[t[e + 7]] + "-" + Z[t[e + 8]] + Z[t[e + 9]] + "-" + Z[t[e + 10]] + Z[t[e + 11]] + Z[t[e + 12]] + Z[t[e + 13]] + Z[t[e + 14]] + Z[t[e + 15]]).toLowerCase();
22
22
  }
@@ -27,12 +27,12 @@ function Qr() {
27
27
  return ut(Xr);
28
28
  }
29
29
  var en = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
30
- const Kt = {
30
+ const Yt = {
31
31
  randomUUID: en
32
32
  };
33
33
  function sr(t, e, r) {
34
- if (Kt.randomUUID && !e && !t)
35
- return Kt.randomUUID();
34
+ if (Yt.randomUUID && !e && !t)
35
+ return Yt.randomUUID();
36
36
  t = t || {};
37
37
  var n = t.random || (t.rng || Qr)();
38
38
  return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, Gr(n);
@@ -73,14 +73,14 @@ var b;
73
73
  }
74
74
  t.joinValues = n, t.jsonStringifyReplacer = (s, a) => typeof a == "bigint" ? a.toString() : a;
75
75
  })(b || (b = {}));
76
- var St;
76
+ var Ot;
77
77
  (function(t) {
78
78
  t.mergeShapes = (e, r) => ({
79
79
  ...e,
80
80
  ...r
81
81
  // second overwrites first
82
82
  });
83
- })(St || (St = {}));
83
+ })(Ot || (Ot = {}));
84
84
  const p = b.arrayToEnum([
85
85
  "string",
86
86
  "nan",
@@ -343,7 +343,7 @@ class D {
343
343
  }
344
344
  const g = Object.freeze({
345
345
  status: "aborted"
346
- }), je = (t) => ({ status: "dirty", value: t }), U = (t) => ({ status: "valid", value: t }), Rt = (t) => t.status === "aborted", Ot = (t) => t.status === "dirty", Be = (t) => t.status === "valid", He = (t) => typeof Promise < "u" && t instanceof Promise;
346
+ }), je = (t) => ({ status: "dirty", value: t }), U = (t) => ({ status: "valid", value: t }), Pt = (t) => t.status === "aborted", It = (t) => t.status === "dirty", Be = (t) => t.status === "valid", He = (t) => typeof Promise < "u" && t instanceof Promise;
347
347
  function pt(t, e, r, n) {
348
348
  if (typeof e == "function" ? t !== e || !n : !e.has(t)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
349
349
  return e.get(t);
@@ -365,7 +365,7 @@ class de {
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 Yt = (t, e) => {
368
+ const Jt = (t, e) => {
369
369
  if (Be(e))
370
370
  return { success: !0, data: e.value };
371
371
  if (!t.common.issues.length)
@@ -455,7 +455,7 @@ class w {
455
455
  data: e,
456
456
  parsedType: _e(e)
457
457
  }, a = this._parseSync({ data: e, path: s.path, parent: s });
458
- return Yt(s, a);
458
+ return Jt(s, a);
459
459
  }
460
460
  async parseAsync(e, r) {
461
461
  const n = await this.safeParseAsync(e, r);
@@ -476,7 +476,7 @@ class w {
476
476
  data: e,
477
477
  parsedType: _e(e)
478
478
  }, s = this._parse({ data: e, path: n.path, parent: n }), a = await (He(s) ? s : Promise.resolve(s));
479
- return Yt(n, a);
479
+ return Jt(n, a);
480
480
  }
481
481
  refine(e, r) {
482
482
  const n = (s) => typeof r == "string" || typeof r > "u" ? { message: r } : typeof r == "function" ? r(s) : r;
@@ -540,7 +540,7 @@ class w {
540
540
  });
541
541
  }
542
542
  brand() {
543
- return new jt({
543
+ return new Zt({
544
544
  typeName: y.ZodBranded,
545
545
  type: this,
546
546
  ..._(this._def)
@@ -576,7 +576,7 @@ class w {
576
576
  }
577
577
  }
578
578
  const sn = /^c[^\s-]{8,}$/i, an = /^[0-9a-z]+$/, on = /^[0-9A-HJKMNP-TV-Z]{26}$/, cn = /^[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, dn = /^[a-z0-9_-]{21}$/i, un = /^[-+]?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)?)??$/, ln = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, fn = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
579
- let Ct;
579
+ let St;
580
580
  const mn = /^(?:(?: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])$/, pn = /^(([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})))$/, hn = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, or = "((\\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])))", yn = new RegExp(`^${or}$`);
581
581
  function cr(t) {
582
582
  let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
@@ -648,7 +648,7 @@ class ee extends w {
648
648
  message: a.message
649
649
  }), n.dirty());
650
650
  else if (a.kind === "emoji")
651
- Ct || (Ct = new RegExp(fn, "u")), Ct.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
651
+ St || (St = new RegExp(fn, "u")), St.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
652
652
  validation: "emoji",
653
653
  code: l.invalid_string,
654
654
  message: a.message
@@ -1906,7 +1906,7 @@ Je.create = (t, e) => new Je({
1906
1906
  typeName: y.ZodUnion,
1907
1907
  ..._(e)
1908
1908
  });
1909
- const me = (t) => t instanceof Qe ? me(t.schema) : t instanceof re ? me(t.innerType()) : t instanceof et ? [t.value] : t instanceof xe ? t.options : t instanceof tt ? b.objectValues(t.enum) : t instanceof rt ? me(t._def.innerType) : t instanceof Ke ? [void 0] : t instanceof Ye ? [null] : t instanceof oe ? [void 0, ...me(t.unwrap())] : t instanceof ke ? [null, ...me(t.unwrap())] : t instanceof jt || t instanceof st ? me(t.unwrap()) : t instanceof nt ? me(t._def.innerType) : [];
1909
+ const me = (t) => t instanceof Qe ? me(t.schema) : t instanceof re ? me(t.innerType()) : t instanceof et ? [t.value] : t instanceof xe ? t.options : t instanceof tt ? b.objectValues(t.enum) : t instanceof rt ? me(t._def.innerType) : t instanceof Ke ? [void 0] : t instanceof Ye ? [null] : t instanceof oe ? [void 0, ...me(t.unwrap())] : t instanceof ke ? [null, ...me(t.unwrap())] : t instanceof Zt || t instanceof st ? me(t.unwrap()) : t instanceof nt ? me(t._def.innerType) : [];
1910
1910
  class wt extends w {
1911
1911
  _parse(e) {
1912
1912
  const { ctx: r } = this._processInputParams(e);
@@ -1969,14 +1969,14 @@ class wt extends w {
1969
1969
  });
1970
1970
  }
1971
1971
  }
1972
- function Pt(t, e) {
1972
+ function At(t, e) {
1973
1973
  const r = _e(t), n = _e(e);
1974
1974
  if (t === e)
1975
1975
  return { valid: !0, data: t };
1976
1976
  if (r === p.object && n === p.object) {
1977
1977
  const s = b.objectKeys(e), a = b.objectKeys(t).filter((c) => s.indexOf(c) !== -1), o = { ...t, ...e };
1978
1978
  for (const c of a) {
1979
- const u = Pt(t[c], e[c]);
1979
+ const u = At(t[c], e[c]);
1980
1980
  if (!u.valid)
1981
1981
  return { valid: !1 };
1982
1982
  o[c] = u.data;
@@ -1987,7 +1987,7 @@ function Pt(t, e) {
1987
1987
  return { valid: !1 };
1988
1988
  const s = [];
1989
1989
  for (let a = 0; a < t.length; a++) {
1990
- const o = t[a], c = e[a], u = Pt(o, c);
1990
+ const o = t[a], c = e[a], u = At(o, c);
1991
1991
  if (!u.valid)
1992
1992
  return { valid: !1 };
1993
1993
  s.push(u.data);
@@ -1998,10 +1998,10 @@ function Pt(t, e) {
1998
1998
  class Ge extends w {
1999
1999
  _parse(e) {
2000
2000
  const { status: r, ctx: n } = this._processInputParams(e), s = (a, o) => {
2001
- if (Rt(a) || Rt(o))
2001
+ if (Pt(a) || Pt(o))
2002
2002
  return g;
2003
- const c = Pt(a.value, o.value);
2004
- return c.valid ? ((Ot(a) || Ot(o)) && r.dirty(), { status: r.value, value: c.data }) : (m(n, {
2003
+ const c = At(a.value, o.value);
2004
+ return c.valid ? ((It(a) || It(o)) && r.dirty(), { status: r.value, value: c.data }) : (m(n, {
2005
2005
  code: l.invalid_intersection_types
2006
2006
  }), g);
2007
2007
  };
@@ -2692,7 +2692,7 @@ _t.create = (t) => new _t({
2692
2692
  ..._(t)
2693
2693
  });
2694
2694
  const wn = Symbol("zod_brand");
2695
- class jt extends w {
2695
+ class Zt extends w {
2696
2696
  _parse(e) {
2697
2697
  const { ctx: r } = this._processInputParams(e), n = r.data;
2698
2698
  return this._def.type._parse({
@@ -2777,7 +2777,7 @@ var y;
2777
2777
  })(y || (y = {}));
2778
2778
  const En = (t, e = {
2779
2779
  message: `Input not instance of ${t.name}`
2780
- }) => lr((r) => r instanceof t, e), fr = ee.create, mr = be.create, xn = _t.create, kn = Ee.create, pr = We.create, Tn = Pe.create, Cn = ht.create, Sn = Ke.create, Rn = Ye.create, On = De.create, Pn = Oe.create, In = he.create, An = yt.create, Nn = te.create, jn = R.create, Mn = R.strictCreate, Zn = Je.create, Dn = wt.create, $n = Ge.create, Ln = ue.create, Un = Xe.create, Vn = gt.create, Fn = Ie.create, zn = Me.create, qn = Qe.create, Bn = et.create, Hn = xe.create, Wn = tt.create, Kn = $e.create, Jt = re.create, Yn = oe.create, Jn = ke.create, Gn = re.createWithPreprocess, Xn = ot.create, Qn = () => fr().optional(), es = () => mr().optional(), ts = () => pr().optional(), rs = {
2780
+ }) => lr((r) => r instanceof t, e), fr = ee.create, mr = be.create, xn = _t.create, kn = Ee.create, pr = We.create, Tn = Pe.create, Cn = ht.create, Sn = Ke.create, Rn = Ye.create, On = De.create, Pn = Oe.create, In = he.create, An = yt.create, Nn = te.create, jn = R.create, Mn = R.strictCreate, Zn = Je.create, Dn = wt.create, $n = Ge.create, Ln = ue.create, Un = Xe.create, Vn = gt.create, Fn = Ie.create, zn = Me.create, qn = Qe.create, Bn = et.create, Hn = xe.create, Wn = tt.create, Kn = $e.create, Gt = re.create, Yn = oe.create, Jn = ke.create, Gn = re.createWithPreprocess, Xn = ot.create, Qn = () => fr().optional(), es = () => mr().optional(), ts = () => pr().optional(), rs = {
2781
2781
  string: (t) => ee.create({ ...t, coerce: !0 }),
2782
2782
  number: (t) => be.create({ ...t, coerce: !0 }),
2783
2783
  boolean: (t) => We.create({
@@ -2799,15 +2799,15 @@ var i = /* @__PURE__ */ Object.freeze({
2799
2799
  INVALID: g,
2800
2800
  DIRTY: je,
2801
2801
  OK: U,
2802
- isAborted: Rt,
2803
- isDirty: Ot,
2802
+ isAborted: Pt,
2803
+ isDirty: It,
2804
2804
  isValid: Be,
2805
2805
  isAsync: He,
2806
2806
  get util() {
2807
2807
  return b;
2808
2808
  },
2809
2809
  get objectUtil() {
2810
- return St;
2810
+ return Ot;
2811
2811
  },
2812
2812
  ZodParsedType: p,
2813
2813
  getParsedType: _e,
@@ -2848,7 +2848,7 @@ var i = /* @__PURE__ */ Object.freeze({
2848
2848
  ZodCatch: nt,
2849
2849
  ZodNaN: _t,
2850
2850
  BRAND: wn,
2851
- ZodBranded: jt,
2851
+ ZodBranded: Zt,
2852
2852
  ZodPipeline: ot,
2853
2853
  ZodReadonly: st,
2854
2854
  custom: lr,
@@ -2865,7 +2865,7 @@ var i = /* @__PURE__ */ Object.freeze({
2865
2865
  boolean: pr,
2866
2866
  date: Tn,
2867
2867
  discriminatedUnion: Dn,
2868
- effect: Jt,
2868
+ effect: Gt,
2869
2869
  enum: Hn,
2870
2870
  function: zn,
2871
2871
  instanceof: En,
@@ -2892,7 +2892,7 @@ var i = /* @__PURE__ */ Object.freeze({
2892
2892
  strictObject: Mn,
2893
2893
  string: fr,
2894
2894
  symbol: Cn,
2895
- transformer: Jt,
2895
+ transformer: Gt,
2896
2896
  tuple: Ln,
2897
2897
  undefined: Sn,
2898
2898
  union: Zn,
@@ -2903,14 +2903,14 @@ var i = /* @__PURE__ */ Object.freeze({
2903
2903
  quotelessJson: tn,
2904
2904
  ZodError: H
2905
2905
  });
2906
- const B = i.string().trim().min(1, { message: "Cannot be blank" }), q = i.string().trim().optional(), It = (t) => i.nullable(t.optional());
2906
+ const B = i.string().trim().min(1, { message: "Cannot be blank" }), q = i.string().trim().optional(), Nt = (t) => i.nullable(t.optional());
2907
2907
  var at = /* @__PURE__ */ ((t) => (t.FIRST_NAME = "firstName", t.LAST_NAME = "lastName", t.EMAIL = "email", t.ZIP_CODE = "zipCode", t.CITY = "city", t.STATE = "state", t.COUNTRY = "country", t.ADDRESS = "address", t.PHONE = "phone", t.PROMOTION_CODE = "promotionCode", t))(at || {});
2908
2908
  const hr = i.nativeEnum(at);
2909
2909
  var yr = /* @__PURE__ */ ((t) => (t.CARD_NUMBER = "cardNumber", t.CARD_EXPIRY = "cardExpiry", t.CARD_CVC = "cardCvc", t))(yr || {});
2910
2910
  const gr = i.nativeEnum(yr), ss = i.union([hr, gr]), _r = i.object({
2911
2911
  provider: i.string(),
2912
- processor_name: It(i.string()),
2913
- metadata: It(i.record(i.string(), i.any()))
2912
+ processor_name: Nt(i.string()),
2913
+ metadata: Nt(i.record(i.string(), i.any()))
2914
2914
  }), as = i.object({
2915
2915
  id: i.string()
2916
2916
  });
@@ -3026,7 +3026,7 @@ i.object({
3026
3026
  });
3027
3027
  i.object({
3028
3028
  secure_token: i.string(),
3029
- existing_cc_pm_id: It(i.string())
3029
+ existing_cc_pm_id: Nt(i.string())
3030
3030
  });
3031
3031
  const ks = i.object({
3032
3032
  payment_methods: i.array(as)
@@ -3051,7 +3051,7 @@ const ks = i.object({
3051
3051
  paymentFlowMetadata: o,
3052
3052
  doNotUseLegacyCCFlow: a
3053
3053
  });
3054
- (s.provider === "apple_pay" || s.provider === "google_pay") && (c[at.ZIP_CODE] || (c[at.ZIP_CODE] = "00000"));
3054
+ (s.provider === "apple_pay" || s.provider === "google_pay" || s.provider === "stripe_link") && (c[at.ZIP_CODE] || (c[at.ZIP_CODE] = "00000"));
3055
3055
  const u = vr.safeParse(c);
3056
3056
  if (u.success)
3057
3057
  return u.data;
@@ -3075,17 +3075,17 @@ const ks = i.object({
3075
3075
  elementId: r
3076
3076
  };
3077
3077
  t.postMessage(JSON.stringify(a), s);
3078
- }, Rs = "https://cde.getopenpay.com", Os = {
3078
+ }, Rs = "https://cde.openpaystaging.com", Os = {
3079
3079
  usd: "usd",
3080
3080
  brl: "brl"
3081
- }, Mt = async (t) => {
3081
+ }, Dt = async (t) => {
3082
3082
  for (let r = 0; r < 10; r++)
3083
- Gt() || await wr(500);
3084
- if (!Gt())
3083
+ Xt() || await wr(500);
3084
+ if (!Xt())
3085
3085
  throw new Error("Stripe JS not found.");
3086
3086
  return new Stripe(t);
3087
3087
  }, Ps = async (t, e, r, n) => {
3088
- const s = await Mt(t), a = Os[r.toLowerCase().trim()];
3088
+ const s = await Dt(t), a = Os[r.toLowerCase().trim()];
3089
3089
  return s.paymentRequest({
3090
3090
  // TODO: replace this with stripe account country as soon as we support it
3091
3091
  country: "US",
@@ -3100,7 +3100,7 @@ const ks = i.object({
3100
3100
  });
3101
3101
  }, wr = (t) => new Promise((e) => {
3102
3102
  setTimeout(e, t);
3103
- }), Gt = () => "Stripe" in window, Is = async (t) => new Promise((e, r) => {
3103
+ }), Xt = () => "Stripe" in window, Is = async (t) => new Promise((e, r) => {
3104
3104
  try {
3105
3105
  t.on("paymentmethod", async (n) => {
3106
3106
  e(n);
@@ -3123,7 +3123,7 @@ const ks = i.object({
3123
3123
  throw new Error(`Invalid next action metadata format: ${JSON.stringify(r)}`);
3124
3124
  if (e.paymentMethod.id !== t.paymentFlowMetadata.stripePmId)
3125
3125
  throw new Error(`PM ID mismatch: ${e.paymentMethod.id} != ${t.paymentFlowMetadata.stripePmId}`);
3126
- const s = await (await Mt(r.stripe_pk)).confirmCardSetup(r.client_secret, {
3126
+ const s = await (await Dt(r.stripe_pk)).confirmCardSetup(r.client_secret, {
3127
3127
  payment_method: t.paymentFlowMetadata.stripePmId
3128
3128
  });
3129
3129
  if (s.error)
@@ -3131,7 +3131,7 @@ const ks = i.object({
3131
3131
  e.complete("success");
3132
3132
  }, js = async (t) => {
3133
3133
  var a, o, c, u;
3134
- const e = t.nextActionMetadata, n = await (await Mt(e.stripe_pk)).confirmCardSetup(e.client_secret, {
3134
+ const e = t.nextActionMetadata, n = await (await Dt(e.stripe_pk)).confirmCardSetup(e.client_secret, {
3135
3135
  payment_method: e.stripe_pm_id
3136
3136
  }), s = (a = n.setupIntent) == null ? void 0 : a.status;
3137
3137
  if (s !== "succeeded") throw s === "canceled" ? new Error("Payment cancelled, please click Submit again to pay") : new Error(
@@ -3168,7 +3168,7 @@ const ks = i.object({
3168
3168
  function Zs(t) {
3169
3169
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
3170
3170
  }
3171
- var Zt = { exports: {} }, Ds = Wr;
3171
+ var $t = { exports: {} }, Ds = Wr;
3172
3172
  function br(t, e, r) {
3173
3173
  var n = typeof e == "function";
3174
3174
  Ds.useEffect(function() {
@@ -3182,9 +3182,9 @@ function br(t, e, r) {
3182
3182
  };
3183
3183
  }, n ? r : e);
3184
3184
  }
3185
- Zt.exports = br;
3186
- Zt.exports.useAsyncEffect = br;
3187
- var $s = Zt.exports;
3185
+ $t.exports = br;
3186
+ $t.exports.useAsyncEffect = br;
3187
+ var $s = $t.exports;
3188
3188
  const vt = /* @__PURE__ */ Zs($s), Ls = i.object({
3189
3189
  type: i.string(),
3190
3190
  loc: i.array(i.string()),
@@ -3196,7 +3196,7 @@ const vt = /* @__PURE__ */ Zs($s), Ls = i.object({
3196
3196
  path: i.array(i.string())
3197
3197
  }), Fs = i.array(Vs), zs = {
3198
3198
  "failed to fetch": "Connection error: please double check if you are connected to the internet, then try again"
3199
- }, At = (t) => {
3199
+ }, jt = (t) => {
3200
3200
  const e = t.toLowerCase().trim();
3201
3201
  return zs[e] ?? t;
3202
3202
  }, qs = (t) => {
@@ -3205,17 +3205,17 @@ const vt = /* @__PURE__ */ Zs($s), Ls = i.object({
3205
3205
  } catch {
3206
3206
  return !1;
3207
3207
  }
3208
- }, Bs = (t) => t.length === 1 ? At(t[0].msg) : `Please fix the following errors:
3209
- ${t.map((r) => `• ${At(r.msg)}`).join(`
3208
+ }, Bs = (t) => t.length === 1 ? jt(t[0].msg) : `Please fix the following errors:
3209
+ ${t.map((r) => `• ${jt(r.msg)}`).join(`
3210
3210
  `)}`, Hs = (t) => `Encountered the following errors:
3211
3211
  ${t.map((r) => `- ${r.path.join("/")}: ${r.message}`).join(`
3212
- `)}`, Dt = (t) => {
3212
+ `)}`, Lt = (t) => {
3213
3213
  if (window.cur_error = t, t instanceof Error)
3214
3214
  if (qs(t.message)) {
3215
3215
  const e = JSON.parse(t.message);
3216
3216
  return Us.safeParse(e).success ? Bs(e) : Fs.safeParse(e).success ? Hs(e) : t.message;
3217
3217
  } else
3218
- return At(t.message);
3218
+ return jt(t.message);
3219
3219
  if (typeof t == "object")
3220
3220
  try {
3221
3221
  return JSON.stringify(t);
@@ -3297,14 +3297,14 @@ const Ys = i.object({
3297
3297
  tax_amount_atom: i.number(),
3298
3298
  total_amount_atom: i.number(),
3299
3299
  total_discount_amount_atoms: i.array(xr)
3300
- }), Xt = i.object({
3300
+ }), Qt = i.object({
3301
3301
  created: i.array(ra),
3302
3302
  invoices: i.array(aa)
3303
3303
  }), kr = i.object({
3304
- preview: Xt,
3305
- preview_post_trial: N(Xt),
3304
+ preview: Qt,
3305
+ preview_post_trial: N(Qt),
3306
3306
  coupons: i.array(Er)
3307
- }), Qt = i.object({
3307
+ }), er = i.object({
3308
3308
  status: i.literal("open"),
3309
3309
  token: i.string(),
3310
3310
  email: N(i.string()),
@@ -3319,11 +3319,11 @@ const Ys = i.object({
3319
3319
  i.object({
3320
3320
  mode: i.literal("setup"),
3321
3321
  currency: i.nullable(i.undefined())
3322
- }).extend(Qt.shape),
3322
+ }).extend(er.shape),
3323
3323
  i.object({
3324
3324
  mode: i.enum(["payment", "subscription"]),
3325
3325
  currency: Js
3326
- }).extend(Qt.shape)
3326
+ }).extend(er.shape)
3327
3327
  ]), ia = i.object({
3328
3328
  status: i.literal("complete")
3329
3329
  }), oa = i.object({
@@ -3362,7 +3362,7 @@ i.object({
3362
3362
  required_user_actions: i.array(i.record(i.string(), i.any())),
3363
3363
  cc_pm_id: i.string()
3364
3364
  });
3365
- const $t = async (t, e, r) => {
3365
+ const Ut = async (t, e, r) => {
3366
3366
  const n = await t.send(e);
3367
3367
  if (ua(n))
3368
3368
  throw new Error(`[cde-client] Error querying CDE: ${n.message}`);
@@ -3371,7 +3371,7 @@ const $t = async (t, e, r) => {
3371
3371
  throw s.success ? new Error("Invalid state") : s.error;
3372
3372
  }
3373
3373
  return n;
3374
- }, da = (t, e) => e.safeParse(t).success, ua = (t) => Ys.safeParse(t).success, la = async (t, e) => await $t(t, { type: "get_checkout_preview", payload: e }, kr), Lt = async (t) => await $t(t, { type: "get_prefill", payload: {} }, Tr), fa = async (t, e) => await $t(t, { type: "confirm_payment_flow", payload: e }, ks), ma = (t) => t.reduce((e, r) => e + r, 0), pa = (t, e, r, n) => {
3374
+ }, da = (t, e) => e.safeParse(t).success, ua = (t) => Ys.safeParse(t).success, la = async (t, e) => await Ut(t, { type: "get_checkout_preview", payload: e }, kr), Vt = async (t) => await Ut(t, { type: "get_prefill", payload: {} }, Tr), fa = async (t, e) => await Ut(t, { type: "confirm_payment_flow", payload: e }, ks), ma = (t) => t.reduce((e, r) => e + r, 0), pa = (t, e, r, n) => {
3375
3375
  const [s, a] = S(""), [o, c] = S(""), [u, d] = S(null), [f, v] = S(!1), [E, x] = S(null);
3376
3376
  return vt(async () => {
3377
3377
  if (!n || !t)
@@ -3391,10 +3391,10 @@ const $t = async (t, e, r) => {
3391
3391
  try {
3392
3392
  if (!e || !r || !t)
3393
3393
  return;
3394
- const C = (await Lt(e)).mode === "setup", $ = await Cr(e, r, C, o);
3394
+ const C = (await Vt(e)).mode === "setup", $ = await Cr(e, r, C, o);
3395
3395
  T() && (x(null), d($));
3396
3396
  } catch (I) {
3397
- T() && x(Dt(I));
3397
+ T() && x(Lt(I));
3398
3398
  } finally {
3399
3399
  T() && v(!1);
3400
3400
  }
@@ -3437,10 +3437,11 @@ const $t = async (t, e, r) => {
3437
3437
  const s = await ya(t, e, n);
3438
3438
  return { amountAtom: s.amountAtom, currency: s.currency };
3439
3439
  }
3440
- }, er = i.enum(["apple_pay", "google_pay"]), ga = {
3440
+ }, tr = i.enum(["apple_pay", "google_pay", "stripe_link"]), ga = {
3441
3441
  apple_pay: "applePay",
3442
- google_pay: "googlePay"
3443
- }, tr = {
3442
+ google_pay: "googlePay",
3443
+ stripe_link: "link"
3444
+ }, Rt = {
3444
3445
  isLoading: !0,
3445
3446
  isAvailable: !1,
3446
3447
  startFlow: async () => {
@@ -3452,8 +3453,9 @@ const $t = async (t, e, r) => {
3452
3453
  }
3453
3454
  }, va = (t, e, r, n, s, a, o, c) => {
3454
3455
  const [u, d] = Ms({
3455
- apple_pay: tr,
3456
- google_pay: tr
3456
+ apple_pay: Rt,
3457
+ google_pay: Rt,
3458
+ stripe_link: Rt
3457
3459
  }), f = e === void 0 || r === void 0 || !n || !t, v = c.amount, [E, x] = S(null);
3458
3460
  return pe(() => {
3459
3461
  if (!Sr() || !v || E === null)
@@ -3464,11 +3466,11 @@ const $t = async (t, e, r) => {
3464
3466
  if (f)
3465
3467
  return;
3466
3468
  const T = r.filter(
3467
- (j) => j.processor_name === "stripe" && er.options.map((Y) => String(Y)).includes(j.provider)
3469
+ (j) => j.processor_name === "stripe" && tr.options.map((Y) => String(Y)).includes(j.provider)
3468
3470
  );
3469
3471
  if (T.length === 0)
3470
3472
  throw new Error("Stripe is not available as a checkout method");
3471
- const I = As(T[0].metadata), $ = (await Lt(t)).mode === "setup";
3473
+ const I = As(T[0].metadata), $ = (await Vt(t)).mode === "setup";
3472
3474
  x($);
3473
3475
  const V = await Cr(t, e, $, void 0), O = await Ps(
3474
3476
  I,
@@ -3478,7 +3480,7 @@ const $t = async (t, e, r) => {
3478
3480
  );
3479
3481
  Ea(O);
3480
3482
  const W = await O.canMakePayment();
3481
- for (const j of er.options) {
3483
+ for (const j of tr.options) {
3482
3484
  j.replace("_", "");
3483
3485
  try {
3484
3486
  const Y = T.find((J) => J.provider === j);
@@ -3518,7 +3520,7 @@ const $t = async (t, e, r) => {
3518
3520
  const u = await Is(c);
3519
3521
  o("[startFlow] PR fulfilled. Completing flow..."), r(u, e);
3520
3522
  } catch (o) {
3521
- window.console.error("[startFlow] Error:", o), s(Dt(o));
3523
+ window.console.error("[startFlow] Error:", o), s(Lt(o));
3522
3524
  }
3523
3525
  }, Ea = (t) => {
3524
3526
  if ("ojs_pr" in window)
@@ -3543,10 +3545,10 @@ var it;
3543
3545
  (function(t) {
3544
3546
  t.ConnectionDestroyed = "ConnectionDestroyed", t.ConnectionTimeout = "ConnectionTimeout", t.NoIframeSrc = "NoIframeSrc";
3545
3547
  })(it || (it = {}));
3546
- var Nt;
3548
+ var Mt;
3547
3549
  (function(t) {
3548
3550
  t.DataCloneError = "DataCloneError";
3549
- })(Nt || (Nt = {}));
3551
+ })(Mt || (Mt = {}));
3550
3552
  var Te;
3551
3553
  (function(t) {
3552
3554
  t.Message = "message";
@@ -3610,7 +3612,7 @@ const xa = (t, e) => {
3610
3612
  try {
3611
3613
  a.postMessage(V, o);
3612
3614
  } catch (O) {
3613
- if (O.name === Nt.DataCloneError) {
3615
+ if (O.name === Mt.DataCloneError) {
3614
3616
  const W = {
3615
3617
  penpal: ce.Reply,
3616
3618
  id: T,
@@ -3828,12 +3830,12 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
3828
3830
  onSetupPaymentMethodSuccess: x,
3829
3831
  baseUrl: T,
3830
3832
  enableDynamicPreviews: I
3831
- } = t, C = T ?? Rs, [$, V] = S(void 0), [O, W] = S([]), [j, Y] = S("1px"), [J, Nr] = S(!1), [ne, Le] = S(void 0), [Ut, Ce] = S(!1), [ye, jr] = S([]), [ge, Mr] = S({}), [Vt, ct] = S(0), [Ft, se] = S(!1), [ae, Zr] = S(void 0), [zt, Dr] = S(void 0), [qt, $r] = S(void 0), [le, Lr] = S(void 0), [Et, Ur] = S(void 0), fe = ze(() => `opjs-form-${sr()}`, []), G = qe(null);
3833
+ } = t, C = T ?? Rs, [$, V] = S(void 0), [O, W] = S([]), [j, Y] = S("1px"), [J, Nr] = S(!1), [ne, Le] = S(void 0), [Ft, Ce] = S(!1), [ye, jr] = S([]), [ge, Mr] = S({}), [zt, ct] = S(0), [qt, se] = S(!1), [ae, Zr] = S(void 0), [Bt, Dr] = S(void 0), [Ht, $r] = S(void 0), [le, Lr] = S(void 0), [Et, Ur] = S(void 0), fe = ze(() => `opjs-form-${sr()}`, []), G = qe(null);
3832
3834
  pe(() => {
3833
- const P = { version: "0.0.21", release_version: "local_build" };
3835
+ const P = { version: "0.0.22", release_version: "0.0.22-alpha.041cf4f" };
3834
3836
  window.ojs_version = P;
3835
3837
  }, []);
3836
- const { cdeConn: Ae, connectToCdeIframe: Bt } = Ba(), Ht = pa(
3838
+ const { cdeConn: Ae, connectToCdeIframe: Wt } = Ba(), Kt = pa(
3837
3839
  I ?? !1,
3838
3840
  Ae,
3839
3841
  r,
@@ -3880,7 +3882,7 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
3880
3882
  await Ns(A, Et);
3881
3883
  } else
3882
3884
  throw new Error(`Unknown next action type: ${M}`);
3883
- const Q = await Lt(Ae);
3885
+ const Q = await Vt(Ae);
3884
3886
  if (Q.mode === "setup") {
3885
3887
  const { payment_methods: ie } = await fa(Ae, {
3886
3888
  secure_token: Q.token,
@@ -3910,12 +3912,12 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
3910
3912
  C
3911
3913
  ), se(!0), Le(void 0), f && f();
3912
3914
  }).catch((M) => {
3913
- const Q = Dt(M);
3915
+ const Q = Lt(M);
3914
3916
  Ce(!1), se(!1), E && E(Q);
3915
3917
  });
3916
3918
  } else if (z === k.enum.TOKENIZE_SUCCESS && ne) {
3917
- const L = Vt + 1, M = L === Object.keys(ge).length;
3918
- !Ft && (M || A.isReadyForCheckout) ? (Ue(K, fe, Se, ne, C), se(!0), Le(void 0)) : ct(L);
3919
+ const L = zt + 1, M = L === Object.keys(ge).length;
3920
+ !qt && (M || A.isReadyForCheckout) ? (Ue(K, fe, Se, ne, C), se(!0), Le(void 0)) : ct(L);
3919
3921
  } else if (z === k.enum.CHECKOUT_SUCCESS)
3920
3922
  Ce(!1), ct(0), se(!1), v && v(A.invoiceUrls, A.subscriptionIds, A.customerId);
3921
3923
  else if (z === k.enum.SETUP_PAYMENT_METHOD_SUCCESS)
@@ -3956,8 +3958,8 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
3956
3958
  ne,
3957
3959
  ye,
3958
3960
  ge,
3959
- Vt,
3960
- Ft,
3961
+ zt,
3962
+ qt,
3961
3963
  a,
3962
3964
  o,
3963
3965
  s,
@@ -3992,21 +3994,21 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
3992
3994
  }
3993
3995
  }, [G, ge, fe, d, ae, C, le]), kt = ve(
3994
3996
  (P) => {
3995
- Ut && P.preventDefault();
3997
+ Ft && P.preventDefault();
3996
3998
  },
3997
- [Ut]
3999
+ [Ft]
3998
4000
  );
3999
4001
  pe(() => {
4000
4002
  if (J || !G.current) return;
4001
- ye.length > 0 && ye.length === Object.keys(ge).length && (Nr(!0), c && c(qt, zt));
4002
- }, [ye, ge, J, c, qt, zt]), pe(() => (V(window.location.origin), window.addEventListener("message", xt), window.addEventListener("beforeunload", kt), () => {
4003
+ ye.length > 0 && ye.length === Object.keys(ge).length && (Nr(!0), c && c(Ht, Bt));
4004
+ }, [ye, ge, J, c, Ht, Bt]), pe(() => (V(window.location.origin), window.addEventListener("message", xt), window.addEventListener("beforeunload", kt), () => {
4003
4005
  window.removeEventListener("beforeunload", kt), window.removeEventListener("message", xt);
4004
4006
  }), [ae, xt, kt]);
4005
4007
  const Fr = ve(
4006
4008
  (P) => {
4007
- ye.find((X) => X.contentWindow === P.contentWindow) || (ye.length === 0 && Bt(P), jr((X) => [...X, P]));
4009
+ ye.find((X) => X.contentWindow === P.contentWindow) || (ye.length === 0 && Wt(P), jr((X) => [...X, P]));
4008
4010
  },
4009
- [ye, Bt]
4011
+ [ye, Wt]
4010
4012
  ), zr = async (P, K) => {
4011
4013
  if (!(!G.current || !d || !ae || !le))
4012
4014
  for (const [X, F] of Object.entries(ge)) {
@@ -4036,7 +4038,7 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
4036
4038
  checkoutSecureToken: r,
4037
4039
  registerIframe: Fr,
4038
4040
  baseUrl: C
4039
- }, Wt = va(
4041
+ }, Tt = va(
4040
4042
  Ae,
4041
4043
  r,
4042
4044
  le,
@@ -4044,13 +4046,14 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
4044
4046
  zr,
4045
4047
  d,
4046
4048
  qr,
4047
- Ht
4049
+ Kt
4048
4050
  ), Hr = {
4049
4051
  submit: Vr,
4050
- applePay: Wt.apple_pay,
4051
- googlePay: Wt.google_pay,
4052
+ applePay: Tt.apple_pay,
4053
+ googlePay: Tt.google_pay,
4054
+ stripeLink: Tt.stripe_link,
4052
4055
  loaded: J,
4053
- preview: Ht
4056
+ preview: Kt
4054
4057
  };
4055
4058
  return /* @__PURE__ */ we(nr.Provider, { value: Br, children: /* @__PURE__ */ we("div", { className: n, ref: G, children: e(Hr) }) });
4056
4059
  }, Ya = (t) => JSON.stringify(t), bt = (t) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getopenpay/openpay-js-react",
3
- "version": "0.0.21",
3
+ "version": "0.0.22-alpha.041cf4f",
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",