mainstack-payments 0.5.7 → 0.5.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.
@@ -25698,66 +25698,77 @@ const az = "Payment Completed", oz = ({
25698
25698
  return ce(""), pe(() => {
25699
25699
  if (c && n > 0) {
25700
25700
  t.email = r.values.email, t.name = r.values.fullname;
25701
- const y = c == null ? void 0 : c.paymentRequest({
25702
- country: s,
25703
- currency: e == null ? void 0 : e.toLowerCase(),
25704
- total: {
25705
- label: t == null ? void 0 : t.productName,
25706
- amount: n
25707
- },
25708
- requestPayerName: !0,
25709
- requestPayerEmail: !0
25710
- });
25711
- y.canMakePayment().then((x) => {
25712
- x && (u(y), h(x));
25713
- }), y.on("paymentmethod", async (x) => {
25714
- const b = Ku();
25715
- try {
25716
- await i.post("payments/init", {
25717
- amount: n,
25718
- currency: e,
25719
- metadata: {
25720
- ...t,
25721
- reference: b
25722
- },
25723
- reference: b
25724
- });
25725
- } catch (F) {
25726
- x.complete("fail"), Pt(
25727
- (F == null ? void 0 : F.message) ?? "We couldn't initialize your payment",
25728
- kt.error
25729
- );
25730
- return;
25731
- }
25732
- const { client_secret: w } = await i.post(
25733
- "/payments/wallets/intent",
25734
- {
25735
- amount: n,
25736
- currency: e,
25737
- metadata: {
25738
- ...t,
25701
+ try {
25702
+ const y = c == null ? void 0 : c.paymentRequest({
25703
+ country: s,
25704
+ currency: e == null ? void 0 : e.toLowerCase(),
25705
+ total: {
25706
+ label: t == null ? void 0 : t.productName,
25707
+ amount: n
25708
+ },
25709
+ requestPayerName: !0,
25710
+ requestPayerEmail: !0
25711
+ });
25712
+ y.canMakePayment().then((x) => {
25713
+ x && (u(y), h(x));
25714
+ }), y.on("paymentmethod", async (x) => {
25715
+ const b = Ku();
25716
+ try {
25717
+ await i.post("payments/init", {
25718
+ amount: n,
25719
+ currency: e,
25720
+ metadata: {
25721
+ ...t,
25722
+ reference: b
25723
+ },
25739
25724
  reference: b
25740
- }
25725
+ });
25726
+ } catch (F) {
25727
+ x.complete("fail"), Pt(
25728
+ (F == null ? void 0 : F.message) ?? "We couldn't initialize your payment",
25729
+ kt.error
25730
+ );
25731
+ return;
25741
25732
  }
25742
- ).then((F) => F.data), { paymentIntent: k, error: E } = await c.confirmCardPayment(
25743
- w,
25744
- {
25745
- payment_method: x.paymentMethod.id
25746
- },
25747
- { handleActions: !1 }
25748
- );
25749
- if (E)
25750
- x.complete("fail"), Pt(
25751
- (E == null ? void 0 : E.message) ?? "We couldn't process your payment",
25752
- kt.error
25733
+ const { client_secret: w } = await i.post(
25734
+ "/payments/wallets/intent",
25735
+ {
25736
+ amount: n,
25737
+ currency: e,
25738
+ metadata: {
25739
+ ...t,
25740
+ reference: b
25741
+ }
25742
+ }
25743
+ ).then((F) => F.data), { paymentIntent: k, error: E } = await c.confirmCardPayment(
25744
+ w,
25745
+ {
25746
+ payment_method: x.paymentMethod.id
25747
+ },
25748
+ { handleActions: !1 }
25753
25749
  );
25754
- else {
25755
- if (x.complete("success"), k.status === "requires_action") {
25756
- const { error: F } = await c.confirmCardPayment(w);
25757
- F ? Pt(
25758
- "Payment failed, please add a new payment method",
25750
+ if (E)
25751
+ x.complete("fail"), Pt(
25752
+ (E == null ? void 0 : E.message) ?? "We couldn't process your payment",
25759
25753
  kt.error
25760
- ) : (m(!0), setTimeout(() => {
25754
+ );
25755
+ else {
25756
+ if (x.complete("success"), k.status === "requires_action") {
25757
+ const { error: F } = await c.confirmCardPayment(w);
25758
+ F ? Pt(
25759
+ "Payment failed, please add a new payment method",
25760
+ kt.error
25761
+ ) : (m(!0), setTimeout(() => {
25762
+ o({
25763
+ fullname: r.values.fullname,
25764
+ email: r.values.email,
25765
+ reference: b,
25766
+ amount: n,
25767
+ currency: e
25768
+ });
25769
+ }, 3e3));
25770
+ }
25771
+ Pt("Payment was successful", kt.success), m(!0), setTimeout(() => {
25761
25772
  o({
25762
25773
  fullname: r.values.fullname,
25763
25774
  email: r.values.email,
@@ -25765,19 +25776,12 @@ const az = "Payment Completed", oz = ({
25765
25776
  amount: n,
25766
25777
  currency: e
25767
25778
  });
25768
- }, 3e3));
25779
+ }, 3e3);
25769
25780
  }
25770
- Pt("Payment was successful", kt.success), m(!0), setTimeout(() => {
25771
- o({
25772
- fullname: r.values.fullname,
25773
- email: r.values.email,
25774
- reference: b,
25775
- amount: n,
25776
- currency: e
25777
- });
25778
- }, 3e3);
25779
- }
25780
- });
25781
+ });
25782
+ } catch (y) {
25783
+ console.log(y == null ? void 0 : y.message);
25784
+ }
25781
25785
  }
25782
25786
  }, [c, l, r.values.email, r.values.fullname, n]), /* @__PURE__ */ S(pn, { children: d && f !== null && /* @__PURE__ */ K(Ze, { width: "100%", gap: "16px", children: [
25783
25787
  (f == null ? void 0 : f.applePay) && /* @__PURE__ */ S(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mainstack-payments",
3
3
  "type": "module",
4
- "version": "0.5.7",
4
+ "version": "0.5.8",
5
5
  "main": "build/mainstack-payments.js",
6
6
  "types": "build/src/index.d.ts",
7
7
  "files": [