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

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 (2) hide show
  1. package/dist/index.js +71 -69
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -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 }), Pt = (t) => t.status === "aborted", It = (t) => t.status === "dirty", Be = (t) => t.status === "valid", He = (t) => typeof Promise < "u" && t instanceof Promise;
346
+ }), je = (t) => ({ status: "dirty", value: t }), V = (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);
@@ -1265,7 +1265,7 @@ class We extends w {
1265
1265
  received: n.parsedType
1266
1266
  }), g;
1267
1267
  }
1268
- return U(e.data);
1268
+ return V(e.data);
1269
1269
  }
1270
1270
  }
1271
1271
  We.create = (t) => new We({
@@ -1361,7 +1361,7 @@ class ht extends w {
1361
1361
  received: n.parsedType
1362
1362
  }), g;
1363
1363
  }
1364
- return U(e.data);
1364
+ return V(e.data);
1365
1365
  }
1366
1366
  }
1367
1367
  ht.create = (t) => new ht({
@@ -1378,7 +1378,7 @@ class Ke extends w {
1378
1378
  received: n.parsedType
1379
1379
  }), g;
1380
1380
  }
1381
- return U(e.data);
1381
+ return V(e.data);
1382
1382
  }
1383
1383
  }
1384
1384
  Ke.create = (t) => new Ke({
@@ -1395,7 +1395,7 @@ class Ye extends w {
1395
1395
  received: n.parsedType
1396
1396
  }), g;
1397
1397
  }
1398
- return U(e.data);
1398
+ return V(e.data);
1399
1399
  }
1400
1400
  }
1401
1401
  Ye.create = (t) => new Ye({
@@ -1407,7 +1407,7 @@ class De extends w {
1407
1407
  super(...arguments), this._any = !0;
1408
1408
  }
1409
1409
  _parse(e) {
1410
- return U(e.data);
1410
+ return V(e.data);
1411
1411
  }
1412
1412
  }
1413
1413
  De.create = (t) => new De({
@@ -1419,7 +1419,7 @@ class Oe extends w {
1419
1419
  super(...arguments), this._unknown = !0;
1420
1420
  }
1421
1421
  _parse(e) {
1422
- return U(e.data);
1422
+ return V(e.data);
1423
1423
  }
1424
1424
  }
1425
1425
  Oe.create = (t) => new Oe({
@@ -1450,7 +1450,7 @@ class yt extends w {
1450
1450
  received: n.parsedType
1451
1451
  }), g;
1452
1452
  }
1453
- return U(e.data);
1453
+ return V(e.data);
1454
1454
  }
1455
1455
  }
