mainstack-payments 2.0.7 → 2.0.9

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.
@@ -1,18 +1,18 @@
1
- import { jsxs as s, jsx as t } 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-DvHbcsZ0.js";
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-DSWwVekW.js";
3
3
  import { toast as w, BodyText as j, ChevronRightIcon as k } from "mainstack-design-system";
4
- import { u as V } from "./payments-CjiNVkeO.js";
4
+ import { u as V } from "./payments-B3Hm80pK.js";
5
5
  import { memo as Z, useState as D, useCallback as L } from "react";
6
- const T = (l) => /* @__PURE__ */ s(
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
- ...l,
12
+ ...s,
13
13
  children: [
14
- /* @__PURE__ */ s("g", { clipPath: "url(#clip0_3703_1664)", children: [
15
- /* @__PURE__ */ t(
14
+ /* @__PURE__ */ i("g", { clipPath: "url(#clip0_3703_1664)", children: [
15
+ /* @__PURE__ */ a(
16
16
  "path",
17
17
  {
18
18
  fillRule: "evenodd",
@@ -21,7 +21,7 @@ const T = (l) => /* @__PURE__ */ s(
21
21
  fill: "#00D533"
22
22
  }
23
23
  ),
24
- /* @__PURE__ */ t(
24
+ /* @__PURE__ */ a(
25
25
  "path",
26
26
  {
27
27
  d: "M17.3184 14.4455C20.6877 15.1617 22.2274 16.5636 22.2274 18.9255C22.2274 21.8817 19.8186 24.0607 16.0531 24.3045L15.6872 26.0569C15.6567 26.2245 15.5042 26.3464 15.3213 26.3464H12.4247C12.1808 26.3464 12.0132 26.1179 12.0589 25.8893L12.5162 23.9388C10.6562 23.4055 9.14687 22.3693 8.27799 21.1045C8.17133 20.9369 8.2018 20.7236 8.35418 20.6017L10.3665 19.0322C10.5343 18.895 10.7781 18.9407 10.9002 19.1084C11.9673 20.6017 13.6138 21.4855 15.5958 21.4855C17.3796 21.4855 18.7211 20.6169 18.7211 19.3674C18.7211 18.4074 18.0503 17.9655 15.7788 17.4931C11.9065 16.655 10.3667 15.2226 10.3667 12.8607C10.3667 10.1179 12.6687 8.06074 16.1447 7.78645L16.5258 5.97312C16.5562 5.8055 16.7088 5.68359 16.8916 5.68359H19.7425C19.9713 5.68359 20.1541 5.89693 20.1084 6.1255L19.6663 8.15217C21.1604 8.60931 22.3799 9.43216 23.1423 10.4531C23.2642 10.6055 23.2337 10.8341 23.0813 10.956L21.2366 12.4645C21.0689 12.6017 20.8403 12.5712 20.7182 12.4036C19.773 11.2455 18.3094 10.5903 16.7086 10.5903C14.9248 10.5903 13.812 11.3674 13.812 12.4645C13.7815 13.3788 14.6506 13.8665 17.3184 14.4455Z",
@@ -29,34 +29,34 @@ const T = (l) => /* @__PURE__ */ s(
29
29
  }
30
30
  )
31
31
  ] }),
32
- /* @__PURE__ */ t("defs", { children: /* @__PURE__ */ t("clipPath", { id: "clip0_3703_1664", children: /* @__PURE__ */ t("rect", { width: "32", height: "32", rx: "16", fill: "white" }) }) })
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: l,
37
+ ProductRequest: s,
38
38
  PaymentRequest: v,
39
- metadata: d,
39
+ metadata: c,
40
40
  subAmount: x,
41
- totalAmount: p,
42
- currency: o,
41
+ totalAmount: d,
42
+ currency: l,
43
43
  redirectUrl: n,
44
- checkForErrors: C,
45
- feesResponse: h,
44
+ checkForErrors: p,
45
+ feesResponse: C,
46
46
  ip: I
47
47
  }) => {
48
- const m = V(), { mutate: u, isLoading: _ } = z(l), { mutate: y, isLoading: A } = H(v), [b, r] = D(!1), f = _ || A || b, P = L(async () => {
49
- const i = M(), g = {
50
- ...d,
51
- 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
52
52
  };
53
53
  try {
54
- const a = await u(
54
+ const t = await h(
55
55
  N({
56
56
  metadata: g,
57
57
  amount: x,
58
- totalAmount: p,
59
- currency: o
58
+ totalAmount: d,
59
+ currency: l
60
60
  }),
61
61
  {
62
62
  onSuccess: (e) => e,
@@ -65,23 +65,23 @@ const T = (l) => /* @__PURE__ */ s(
65
65
  }
66
66
  }
67
67
  );
68
- let c = null;
69
- if (h && (c = B({
70
- initResponse: a,
71
- feesResponse: h,
68
+ let r = null;
69
+ if (C && (r = B({
70
+ initResponse: t,
71
+ feesResponse: C,
72
72
  metadata: g,
73
- currency: o,
73
+ currency: l,
74
74
  ip: I,
75
75
  paymentMethod: R.CASHAPP
76
- })), !c) {
76
+ })), !r) {
77
77
  w.error({
78
78
  title: "",
79
79
  description: "Payment initialization data is missing. Please try again."
80
80
  });
81
81
  return;
82
82
  }
83
- const { client_secret: S } = await y(
84
- c,
83
+ const { client_secret: S } = await u(
84
+ r,
85
85
  {
86
86
  onSuccess: () => {
87
87
  },
@@ -90,9 +90,9 @@ const T = (l) => /* @__PURE__ */ s(
90
90
  }
91
91
  }
92
92
  );
93
- if (m) {
94
- r(!0);
95
- const { error: e } = await m.confirmPayment({
93
+ if (o) {
94
+ m(!0);
95
+ const { error: e } = await o.confirmPayment({
96
96
  // @ts-ignore
97
97
  clientSecret: S,
98
98
  confirmParams: {
@@ -100,7 +100,7 @@ const T = (l) => /* @__PURE__ */ s(
100
100
  // @ts-ignore
101
101
  type: "cashapp"
102
102
  },
103
- return_url: n.includes("?") ? `${n}&reference=${i}` : `${n}?reference=${i}`
103
+ return_url: n.includes("?") ? `${n}&reference=${t.reference}` : `${n}?reference=${t.reference}`
104
104
  }
105
105
  });
106
106
  if (e)
@@ -108,36 +108,36 @@ const T = (l) => /* @__PURE__ */ s(
108
108
  e.message ?? "Couldn't load Cash App integration"
109
109
  );
110
110
  }
111
- } catch (a) {
112
- r(!1), console.error(a), w.error({
111
+ } catch (t) {
112
+ m(!1), console.error(t), w.error({
113
113
  title: "",
114
- description: (a == null ? void 0 : a.message) ?? a ?? "We couldn't complete your payment"
114
+ description: (t == null ? void 0 : t.message) ?? t ?? "We couldn't complete your payment"
115
115
  });
116
116
  }
117
117
  }, [
118
- m,
119
- u,
120
- y,
121
- p,
122
118
  o,
119
+ h,
120
+ u,
123
121
  d,
122
+ l,
123
+ c,
124
124
  n,
125
- r
125
+ m
126
126
  ]), E = L(async () => {
127
- await C() || P();
128
- }, [C, P]);
129
- return /* @__PURE__ */ t(
127
+ await p() || y();
128
+ }, [p, y]);
129
+ return /* @__PURE__ */ a(
130
130
  $,
131
131
  {
132
132
  onClick: E,
133
133
  disabled: f,
134
134
  isLoading: f,
135
- children: /* @__PURE__ */ s("div", { className: "mpl:flex mpl:justify-between mpl:w-full mpl:items-center", children: [
136
- /* @__PURE__ */ s("div", { className: "mpl:flex mpl:items-center mpl:gap-12", children: [
137
- /* @__PURE__ */ t(T, { className: "mpl:size-32" }),
138
- /* @__PURE__ */ t(j, { size: "extrasmall", weight: "medium", children: "Cash App Pay" })
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" })
139
139
  ] }),
140
- /* @__PURE__ */ t(k, { className: "mpl:size-20" })
140
+ /* @__PURE__ */ a(k, { className: "mpl:size-20" })
141
141
  ] })
142
142
  }
143
143
  );
@@ -1,15 +1,15 @@
1
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-DvHbcsZ0.js";
2
+ import { u as S, a as z, C as M, v as N, b as $, c as j, E as B } from "./index-DSWwVekW.js";
3
3
  import { BodyText as R, ChevronRightIcon as T, toast as h } from "mainstack-design-system";
4
- import { u as Z } from "./payments-CjiNVkeO.js";
4
+ import { u as Z } from "./payments-B3Hm80pK.js";
5
5
  import { useState as k } from "react";
6
- const O = (i) => /* @__PURE__ */ r(
6
+ const O = (a) => /* @__PURE__ */ r(
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
- ...i,
12
+ ...a,
13
13
  children: [
14
14
  /* @__PURE__ */ t("g", { clipPath: "url(#clip0_2605_970)", children: /* @__PURE__ */ t(
15
15
  "path",
@@ -22,46 +22,46 @@ const O = (i) => /* @__PURE__ */ r(
22
22
  ]
23
23
  }
24
24
  ), F = ({
25
- ProductRequest: i,
25
+ ProductRequest: a,
26
26
  PaymentRequest: u,
27
27
  metadata: C,
28
28
  subAmount: f,
29
29
  totalAmount: g,
30
- currency: l,
31
- redirectUrl: s,
30
+ currency: o,
31
+ redirectUrl: i,
32
32
  checkForErrors: P,
33
- feesResponse: m,
33
+ feesResponse: l,
34
34
  ip: L
35
35
  }) => {
36
- const c = Z(), { mutate: w, isLoading: x } = S(i), { mutate: I, isLoading: v } = z(u), [_, d] = k(!1), p = x || v || _, E = async () => {
37
- const a = N(), y = {
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
38
  ...C,
39
- reference: a
39
+ reference: p
40
40
  };
41
41
  try {
42
- const n = await w(
42
+ const e = await w(
43
43
  $({
44
44
  metadata: y,
45
45
  amount: f,
46
46
  totalAmount: g,
47
- currency: l
47
+ currency: o
48
48
  }),
49
49
  {
50
- onSuccess: (e) => e,
51
- onError: (e) => {
52
- throw e;
50
+ onSuccess: (n) => n,
51
+ onError: (n) => {
52
+ throw n;
53
53
  }
54
54
  }
55
55
  );
56
- let o = null;
57
- if (m && (o = j({
58
- initResponse: n,
59
- feesResponse: m,
56
+ let s = null;
57
+ if (l && (s = j({
58
+ initResponse: e,
59
+ feesResponse: l,
60
60
  metadata: y,
61
- currency: l,
61
+ currency: o,
62
62
  ip: L,
63
63
  paymentMethod: B.CRYPTO
64
- })), !o) {
64
+ })), !s) {
65
65
  h.error({
66
66
  title: "",
67
67
  description: "Payment initialization data is missing. Please try again."
@@ -69,18 +69,18 @@ const O = (i) => /* @__PURE__ */ r(
69
69
  return;
70
70
  }
71
71
  const { client_secret: b } = await I(
72
- o,
72
+ s,
73
73
  {
74
74
  onSuccess: () => {
75
75
  },
76
- onError: (e) => {
77
- throw e;
76
+ onError: (n) => {
77
+ throw n;
78
78
  }
79
79
  }
80
80
  );
81
81
  if (c) {
82
- d(!0);
83
- const { error: e } = await c.confirmPayment({
82
+ m(!0);
83
+ const { error: n } = await c.confirmPayment({
84
84
  // @ts-ignore
85
85
  clientSecret: b,
86
86
  confirmParams: {
@@ -88,16 +88,16 @@ const O = (i) => /* @__PURE__ */ r(
88
88
  // @ts-ignore
89
89
  type: "crypto"
90
90
  },
91
- return_url: s.includes("?") ? `${s}&reference=${a}` : `${s}?reference=${a}`
91
+ return_url: i.includes("?") ? `${i}&reference=${e.reference}` : `${i}?reference=${e.reference}`
92
92
  }
93
93
  });
94
- if (e)
95
- throw new Error(e.message ?? "Couldn't load wallet integration");
94
+ if (n)
95
+ throw new Error(n.message ?? "Couldn't load wallet integration");
96
96
  }
97
- } catch (n) {
98
- d(!1), console.error(n), h.error({
97
+ } catch (e) {
98
+ m(!1), console.error(e), h.error({
99
99
  title: "",
100
- description: (n == null ? void 0 : n.message) ?? n ?? "We couldn't complete your payment"
100
+ description: (e == null ? void 0 : e.message) ?? e ?? "We couldn't complete your payment"
101
101
  });
102
102
  }
103
103
  };
@@ -107,8 +107,8 @@ const O = (i) => /* @__PURE__ */ r(
107
107
  onClick: async () => {
108
108
  await P() || E();
109
109
  },
110
- disabled: p,
111
- isLoading: p,
110
+ disabled: d,
111
+ isLoading: d,
112
112
  children: /* @__PURE__ */ r("div", { className: "mpl:flex mpl:justify-between mpl:w-full mpl:items-center", children: [
113
113
  /* @__PURE__ */ r("div", { className: "mpl:flex mpl:items-center mpl:gap-12", children: [
114
114
  /* @__PURE__ */ t(O, { className: "mpl:size-32" }),