@getopenpay/openpay-js-react 0.0.23-alpha.1 → 0.0.23
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.js +68 -70
- 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 }),
|
|
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);
|
|
@@ -1265,7 +1265,7 @@ class We extends w {
|
|
|
1265
1265
|
received: n.parsedType
|
|
1266
1266
|
}), g;
|
|
1267
1267
|
}
|
|
1268
|
-
return
|
|
1268
|
+
return U(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
|
|
1364
|
+
return U(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
|
|
1381
|
+
return U(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
|
|
1398
|
+
return U(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
|
|
1410
|
+
return U(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
|
|
1422
|
+
return U(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
|
|
1453
|
+
return U(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
|
|
2286
|
+
return U(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
|
|
2296
|
+
return U(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
|
|
2403
|
+
return U(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
|
|
2463
|
+
return U(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
|
|
2488
|
+
return U(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 ?
|
|
2590
|
+
return this._getType(e) === p.undefined ? U(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 ?
|
|
2603
|
+
return this._getType(e) === p.null ? U(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:
|
|
2801
|
+
OK: U,
|
|
2802
2802
|
isAborted: Pt,
|
|
2803
2803
|
isDirty: It,
|
|
2804
2804
|
isValid: Be,
|
|
@@ -3075,7 +3075,7 @@ const ks = i.object({
|
|
|
3075
3075
|
elementId: r
|
|
3076
3076
|
};
|
|
3077
3077
|
t.postMessage(JSON.stringify(a), s);
|
|
3078
|
-
}, Rs = "https://cde.
|
|
3078
|
+
}, Rs = "https://cde.getopenpay.com", Os = {
|
|
3079
3079
|
usd: "usd",
|
|
3080
3080
|
brl: "brl"
|
|
3081
3081
|
}, Dt = async (t) => {
|
|
@@ -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
|
|
3475
|
+
const V = await Cr(t, e, $, void 0), O = await Ps(
|
|
3476
3476
|
I,
|
|
3477
|
-
|
|
3478
|
-
|
|
3477
|
+
V.amountAtom,
|
|
3478
|
+
V.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
|
|
3605
|
+
const V = {
|
|
3606
3606
|
penpal: ce.Reply,
|
|
3607
3607
|
id: T,
|
|
3608
3608
|
resolution: C,
|
|
3609
3609
|
returnValue: $
|
|
3610
3610
|
};
|
|
3611
|
-
C === Re.Rejected && $ instanceof Error && (
|
|
3611
|
+
C === Re.Rejected && $ instanceof Error && (V.returnValue = rr($), V.returnValueIsError = !0);
|
|
3612
3612
|
try {
|
|
3613
|
-
a.postMessage(
|
|
3613
|
+
a.postMessage(V, 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
|
|
3670
|
-
if (j.source !== c || j.data.penpal !== ce.Reply || j.data.id !==
|
|
3669
|
+
const V = Aa(), O = (j) => {
|
|
3670
|
+
if (j.source !== c || j.data.penpal !== ce.Reply || j.data.id !== V)
|
|
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:
|
|
3684
|
+
id: V,
|
|
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),
|
|
3757
|
+
const $ = Fa(s, d), V = (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,
|
|
3771
|
-
window.removeEventListener(Te.Message,
|
|
3770
|
+
window.addEventListener(Te.Message, V), o("Parent: Awaiting handshake"), Va(e, c), u((O) => {
|
|
3771
|
+
window.removeEventListener(Te.Message, V), O && C(O);
|
|
3772
3772
|
});
|
|
3773
3773
|
}),
|
|
3774
3774
|
destroy() {
|
|
@@ -3830,7 +3830,7 @@ 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, [$,
|
|
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);
|
|
3834
3834
|
pe(() => {
|
|
3835
3835
|
const P = { version: "0.0.23", release_version: "local_build" };
|
|
3836
3836
|
window.ojs_version = P;
|
|
@@ -3846,30 +3846,28 @@ 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),
|
|
3850
|
-
if (
|
|
3849
|
+
const X = JSON.parse(P.data), F = Ss(X), Se = F.elementId;
|
|
3850
|
+
if (F.formId !== fe || !Se || F.nonce in O)
|
|
3851
3851
|
return;
|
|
3852
|
-
W((
|
|
3853
|
-
const A =
|
|
3854
|
-
if (
|
|
3855
|
-
const
|
|
3856
|
-
Y(
|
|
3857
|
-
} else if (
|
|
3858
|
-
s(
|
|
3859
|
-
else if (
|
|
3860
|
-
a(
|
|
3861
|
-
else if (
|
|
3862
|
-
o(
|
|
3863
|
-
else if (
|
|
3864
|
-
const
|
|
3865
|
-
if (Ce(!1), !
|
|
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)
|
|
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 (
|
|
3869
|
-
Ce(!0);
|
|
3870
|
-
else if (
|
|
3871
|
-
f && f();
|
|
3872
|
-
else if (L === k.enum.PAYMENT_FLOW_STARTED) {
|
|
3868
|
+
} else if (z === k.enum.TOKENIZE_STARTED)
|
|
3869
|
+
Ce(!0), f && f();
|
|
3870
|
+
else if (z === k.enum.PAYMENT_FLOW_STARTED) {
|
|
3873
3871
|
if (!ne)
|
|
3874
3872
|
throw new Error("extraData not populated");
|
|
3875
3873
|
if (!Ae)
|
|
@@ -3917,22 +3915,22 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
|
|
|
3917
3915
|
const Q = Lt(M);
|
|
3918
3916
|
Ce(!1), se(!1), E && E(Q);
|
|
3919
3917
|
});
|
|
3920
|
-
} else if (
|
|
3921
|
-
const
|
|
3922
|
-
!qt && (M || A.isReadyForCheckout) ? (Ue(K, fe, Se, ne, C), se(!0), Le(void 0)) : ct(
|
|
3923
|
-
} else if (
|
|
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)
|
|
3924
3922
|
Ce(!1), ct(0), se(!1), v && v(A.invoiceUrls, A.subscriptionIds, A.customerId);
|
|
3925
|
-
else if (
|
|
3923
|
+
else if (z === k.enum.SETUP_PAYMENT_METHOD_SUCCESS)
|
|
3926
3924
|
Ce(!1), ct(0), se(!1), x && x(A.paymentMethodId);
|
|
3927
|
-
else if (
|
|
3925
|
+
else if (z === k.enum.LOAD_ERROR)
|
|
3928
3926
|
u && u(A.message);
|
|
3929
|
-
else if (
|
|
3930
|
-
const
|
|
3931
|
-
(
|
|
3932
|
-
} else if (
|
|
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)
|
|
3933
3931
|
if (A.message === "3DS_REQUIRED") {
|
|
3934
|
-
const
|
|
3935
|
-
if (!ae || !G.current || !d || !
|
|
3932
|
+
const L = le == null ? void 0 : le.find((M) => M.provider === "credit_card");
|
|
3933
|
+
if (!ae || !G.current || !d || !L) return;
|
|
3936
3934
|
for (const [M, Q] of Object.entries(ge)) {
|
|
3937
3935
|
if (!Q) continue;
|
|
3938
3936
|
const ie = lt(
|
|
@@ -3942,7 +3940,7 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
|
|
|
3942
3940
|
d,
|
|
3943
3941
|
// Only stripe supports frontend 3DS right now,
|
|
3944
3942
|
// so we pass processor_name: 'stripe' to tell delegator to only use stripe
|
|
3945
|
-
{ ...
|
|
3943
|
+
{ ...L, processor_name: "stripe" },
|
|
3946
3944
|
!1
|
|
3947
3945
|
);
|
|
3948
3946
|
if (ie) {
|
|
@@ -3990,8 +3988,8 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
|
|
|
3990
3988
|
!1
|
|
3991
3989
|
);
|
|
3992
3990
|
if (K) {
|
|
3993
|
-
for (const [X,
|
|
3994
|
-
|
|
3991
|
+
for (const [X, F] of Object.entries(ge))
|
|
3992
|
+
F && Ue(F, fe, X, K, C);
|
|
3995
3993
|
K.type = k.enum.CHECKOUT, Le(K);
|
|
3996
3994
|
}
|
|
3997
3995
|
}, [G, ge, fe, d, ae, C, le]), kt = ve(
|
|
@@ -4003,7 +4001,7 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
|
|
|
4003
4001
|
pe(() => {
|
|
4004
4002
|
if (J || !G.current) return;
|
|
4005
4003
|
ye.length > 0 && ye.length === Object.keys(ge).length && (Nr(!0), c && c(Ht, Bt));
|
|
4006
|
-
}, [ye, ge, J, c, Ht, Bt]), pe(() => (
|
|
4004
|
+
}, [ye, ge, J, c, Ht, Bt]), pe(() => (V(window.location.origin), window.addEventListener("message", xt), window.addEventListener("beforeunload", kt), () => {
|
|
4007
4005
|
window.removeEventListener("beforeunload", kt), window.removeEventListener("message", xt);
|
|
4008
4006
|
}), [ae, xt, kt]);
|
|
4009
4007
|
const Fr = ve(
|
|
@@ -4013,8 +4011,8 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
|
|
|
4013
4011
|
[ye, Wt]
|
|
4014
4012
|
), zr = async (P, K) => {
|
|
4015
4013
|
if (!(!G.current || !d || !ae || !le))
|
|
4016
|
-
for (const [X,
|
|
4017
|
-
if (!
|
|
4014
|
+
for (const [X, F] of Object.entries(ge)) {
|
|
4015
|
+
if (!F) continue;
|
|
4018
4016
|
const Se = {
|
|
4019
4017
|
stripePmId: P.paymentMethod.id
|
|
4020
4018
|
}, dt = lt(
|
|
@@ -4027,7 +4025,7 @@ const Aa = () => ++Ia, Pr = ".", Ir = (t) => t ? t.split(Pr) : [], Na = (t) => t
|
|
|
4027
4025
|
Se
|
|
4028
4026
|
);
|
|
4029
4027
|
if (dt) {
|
|
4030
|
-
Ur(P), se(!0), Le(dt), Ue(
|
|
4028
|
+
Ur(P), se(!0), Le(dt), Ue(F, fe, X, dt, C);
|
|
4031
4029
|
break;
|
|
4032
4030
|
}
|
|
4033
4031
|
}
|
package/package.json
CHANGED