1456
1456
  yt.create = (t) => new yt({
@@ -2283,7 +2283,7 @@ class Me extends w {
2283
2283
  const a = { errorMap: r.common.contextualErrorMap }, o = r.data;
2284
2284
  if (this._def.returns instanceof $e) {
2285
2285
  const c = this;
2286
- return U(async function(...u) {
2286
+ return V(async function(...u) {
2287
2287
  const d = new H([]), f = await c._def.args.parseAsync(u, a).catch((x) => {
2288
2288
  throw d.addIssue(n(u, x)), d;
2289
2289
  }), v = await Reflect.apply(o, this, f);
@@ -2293,7 +2293,7 @@ class Me extends w {
2293
2293
  });
2294
2294
  } else {
2295
2295
  const c = this;
2296
- return U(function(...u) {
2296
+ return V(function(...u) {
2297
2297
  const d = c._def.args.safeParse(u, a);
2298
2298
  if (!d.success)
2299
2299
  throw new H([n(u, d.error)]);
@@ -2400,7 +2400,7 @@ class xe extends w {
2400
2400
  options: n
2401
2401
  }), g;
2402
2402
  }
2403
- return U(e.data);
2403
+ return V(e.data);
2404
2404
  }
2405
2405
  get options() {
2406
2406
  return this._def.values;
@@ -2460,7 +2460,7 @@ class tt extends w {
2460
2460
  options: s
2461
2461
  }), g;
2462
2462
  }
2463
- return U(e.data);
2463
+ return V(e.data);
2464
2464
  }
2465
2465
  get enum() {
2466
2466
  return this._def.values;
@@ -2485,7 +2485,7 @@ class $e extends w {
2485
2485
  received: r.parsedType
2486
2486
  }), g;
2487
2487
  const n = r.parsedType === p.promise ? r.data : Promise.resolve(r.data);
2488
- return U(n.then((s) => this._def.type.parseAsync(s, {
2488
+ return V(n.then((s) => this._def.type.parseAsync(s, {
2489
2489
  path: r.path,
2490
2490
  errorMap: r.common.contextualErrorMap
2491
2491
  })));
@@ -2587,7 +2587,7 @@ re.createWithPreprocess = (t, e, r) => new re({
2587
2587
  });
2588
2588
  class oe extends w {
2589
2589
  _parse(e) {
2590
- return this._getType(e) === p.undefined ? U(void 0) : this._def.innerType._parse(e);
2590
+ return this._getType(e) === p.undefined ? V(void 0) : this._def.innerType._parse(e);
2591
2591
  }
2592
2592
  unwrap() {
2593
2593
  return this._def.innerType;
@@ -2600,7 +2600,7 @@ oe.create = (t, e) => new oe({
2600
2600
  });
2601
2601
  class ke extends w {
2602
2602
  _parse(e) {
2603
- return this._getType(e) === p.null ? U(null) : this._def.innerType._parse(e);
2603
+ return this._getType(e) === p.null ? V(null) : this._def.innerType._parse(e);
2604
2604
  }
2605
2605
  unwrap() {
2606
2606
  return this._def.innerType;
@@ -2798,7 +2798,7 @@ var i = /* @__PURE__ */ Object.freeze({
2798
2798
  ParseStatus: D,
2799
2799
  INVALID: g,
2800
2800
  DIRTY: je,
2801
- OK: U,
2801
+ OK: V,
2802
2802
  isAborted: Pt,
2803
2803
  isDirty: It,
2804
2804
  isValid: Be,
@@ -3040,7 +3040,7 @@ const ks = i.object({
3040
3040
  return;
3041
3041
  }
3042
3042
  }), e;
3043
- }, Cs = (t, e) => Array.from(t.querySelectorAll("input[data-opid]") ?? []).reduce((s, a) => {
3043
+ }, Cs = (t, e) => Array.from(t.querySelectorAll("[data-opid]") ?? []).reduce((s, a) => {
3044
3044
  const o = a.getAttribute("data-opid");
3045
3045
  return o ? { ...s, [o]: a.value } : s;
3046
3046
  }, e), lt = (t, e, r, n, s, a, o) => {
@@ -3472,10 +3472,10 @@ const Ut = async (t, e, r) => {
3472
3472
  throw new Error("Stripe is not available as a checkout method");
3473
3473
  const I = As(T[0].metadata), $ = (await Vt(t)).mode === "setup";
3474
3474
  x($);
3475
- const V = await Cr(t, e, $, void 0), O = await Ps(
3475
+ const F = await Cr(t, e, $, void 0), O = await Ps(
3476
3476
  I,
3477
- V.amountAtom,
3478
- V.currency,
3477
+ F.amountAtom,
3478
+ F.currency,
3479
3479
  $
3480
3480
  );
3481
3481
  Ea(O);
@@ -3602,15 +3602,15 @@ const xa = (t, e) => {
3602
3602
  r(`${n}: Unable to send ${E}() reply due to destroyed connection`);
3603
3603
  return;
3604
3604
  }
3605
- const V = {
3605
+ const F = {
3606
3606
  penpal: ce.Reply,
3607
3607
  id: T,
3608
3608
  resolution: C,
3609
3609
  returnValue: $
3610
3610
  };
3611
- C === Re.Rejected && $ instanceof Error && (V.returnValue = rr($), V.returnValueIsError = !0);
3611
+ C === Re.Rejected && $ instanceof Error && (F.returnValue = rr($), F.returnValueIsError = !0);
3612
3612
  try {
3613
- a.postMessage(V, o);
3613
+ a.postMessage(F, o);
3614
3614
  } catch (O) {
3615
3615
  if (O.name === Mt.DataCloneError) {
3616
3616
  const W = {
@@ -3666,8 +3666,8 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
3666
3666
  throw C.code = it.ConnectionDestroyed, C;
3667
3667
  }
3668
3668
  return new Promise((C, $) => {
3669
- const V = Aa(), O = (j) => {
3670
- if (j.source !== c || j.data.penpal !== ce.Reply || j.data.id !== V)
3669
+ const F = Aa(), O = (j) => {
3670
+ if (j.source !== c || j.data.penpal !== ce.Reply || j.data.id !== F)
3671
3671
  return;
3672
3672
  if (d !== "*" && j.origin !== d) {
3673
3673
  s(`${a} received message from origin ${j.origin} which did not match expected origin ${d}`);
@@ -3681,7 +3681,7 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
3681
3681
  o.addEventListener(Te.Message, O);
3682
3682
  const W = {
3683
3683
  penpal: ce.Call,
3684
- id: V,
3684
+ id: F,
3685
3685
  methodName: x,
3686
3686
  args: T
3687
3687
  };
@@ -3754,7 +3754,7 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
3754
3754
  const f = n === "null" ? "*" : n, v = Ar(r), E = La(o, v, n, f), x = $a(v, n, f, c, o);
3755
3755
  return {
3756
3756
  promise: new Promise((I, C) => {
3757
- const $ = Fa(s, d), V = (O) => {
3757
+ const $ = Fa(s, d), F = (O) => {
3758
3758
  if (!(O.source !== e.contentWindow || !O.data)) {
3759
3759
  if (O.data.penpal === ce.Syn) {
3760
3760
  E(O);
@@ -3767,8 +3767,8 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
3767
3767
  }
3768
3768
  }
3769
3769
  };
3770
- window.addEventListener(Te.Message, V), o("Parent: Awaiting handshake"), Va(e, c), u((O) => {
3771
- window.removeEventListener(Te.Message, V), O && C(O);
3770
+ window.addEventListener(Te.Message, F), o("Parent: Awaiting handshake"), Va(e, c), u((O) => {
3771
+ window.removeEventListener(Te.Message, F), O && C(O);
3772
3772
  });
3773
3773
  }),
3774
3774
  destroy() {
@@ -3830,9 +3830,9 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
3830
3830
  onSetupPaymentMethodSuccess: x,
3831
3831
  baseUrl: T,
3832
3832
  enableDynamicPreviews: I
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);
3833
+ } = t, C = T ?? Rs, [$, F] = 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);
3834
3834
  pe(() => {
3835
- const P = { version: "0.0.22", release_version: "0.0.22-alpha.041cf4f" };
3835
+ const P = { version: "0.0.23", release_version: "local_build" };
3836
3836
  window.ojs_version = P;
3837
3837
  }, []);
3838
3838
  const { cdeConn: Ae, connectToCdeIframe: Wt } = Ba(), Kt = pa(
@@ -3846,28 +3846,30 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
3846
3846
  const K = P.source;
3847
3847
  if (!Ka(P.data))
3848
3848
  return;
3849
- const X = JSON.parse(P.data), F = Ss(X), Se = F.elementId;
3850
- if (F.formId !== fe || !Se || F.nonce in O)
3849
+ const X = JSON.parse(P.data), z = Ss(X), Se = z.elementId;
3850
+ if (z.formId !== fe || !Se || z.nonce in O)
3851
3851
  return;
3852
- W((L) => [...L, F.nonce]);
3853
- const A = F.payload, z = A.type;
3854
- if (z === k.enum.LAYOUT) {
3855
- const L = A.height ? `${A.height}px` : "100%";
3856
- Y(L);
3857
- } else if (z === k.enum.FOCUS && s)
3858
- s(F.elementId);
3859
- else if (z === k.enum.BLUR && a)
3860
- a(F.elementId);
3861
- else if (z === k.enum.CHANGE && o)
3862
- o(F.elementId);
3863
- else if (z === k.enum.LOADED) {
3864
- const L = ye.find((M) => M.contentWindow === K);
3865
- if (Ce(!1), !L)
3852
+ W((U) => [...U, z.nonce]);
3853
+ const A = z.payload, L = A.type;
3854
+ if (L === k.enum.LAYOUT) {
3855
+ const U = A.height ? `${A.height}px` : "100%";
3856
+ Y(U);
3857
+ } else if (L === k.enum.FOCUS && s)
3858
+ s(z.elementId);
3859
+ else if (L === k.enum.BLUR && a)
3860
+ a(z.elementId);
3861
+ else if (L === k.enum.CHANGE && o)
3862
+ o(z.elementId);
3863
+ else if (L === k.enum.LOADED) {
3864
+ const U = ye.find((M) => M.contentWindow === K);
3865
+ if (Ce(!1), !U)
3866
3866
  return;
3867
3867
  Mr((M) => ({ ...M, [Se]: K })), $r(A.totalAmountAtoms), Dr(A.currency), Lr(A.checkoutPaymentMethods), ae || Zr(A.sessionId);
3868
- } else if (z === k.enum.TOKENIZE_STARTED)
3869
- Ce(!0), f && f();
3870
- else if (z === k.enum.PAYMENT_FLOW_STARTED) {
3868
+ } else if (L === k.enum.TOKENIZE_STARTED)
3869
+ Ce(!0);
3870
+ else if (L === k.enum.CHECKOUT_STARTED)
3871
+ f && f();
3872
+ else if (L === k.enum.PAYMENT_FLOW_STARTED) {
3871
3873
  if (!ne)
3872
3874
  throw new Error("extraData not populated");
3873
3875
  if (!Ae)
@@ -3915,22 +3917,22 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
3915
3917
  const Q = Lt(M);
3916
3918
  Ce(!1), se(!1), E && E(Q);
3917
3919
  });
3918
- } else if (z === k.enum.TOKENIZE_SUCCESS && ne) {
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);
3921
- } else if (z === k.enum.CHECKOUT_SUCCESS)
3920
+ } else if (L === k.enum.TOKENIZE_SUCCESS && ne) {
3921
+ const U = zt + 1, M = U === Object.keys(ge).length;
3922
+ !qt && (M || A.isReadyForCheckout) ? (Ue(K, fe, Se, ne, C), se(!0), Le(void 0)) : ct(U);
3923
+ } else if (L === k.enum.CHECKOUT_SUCCESS)
3922
3924
  Ce(!1), ct(0), se(!1), v && v(A.invoiceUrls, A.subscriptionIds, A.customerId);
3923
- else if (z === k.enum.SETUP_PAYMENT_METHOD_SUCCESS)
3925
+ else if (L === k.enum.SETUP_PAYMENT_METHOD_SUCCESS)
3924
3926
  Ce(!1), ct(0), se(!1), x && x(A.paymentMethodId);
3925
- else if (z === k.enum.LOAD_ERROR)
3927
+ else if (L === k.enum.LOAD_ERROR)
3926
3928
  u && u(A.message);
3927
- else if (z === k.enum.VALIDATION_ERROR) {
3928
- const L = ne == null ? void 0 : ne.checkoutPaymentMethod.provider;
3929
- (L === "credit_card" || L === void 0) && d && d(A.elementType, A.errors, Se);
3930
- } else if (z === k.enum.TOKENIZE_ERROR || z === k.enum.CHECKOUT_ERROR)
3929
+ else if (L === k.enum.VALIDATION_ERROR) {
3930
+ const U = ne == null ? void 0 : ne.checkoutPaymentMethod.provider;
3931
+ (U === "credit_card" || U === void 0) && d && d(A.elementType, A.errors, Se);
3932
+ } else if (L === k.enum.TOKENIZE_ERROR || L === k.enum.CHECKOUT_ERROR)
3931
3933
  if (A.message === "3DS_REQUIRED") {
3932
- const L = le == null ? void 0 : le.find((M) => M.provider === "credit_card");
3933
- if (!ae || !G.current || !d || !L) return;
3934
+ const U = le == null ? void 0 : le.find((M) => M.provider === "credit_card");
3935
+ if (!ae || !G.current || !d || !U) return;
3934
3936
  for (const [M, Q] of Object.entries(ge)) {
3935
3937
  if (!Q) continue;
3936
3938
  const ie = lt(
@@ -3940,7 +3942,7 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
3940
3942
  d,
3941
3943
  // Only stripe supports frontend 3DS right now,
3942
3944
  // so we pass processor_name: 'stripe' to tell delegator to only use stripe
3943
- { ...L, processor_name: "stripe" },
3945
+ { ...U, processor_name: "stripe" },
3944
3946
  !1
3945
3947
  );
3946
3948
  if (ie) {
@@ -3988,8 +3990,8 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
3988
3990
  !1
3989
3991
  );
3990
3992
  if (K) {
3991
- for (const [X, F] of Object.entries(ge))
3992
- F && Ue(F, fe, X, K, C);
3993
+ for (const [X, z] of Object.entries(ge))
3994
+ z && Ue(z, fe, X, K, C);
3993
3995
  K.type = k.enum.CHECKOUT, Le(K);
3994
3996
  }
3995
3997
  }, [G, ge, fe, d, ae, C, le]), kt = ve(
@@ -4001,7 +4003,7 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
4001
4003
  pe(() => {
4002
4004
  if (J || !G.current) return;
4003
4005
  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), () => {
4006
+ }, [ye, ge, J, c, Ht, Bt]), pe(() => (F(window.location.origin), window.addEventListener("message", xt), window.addEventListener("beforeunload", kt), () => {
4005
4007
  window.removeEventListener("beforeunload", kt), window.removeEventListener("message", xt);
4006
4008
  }), [ae, xt, kt]);
4007
4009
  const Fr = ve(
@@ -4011,8 +4013,8 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
4011
4013
  [ye, Wt]
4012
4014
  ), zr = async (P, K) => {
4013
4015
  if (!(!G.current || !d || !ae || !le))
4014
- for (const [X, F] of Object.entries(ge)) {
4015
- if (!F) continue;
4016
+ for (const [X, z] of Object.entries(ge)) {
4017
+ if (!z) continue;
4016
4018
  const Se = {
4017
4019
  stripePmId: P.paymentMethod.id
4018
4020
  }, dt = lt(
@@ -4025,7 +4027,7 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
4025
4027
  Se
4026
4028
  );
4027
4029
  if (dt) {
4028
- Ur(P), se(!0), Le(dt), Ue(F, fe, X, dt, C);
4030
+ Ur(P), se(!0), Le(dt), Ue(z, fe, X, dt, C);
4029
4031
  break;
4030
4032
  }
4031
4033
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getopenpay/openpay-js-react",
3
- "version": "0.0.22-alpha.041cf4f",
3
+ "version": "0.0.23-alpha.1",
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",