mainstack-payments 2.0.6 → 2.0.8
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/build/{CashAppPayment-CLJ1mUgV.js → CashAppPayment-CpquRmvy.js} +77 -66
- package/build/CryptoPayments-NwBMYtta.js +125 -0
- package/build/{index-D6I8egaA.js → index-Di1ugn5_.js} +2365 -2260
- package/build/index.css +1 -1
- package/build/mainstack-payments.js +1 -1
- package/build/src/api/index.d.ts +88 -76
- package/build/src/components/CheckoutForm.d.ts +1 -1
- package/build/src/components/ContactAction.d.ts +1 -2
- package/build/src/components/PaymentOptions/CashAppPayment.d.ts +7 -4
- package/build/src/components/PaymentOptions/CryptoPayments.d.ts +7 -3
- package/build/src/components/SummaryCard.d.ts +2 -7
- package/build/src/components/WalletPay.d.ts +8 -3
- package/build/src/hooks/useApi.d.ts +27 -21
- package/build/src/pages/Receipt.d.ts +3 -0
- package/build/src/routes/index.d.ts +1 -0
- package/build/src/types/index.d.ts +19 -1
- package/package.json +1 -1
- package/build/CryptoPayments-D0V_H65D.js +0 -114
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { u as
|
|
3
|
-
import { toast as
|
|
4
|
-
import { u as
|
|
5
|
-
import { memo as
|
|
6
|
-
const
|
|
1
|
+
import { jsxs as i, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { u as z, a as H, v as M, b as N, c as B, E as R, C as $ } from "./index-Di1ugn5_.js";
|
|
3
|
+
import { toast as w, BodyText as j, ChevronRightIcon as k } from "mainstack-design-system";
|
|
4
|
+
import { u as V } from "./payments-B3Hm80pK.js";
|
|
5
|
+
import { memo as Z, useState as D, useCallback as L } from "react";
|
|
6
|
+
const T = (s) => /* @__PURE__ */ i(
|
|
7
7
|
"svg",
|
|
8
8
|
{
|
|
9
9
|
viewBox: "0 0 32 32",
|
|
10
10
|
fill: "none",
|
|
11
11
|
xmlns: "http://www.w3.org/2000/svg",
|
|
12
|
-
...
|
|
12
|
+
...s,
|
|
13
13
|
children: [
|
|
14
|
-
/* @__PURE__ */
|
|
14
|
+
/* @__PURE__ */ i("g", { clipPath: "url(#clip0_3703_1664)", children: [
|
|
15
15
|
/* @__PURE__ */ a(
|
|
16
16
|
"path",
|
|
17
17
|
{
|
|
@@ -32,64 +32,75 @@ const R = (m) => /* @__PURE__ */ l(
|
|
|
32
32
|
/* @__PURE__ */ a("defs", { children: /* @__PURE__ */ a("clipPath", { id: "clip0_3703_1664", children: /* @__PURE__ */ a("rect", { width: "32", height: "32", rx: "16", fill: "white" }) }) })
|
|
33
33
|
]
|
|
34
34
|
}
|
|
35
|
-
),
|
|
35
|
+
), W = Z(
|
|
36
36
|
({
|
|
37
|
-
ProductRequest:
|
|
38
|
-
PaymentRequest:
|
|
39
|
-
metadata:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
ProductRequest: s,
|
|
38
|
+
PaymentRequest: v,
|
|
39
|
+
metadata: c,
|
|
40
|
+
subAmount: x,
|
|
41
|
+
totalAmount: d,
|
|
42
|
+
currency: l,
|
|
43
|
+
redirectUrl: n,
|
|
44
|
+
checkForErrors: p,
|
|
45
|
+
feesResponse: C,
|
|
46
|
+
ip: I
|
|
44
47
|
}) => {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
reference: i
|
|
48
|
+
const o = V(), { mutate: h, isLoading: _ } = z(s), { mutate: u, isLoading: A } = H(v), [b, m] = D(!1), f = _ || A || b, y = L(async () => {
|
|
49
|
+
const P = M(), g = {
|
|
50
|
+
...c,
|
|
51
|
+
reference: P
|
|
50
52
|
};
|
|
51
53
|
try {
|
|
52
|
-
await
|
|
53
|
-
|
|
54
|
+
const t = await h(
|
|
55
|
+
N({
|
|
54
56
|
metadata: g,
|
|
55
|
-
amount:
|
|
56
|
-
|
|
57
|
+
amount: x,
|
|
58
|
+
totalAmount: d,
|
|
59
|
+
currency: l
|
|
57
60
|
}),
|
|
58
61
|
{
|
|
59
|
-
onSuccess: (e) =>
|
|
60
|
-
},
|
|
62
|
+
onSuccess: (e) => e,
|
|
61
63
|
onError: (e) => {
|
|
62
|
-
|
|
63
|
-
throw ((n = e == null ? void 0 : e.raw) == null ? void 0 : n.message) ?? e;
|
|
64
|
+
throw e == null ? void 0 : e.message;
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
let r = null;
|
|
69
|
+
if (C && (r = B({
|
|
70
|
+
initResponse: t,
|
|
71
|
+
feesResponse: C,
|
|
72
|
+
metadata: g,
|
|
73
|
+
currency: l,
|
|
74
|
+
ip: I,
|
|
75
|
+
paymentMethod: R.CASHAPP
|
|
76
|
+
})), !r) {
|
|
77
|
+
w.error({
|
|
78
|
+
title: "",
|
|
79
|
+
description: "Payment initialization data is missing. Please try again."
|
|
80
|
+
});
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const { client_secret: S } = await u(
|
|
84
|
+
r,
|
|
74
85
|
{
|
|
75
|
-
onSuccess: (
|
|
86
|
+
onSuccess: () => {
|
|
76
87
|
},
|
|
77
88
|
onError: (e) => {
|
|
78
|
-
|
|
79
|
-
throw ((n = e == null ? void 0 : e.raw) == null ? void 0 : n.message) ?? e;
|
|
89
|
+
throw e;
|
|
80
90
|
}
|
|
81
91
|
}
|
|
82
92
|
);
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
const { error: e } = await
|
|
86
|
-
|
|
93
|
+
if (o) {
|
|
94
|
+
m(!0);
|
|
95
|
+
const { error: e } = await o.confirmPayment({
|
|
96
|
+
// @ts-ignore
|
|
97
|
+
clientSecret: S,
|
|
87
98
|
confirmParams: {
|
|
88
99
|
payment_method_data: {
|
|
89
100
|
// @ts-ignore
|
|
90
101
|
type: "cashapp"
|
|
91
102
|
},
|
|
92
|
-
return_url:
|
|
103
|
+
return_url: n.includes("?") ? `${n}&reference=${t.reference}` : `${n}?reference=${t.reference}`
|
|
93
104
|
}
|
|
94
105
|
});
|
|
95
106
|
if (e)
|
|
@@ -98,41 +109,41 @@ const R = (m) => /* @__PURE__ */ l(
|
|
|
98
109
|
);
|
|
99
110
|
}
|
|
100
111
|
} catch (t) {
|
|
101
|
-
|
|
112
|
+
m(!1), console.error(t), w.error({
|
|
102
113
|
title: "",
|
|
103
|
-
description: (
|
|
114
|
+
description: (t == null ? void 0 : t.message) ?? t ?? "We couldn't complete your payment"
|
|
104
115
|
});
|
|
105
116
|
}
|
|
106
117
|
}, [
|
|
107
|
-
p,
|
|
108
|
-
f,
|
|
109
|
-
r,
|
|
110
118
|
o,
|
|
119
|
+
h,
|
|
120
|
+
u,
|
|
121
|
+
d,
|
|
122
|
+
l,
|
|
111
123
|
c,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}, [h, y]);
|
|
124
|
+
n,
|
|
125
|
+
m
|
|
126
|
+
]), E = L(async () => {
|
|
127
|
+
await p() || y();
|
|
128
|
+
}, [p, y]);
|
|
118
129
|
return /* @__PURE__ */ a(
|
|
119
|
-
|
|
130
|
+
$,
|
|
120
131
|
{
|
|
121
|
-
onClick:
|
|
122
|
-
disabled:
|
|
123
|
-
isLoading:
|
|
124
|
-
children: /* @__PURE__ */
|
|
125
|
-
/* @__PURE__ */
|
|
126
|
-
/* @__PURE__ */ a(
|
|
127
|
-
/* @__PURE__ */ a(
|
|
132
|
+
onClick: E,
|
|
133
|
+
disabled: f,
|
|
134
|
+
isLoading: f,
|
|
135
|
+
children: /* @__PURE__ */ i("div", { className: "mpl:flex mpl:justify-between mpl:w-full mpl:items-center", children: [
|
|
136
|
+
/* @__PURE__ */ i("div", { className: "mpl:flex mpl:items-center mpl:gap-12", children: [
|
|
137
|
+
/* @__PURE__ */ a(T, { className: "mpl:size-32" }),
|
|
138
|
+
/* @__PURE__ */ a(j, { size: "extrasmall", weight: "medium", children: "Cash App Pay" })
|
|
128
139
|
] }),
|
|
129
|
-
/* @__PURE__ */ a(
|
|
140
|
+
/* @__PURE__ */ a(k, { className: "mpl:size-20" })
|
|
130
141
|
] })
|
|
131
142
|
}
|
|
132
143
|
);
|
|
133
144
|
}
|
|
134
145
|
);
|
|
135
|
-
|
|
146
|
+
W.displayName = "CashAppPayment";
|
|
136
147
|
export {
|
|
137
|
-
|
|
148
|
+
W as default
|
|
138
149
|
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { jsxs as r, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { u as S, a as z, C as M, v as N, b as $, c as j, E as B } from "./index-Di1ugn5_.js";
|
|
3
|
+
import { BodyText as R, ChevronRightIcon as T, toast as h } from "mainstack-design-system";
|
|
4
|
+
import { u as Z } from "./payments-B3Hm80pK.js";
|
|
5
|
+
import { useState as k } from "react";
|
|
6
|
+
const O = (a) => /* @__PURE__ */ r(
|
|
7
|
+
"svg",
|
|
8
|
+
{
|
|
9
|
+
viewBox: "0 0 32 32",
|
|
10
|
+
fill: "none",
|
|
11
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
12
|
+
...a,
|
|
13
|
+
children: [
|
|
14
|
+
/* @__PURE__ */ t("g", { clipPath: "url(#clip0_2605_970)", children: /* @__PURE__ */ t(
|
|
15
|
+
"path",
|
|
16
|
+
{
|
|
17
|
+
d: "M16 32C7.163 32 0 24.837 0 16C0 7.163 7.163 0 16 0C24.837 0 32 7.163 32 16C32 24.837 24.837 32 16 32ZM21.002 9.855L21.812 6.614L19.216 5.968L18.573 8.543C18.1498 8.40049 17.7157 8.29247 17.275 8.22L17.919 5.645L15.323 5L14.513 8.241C11.53 8.783 9.004 10.978 8.233 14.064C7.462 17.15 8.659 20.27 11.037 22.144L10.227 25.386L12.823 26.032L13.466 23.457C13.8892 23.5995 14.3233 23.7075 14.764 23.78L14.12 26.355L16.716 27L17.526 23.759C18.575 23.5709 19.5756 23.1744 20.4687 22.593C21.3619 22.0116 22.1294 21.2571 22.726 20.374L19.879 19.666C19.2215 20.3303 18.4022 20.8116 17.5018 21.0624C16.6014 21.3132 15.6512 21.3248 14.745 21.096C11.879 20.384 10.125 17.524 10.828 14.709C11.531 11.894 14.427 10.19 17.294 10.903C18.2012 11.1247 19.0347 11.5798 19.7118 12.223C20.3889 12.8663 20.8861 13.6753 21.154 14.57L24 15.278C23.8889 14.2194 23.5663 13.1938 23.0513 12.2623C22.5363 11.3307 21.8394 10.5121 21.002 9.855Z",
|
|
18
|
+
fill: "#131316"
|
|
19
|
+
}
|
|
20
|
+
) }),
|
|
21
|
+
/* @__PURE__ */ t("defs", { children: /* @__PURE__ */ t("clipPath", { id: "clip0_2605_970", children: /* @__PURE__ */ t("rect", { width: "32", height: "32", fill: "white" }) }) })
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
), F = ({
|
|
25
|
+
ProductRequest: a,
|
|
26
|
+
PaymentRequest: u,
|
|
27
|
+
metadata: C,
|
|
28
|
+
subAmount: f,
|
|
29
|
+
totalAmount: g,
|
|
30
|
+
currency: o,
|
|
31
|
+
redirectUrl: i,
|
|
32
|
+
checkForErrors: P,
|
|
33
|
+
feesResponse: l,
|
|
34
|
+
ip: L
|
|
35
|
+
}) => {
|
|
36
|
+
const c = Z(), { mutate: w, isLoading: x } = S(a), { mutate: I, isLoading: v } = z(u), [_, m] = k(!1), d = x || v || _, E = async () => {
|
|
37
|
+
const p = N(), y = {
|
|
38
|
+
...C,
|
|
39
|
+
reference: p
|
|
40
|
+
};
|
|
41
|
+
try {
|
|
42
|
+
const e = await w(
|
|
43
|
+
$({
|
|
44
|
+
metadata: y,
|
|
45
|
+
amount: f,
|
|
46
|
+
totalAmount: g,
|
|
47
|
+
currency: o
|
|
48
|
+
}),
|
|
49
|
+
{
|
|
50
|
+
onSuccess: (n) => n,
|
|
51
|
+
onError: (n) => {
|
|
52
|
+
throw n;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
let s = null;
|
|
57
|
+
if (l && (s = j({
|
|
58
|
+
initResponse: e,
|
|
59
|
+
feesResponse: l,
|
|
60
|
+
metadata: y,
|
|
61
|
+
currency: o,
|
|
62
|
+
ip: L,
|
|
63
|
+
paymentMethod: B.CRYPTO
|
|
64
|
+
})), !s) {
|
|
65
|
+
h.error({
|
|
66
|
+
title: "",
|
|
67
|
+
description: "Payment initialization data is missing. Please try again."
|
|
68
|
+
});
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const { client_secret: b } = await I(
|
|
72
|
+
s,
|
|
73
|
+
{
|
|
74
|
+
onSuccess: () => {
|
|
75
|
+
},
|
|
76
|
+
onError: (n) => {
|
|
77
|
+
throw n;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
if (c) {
|
|
82
|
+
m(!0);
|
|
83
|
+
const { error: n } = await c.confirmPayment({
|
|
84
|
+
// @ts-ignore
|
|
85
|
+
clientSecret: b,
|
|
86
|
+
confirmParams: {
|
|
87
|
+
payment_method_data: {
|
|
88
|
+
// @ts-ignore
|
|
89
|
+
type: "crypto"
|
|
90
|
+
},
|
|
91
|
+
return_url: i.includes("?") ? `${i}&reference=${e.reference}` : `${i}?reference=${e.reference}`
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
if (n)
|
|
95
|
+
throw new Error(n.message ?? "Couldn't load wallet integration");
|
|
96
|
+
}
|
|
97
|
+
} catch (e) {
|
|
98
|
+
m(!1), console.error(e), h.error({
|
|
99
|
+
title: "",
|
|
100
|
+
description: (e == null ? void 0 : e.message) ?? e ?? "We couldn't complete your payment"
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
return /* @__PURE__ */ t(
|
|
105
|
+
M,
|
|
106
|
+
{
|
|
107
|
+
onClick: async () => {
|
|
108
|
+
await P() || E();
|
|
109
|
+
},
|
|
110
|
+
disabled: d,
|
|
111
|
+
isLoading: d,
|
|
112
|
+
children: /* @__PURE__ */ r("div", { className: "mpl:flex mpl:justify-between mpl:w-full mpl:items-center", children: [
|
|
113
|
+
/* @__PURE__ */ r("div", { className: "mpl:flex mpl:items-center mpl:gap-12", children: [
|
|
114
|
+
/* @__PURE__ */ t(O, { className: "mpl:size-32" }),
|
|
115
|
+
/* @__PURE__ */ t(R, { size: "extrasmall", weight: "medium", children: "Stablecoins & Crypto" })
|
|
116
|
+
] }),
|
|
117
|
+
/* @__PURE__ */ t(T, { className: "mpl:size-20" }),
|
|
118
|
+
" "
|
|
119
|
+
] })
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
};
|
|
123
|
+
export {
|
|
124
|
+
F as default
|
|
125
|
+
};
|