mainstack-payments 2.0.5 → 2.0.7

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 (63) hide show
  1. package/build/{CashAppPayment-D4RId4l8.js → CashAppPayment-D4Ml8WuY.js} +81 -70
  2. package/build/CryptoPayments-6A3VCTqi.js +125 -0
  3. package/build/{index-BUQq9lgH.js → index-DvHbcsZ0.js} +2440 -2340
  4. package/build/index.css +1 -1
  5. package/build/mainstack-payments.js +1 -1
  6. package/build/{payments-B3Hm80pK.js → payments-CjiNVkeO.js} +143 -145
  7. package/build/{api → src/api}/config.d.ts +5 -2
  8. package/build/src/api/index.d.ts +133 -0
  9. package/build/{components → src/components}/CheckoutForm.d.ts +1 -1
  10. package/build/{components → src/components}/ContactAction.d.ts +1 -2
  11. package/build/src/components/PaymentOptions/CashAppPayment.d.ts +16 -0
  12. package/build/src/components/PaymentOptions/CryptoPayments.d.ts +16 -0
  13. package/build/{components → src/components}/SummaryCard.d.ts +2 -7
  14. package/build/{components → src/components}/WalletPay.d.ts +8 -3
  15. package/build/src/hooks/useApi.d.ts +31 -0
  16. package/build/src/pages/Receipt.d.ts +3 -0
  17. package/build/{routes → src/routes}/index.d.ts +1 -0
  18. package/build/{types → src/types}/index.d.ts +19 -2
  19. package/package.json +1 -1
  20. package/build/CryptoPayments-agwrxVl5.js +0 -114
  21. package/build/api/index.d.ts +0 -121
  22. package/build/components/PaymentOptions/CashAppPayment.d.ts +0 -13
  23. package/build/components/PaymentOptions/CryptoPayments.d.ts +0 -12
  24. package/build/hooks/useApi.d.ts +0 -25
  25. /package/build/{app.d.ts → src/app.d.ts} +0 -0
  26. /package/build/{components → src/components}/ConfirmEmailModal.d.ts +0 -0
  27. /package/build/{components → src/components}/ContactForm.d.ts +0 -0
  28. /package/build/{components → src/components}/Payment.d.ts +0 -0
  29. /package/build/{components → src/components}/PaymentActionModal.d.ts +0 -0
  30. /package/build/{components → src/components}/PaymentOptions/PaystackPayments.d.ts +0 -0
  31. /package/build/{components → src/components}/PaystackPaymentErrorModal.d.ts +0 -0
  32. /package/build/{components → src/components}/PrivacyPolicy.d.ts +0 -0
  33. /package/build/{components → src/components}/UI/CardButton.d.ts +0 -0
  34. /package/build/{components → src/components}/UI/Collapse.d.ts +0 -0
  35. /package/build/{components → src/components}/UI/PaymentsDivider.d.ts +0 -0
  36. /package/build/{components → src/components}/UI/icons/AfricanPayIcon.d.ts +0 -0
  37. /package/build/{components → src/components}/UI/icons/ApplePayIcon.d.ts +0 -0
  38. /package/build/{components → src/components}/UI/icons/CashAppIcon.d.ts +0 -0
  39. /package/build/{components → src/components}/UI/icons/CheckoutCardIcon.d.ts +0 -0
  40. /package/build/{components → src/components}/UI/icons/CryptoIcon.d.ts +0 -0
  41. /package/build/{components → src/components}/UI/icons/GooglePayIcon.d.ts +0 -0
  42. /package/build/{components → src/components}/UI/icons/MainstackLogo.d.ts +0 -0
  43. /package/build/{constants → src/constants}/index.d.ts +0 -0
  44. /package/build/{enums → src/enums}/currenciesEnums.d.ts +0 -0
  45. /package/build/{hooks → src/hooks}/useDebounce.d.ts +0 -0
  46. /package/build/{hooks → src/hooks}/usePayment.d.ts +0 -0
  47. /package/build/{hooks → src/hooks}/usePaystackPayment.d.ts +0 -0
  48. /package/build/{hooks → src/hooks}/useSmoothScroll.d.ts +0 -0
  49. /package/build/{index.d.ts → src/index.d.ts} +0 -0
  50. /package/build/{pages → src/pages}/DiscountCode.d.ts +0 -0
  51. /package/build/{pages → src/pages}/Home.d.ts +0 -0
  52. /package/build/{pages → src/pages}/Login.d.ts +0 -0
  53. /package/build/{pages → src/pages}/Page404.d.ts +0 -0
  54. /package/build/{pages → src/pages}/PaymentRedirect.d.ts +0 -0
  55. /package/build/{pages → src/pages}/index.d.ts +0 -0
  56. /package/build/{provider → src/provider}/index.d.ts +0 -0
  57. /package/build/{utils → src/utils}/ValidatePostcode.d.ts +0 -0
  58. /package/build/{utils → src/utils}/countries_flag.json.d.ts +0 -0
  59. /package/build/{utils → src/utils}/countries_with_flags_and_currencies.json.d.ts +0 -0
  60. /package/build/{utils → src/utils}/formatUnderscoreText.d.ts +0 -0
  61. /package/build/{utils → src/utils}/index.d.ts +0 -0
  62. /package/build/{utils → src/utils}/stringifyPrice.d.ts +0 -0
  63. /package/build/{utils → src/utils}/validations.d.ts +0 -0
@@ -0,0 +1,133 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { IInitPayment, IInitPaymentResponse, ITransactionFeesResponse, TPaymentMethods } from 'types';
3
+
4
+ export interface IGetTransactionFeesPayload {
5
+ merchantId: string;
6
+ currencyCode: string;
7
+ amount: number;
8
+ types: string[];
9
+ address?: {
10
+ country?: string;
11
+ postal_code?: string;
12
+ };
13
+ ip?: string;
14
+ appName?: string;
15
+ quantity?: number;
16
+ }
17
+ /**
18
+ * Fetches transaction fee breakdown for a given amount + currency.
19
+ * Returns `ITransactionFeesResponse` directly (envelope unwrapped).
20
+ */
21
+ export declare const useGetTransactionFees: (payload: IGetTransactionFeesPayload, FeeRequest: AxiosInstance) => import('hooks/useApi').IQueryResult<ITransactionFeesResponse>;
22
+ /**
23
+ * Creates an order and returns `IInitPaymentResponse` directly (envelope unwrapped).
24
+ */
25
+ export declare const useInitPayment: (ProductRequest: AxiosInstance) => import('hooks/useApi').IMutationResult<IInitPayment, IInitPaymentResponse>;
26
+ export declare const buildInitPaymentPayload: ({ metadata, amount, currency, countryISO, totalAmount, }: {
27
+ metadata: Record<string, any>;
28
+ amount: number;
29
+ currency: string;
30
+ countryISO?: string | undefined;
31
+ totalAmount?: number | undefined;
32
+ }) => IInitPayment;
33
+ export interface IChargePaymentAmount {
34
+ currency: string;
35
+ value: number;
36
+ }
37
+ export interface IChargePaymentCustomer {
38
+ email?: string;
39
+ phone?: string;
40
+ name?: string;
41
+ }
42
+ export interface IChargePayment {
43
+ orderId?: string;
44
+ reference?: string;
45
+ iPAddress?: string;
46
+ paymentMethod?: string;
47
+ paymentToken?: string;
48
+ customerPaymentMethodId?: string;
49
+ callbackUrl?: string;
50
+ amount: IChargePaymentAmount;
51
+ feeAmount?: IChargePaymentAmount;
52
+ feeIds?: string[];
53
+ merchantId: string;
54
+ customer?: IChargePaymentCustomer;
55
+ metadata?: Record<string, unknown>;
56
+ source?: string;
57
+ payment_method_id?: string;
58
+ }
59
+ export interface IChargePaymentResponse {
60
+ reference: string;
61
+ status: string;
62
+ [key: string]: unknown;
63
+ next_action?: {
64
+ redirect_to_url: {
65
+ url: string;
66
+ };
67
+ };
68
+ }
69
+ export declare const buildChargePaymentPayload: ({ initResponse, metadata, callbackUrl, paymentToken, paymentMethodId, ip, paymentMethod, }: {
70
+ initResponse: IInitPaymentResponse;
71
+ feesResponse: ITransactionFeesResponse;
72
+ metadata: Record<string, any>;
73
+ currency: string;
74
+ callbackUrl?: string | undefined;
75
+ paymentToken?: string | undefined;
76
+ paymentMethodId?: string | undefined;
77
+ ip?: string | undefined;
78
+ paymentMethod?: "crypto" | "cashapp" | "card" | "transfer" | "mobile_money" | "google_pay" | "apple_pay" | "bank_transfer" | "ussd" | "payattitude" | "qr" | "wechat_pay" | undefined;
79
+ }) => IChargePayment;
80
+ /**
81
+ * Submits a payment charge. Returns `IChargePaymentResponse` directly (envelope unwrapped).
82
+ */
83
+ export declare const useChargePayment: (PaymentRequest: AxiosInstance) => import('hooks/useApi').IMutationResult<IChargePayment, IChargePaymentResponse>;
84
+ export interface IIntentPaymentResponse {
85
+ client_secret?: string;
86
+ [key: string]: unknown;
87
+ }
88
+ /**
89
+ * Creates a Stripe / wallet payment intent. Returns `IIntentPaymentResponse` directly.
90
+ */
91
+ export declare const useIntentPayment: (Request: AxiosInstance) => import('hooks/useApi').IMutationResult<IChargePayment, IIntentPaymentResponse>;
92
+ export interface IVerifyPaymentResponse {
93
+ reference: string;
94
+ status: string;
95
+ [key: string]: unknown;
96
+ }
97
+ /**
98
+ * Verifies a payment by reference. Returns `IVerifyPaymentResponse` directly.
99
+ * Call `refetch()` to trigger (enabled: false by default).
100
+ */
101
+ export declare const useVerifyPayment: (reference: string, Request: AxiosInstance) => import('hooks/useApi').IQueryResult<IVerifyPaymentResponse>;
102
+ interface IApplyDiscountPayload {
103
+ discount_code: string;
104
+ product_id: string;
105
+ account_id: string;
106
+ currency: string;
107
+ store_id: string;
108
+ cart_id?: string;
109
+ ticket_payload?: string;
110
+ payment_plan_id?: string;
111
+ }
112
+ export interface IApplyDiscountResponse {
113
+ discount_code: string;
114
+ amount: number;
115
+ type: string;
116
+ value: number;
117
+ isFullDiscount: boolean;
118
+ /** Discounted price the customer pays */
119
+ discounted_amount: number;
120
+ /** Discount type string (e.g. "percentage") */
121
+ discount_type: string;
122
+ /** Raw discount value */
123
+ discount_value: number;
124
+ /** Amount to pay after discount (0 = fully discounted) */
125
+ amount_to_pay: number;
126
+ [key: string]: unknown;
127
+ }
128
+ /**
129
+ * Validates a discount code. Returns `IApplyDiscountResponse` directly.
130
+ * Call `refetch()` to trigger (enabled: false by default).
131
+ */
132
+ export declare const useApplyDiscount: ({ discount_code, product_id, account_id, currency, store_id, ticket_payload, cart_id, payment_plan_id, }: IApplyDiscountPayload, Request: AxiosInstance) => import('hooks/useApi').IQueryResult<IApplyDiscountResponse>;
133
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { IChargePayment } from 'api';
2
2
  import { TCustomizations, TPaymentModel } from 'types';
3
3
 
4
- declare const CheckoutDetailsForm: ({ currency, amount, metadata, formik, isFree, showPayment, showCheckoutForm, onCancel, btn_color, onPaymentComplete, PaymentRequest, paymentModel, callbackUrl, buildChargePayload, setIframeUrl, isEuroCurrencies, paymentWidth, customizations, onGoBack, Styles, }: {
4
+ declare const CheckoutDetailsForm: ({ currency, amount, metadata, formik, isFree, showPayment, showCheckoutForm, onCancel, btn_color, onPaymentComplete, PaymentRequest, paymentModel, callbackUrl, buildChargePayload, setIframeUrl, isEuroCurrencies, customizations, onGoBack, Styles, }: {
5
5
  currency: string;
6
6
  amount: number;
7
7
  metadata?: any;
@@ -3,10 +3,9 @@ import { TCustomizations } from 'types';
3
3
  interface ContactActionProps {
4
4
  customizations?: TCustomizations;
5
5
  discount?: number;
6
- onGoBack?: () => void;
7
6
  handlePaymentProceed: (e: React.MouseEvent) => void;
8
7
  feesLoading: boolean;
9
8
  isSubmitting: boolean;
10
9
  }
11
- declare const ContactAction: ({ customizations, discount, onGoBack, handlePaymentProceed, feesLoading, isSubmitting, }: ContactActionProps) => import("react/jsx-runtime").JSX.Element;
10
+ declare const ContactAction: ({ customizations, discount, handlePaymentProceed, feesLoading, isSubmitting, }: ContactActionProps) => import("react/jsx-runtime").JSX.Element;
12
11
  export default ContactAction;
@@ -0,0 +1,16 @@
1
+ import { ITransactionFeesResponse } from 'types';
2
+
3
+ interface CashAppPaymentProps {
4
+ ProductRequest: any;
5
+ PaymentRequest: any;
6
+ metadata: any;
7
+ subAmount: number;
8
+ totalAmount: number;
9
+ currency: string;
10
+ redirectUrl: string;
11
+ checkForErrors: () => Promise<boolean>;
12
+ feesResponse?: ITransactionFeesResponse;
13
+ ip: string;
14
+ }
15
+ declare const CashAppPayment: import('react').MemoExoticComponent<({ ProductRequest, PaymentRequest, metadata, subAmount, totalAmount, currency, redirectUrl, checkForErrors, feesResponse, ip, }: CashAppPaymentProps) => import("react/jsx-runtime").JSX.Element>;
16
+ export default CashAppPayment;
@@ -0,0 +1,16 @@
1
+ import { ITransactionFeesResponse } from 'types';
2
+
3
+ interface CryptoPaymentsProps {
4
+ ProductRequest: any;
5
+ PaymentRequest: any;
6
+ metadata: any;
7
+ subAmount: number;
8
+ totalAmount: number;
9
+ currency: string;
10
+ redirectUrl: string;
11
+ checkForErrors: () => Promise<boolean>;
12
+ feesResponse?: ITransactionFeesResponse;
13
+ ip: string;
14
+ }
15
+ declare const CryptoPayments: ({ ProductRequest, PaymentRequest, metadata, subAmount, totalAmount, currency, redirectUrl, checkForErrors, feesResponse, ip, }: CryptoPaymentsProps) => import("react/jsx-runtime").JSX.Element;
16
+ export default CryptoPayments;
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { TItemList } from 'types';
2
+ import { IAppliedFee, TItemList } from 'types';
3
3
 
4
4
  type IProps = {
5
5
  summaryTitle: string | ReactNode;
@@ -19,12 +19,7 @@ type IProps = {
19
19
  };
20
20
  transactionFees: {
21
21
  totalAmountPlusFees: number;
22
- applied_fees: Array<{
23
- _id: number;
24
- display_name: string;
25
- amount: number;
26
- extra: number;
27
- }>;
22
+ applied_fees?: IAppliedFee[];
28
23
  transactionFeeValue: number;
29
24
  };
30
25
  isSingleColumn: boolean;
@@ -1,5 +1,5 @@
1
- /** @format */
2
- /// <reference types="react" />
1
+ import { ITransactionFeesResponse } from 'types';
2
+
3
3
  interface WalletPayProps {
4
4
  currency: string;
5
5
  amount: number;
@@ -7,12 +7,17 @@ interface WalletPayProps {
7
7
  formik: any;
8
8
  checkForErrors: () => Promise<boolean>;
9
9
  onPaymentComplete: (payload: object) => void;
10
+ ProductRequest: any;
10
11
  PaymentRequest: any;
11
12
  stripeCountry: string;
12
13
  onInitializePayment?: (e: object) => Promise<{
13
14
  terminate?: boolean;
14
15
  }>;
15
16
  onToggleWallet: () => void;
17
+ subAmount: number;
18
+ totalAmount: number;
19
+ feesResponse?: ITransactionFeesResponse;
20
+ ip: string;
16
21
  }
17
- declare const WalletPay: import('react').MemoExoticComponent<({ currency, metadata, amount, formik, checkForErrors, onPaymentComplete, PaymentRequest, stripeCountry, onInitializePayment, onToggleWallet, }: WalletPayProps) => import("react/jsx-runtime").JSX.Element>;
22
+ declare const WalletPay: import('react').MemoExoticComponent<({ currency, metadata, amount, formik, checkForErrors, onPaymentComplete, ProductRequest, PaymentRequest, stripeCountry, onInitializePayment, onToggleWallet, subAmount, totalAmount, feesResponse, ip, }: WalletPayProps) => import("react/jsx-runtime").JSX.Element>;
18
23
  export default WalletPay;
@@ -0,0 +1,31 @@
1
+ /** Shape returned by `refetch()` — mirrors the old callback contract. */
2
+ export interface IFetchResult<TData> {
3
+ data: TData | undefined;
4
+ isSuccess: boolean;
5
+ error: unknown;
6
+ }
7
+ export interface IQueryResult<TData> {
8
+ data: TData | undefined;
9
+ isLoading: boolean;
10
+ error: unknown;
11
+ /** Re-runs the query and returns a result object with `{ isSuccess, data, error }`. */
12
+ refetch: () => Promise<IFetchResult<TData>>;
13
+ }
14
+ export declare const useQuery: <TData = unknown>({ queryFn, enabled, dependingOn, }: {
15
+ /** Should return the already-unwrapped data value (not the full axios response). */
16
+ queryFn: () => Promise<TData>;
17
+ enabled?: boolean | undefined;
18
+ dependingOn?: unknown[] | undefined;
19
+ }) => IQueryResult<TData>;
20
+ export interface IMutationResult<TInput, TData> {
21
+ data: TData | undefined;
22
+ isLoading: boolean;
23
+ mutate: (params: TInput, callbacks: {
24
+ onSuccess: (data: TData) => void;
25
+ onError: (error: unknown) => void;
26
+ }) => Promise<TData>;
27
+ }
28
+ export declare const useMutation: <TInput, TData = unknown>({ mutationFn, }: {
29
+ /** Should return the already-unwrapped data value (not the full axios response). */
30
+ mutationFn: (data: TInput) => Promise<TData>;
31
+ }) => IMutationResult<TInput, TData>;
@@ -0,0 +1,3 @@
1
+ /** @format */
2
+ declare const Receipt: () => import("react/jsx-runtime").JSX.Element;
3
+ export default Receipt;
@@ -4,4 +4,5 @@ export declare const ROUTES: {
4
4
  LOGIN: string;
5
5
  NOT_FOUND: string;
6
6
  PAYMENT_REDIRECT: string;
7
+ RECEIPT: string;
7
8
  };
@@ -1,8 +1,25 @@
1
1
  /** @format */
2
+ export declare enum EStatusCode {
3
+ StatusCode200 = 200,
4
+ StatusCode201 = 201,
5
+ StatusCode304 = 304,
6
+ StatusCode400 = 400,
7
+ StatusCode401 = 401,
8
+ StatusCode403 = 403,
9
+ StatusCode404 = 404,
10
+ StatusCode409 = 409,
11
+ StatusCode500 = 500
12
+ }
13
+ /** Shape every backend endpoint returns. Callers receive `T` directly after unwrapping. */
14
+ export interface IApiResponse<T = unknown> {
15
+ statusCode: EStatusCode;
16
+ message: string;
17
+ data?: T;
18
+ }
2
19
  type TPaymentOption = "wallet" | "startbutton" | "stripe" | "paystack" | "crypto" | "cashapp";
3
20
  type TPaymentMode = "card" | "transfer" | "mobile_money";
4
21
  type TPaymentModel = "ips" | "default";
5
- declare enum EPaymentMethods {
22
+ export declare enum EPaymentMethods {
6
23
  CARD = "card",
7
24
  GOOGLE_PAY = "google_pay",
8
25
  APPLE_PAY = "apple_pay",
@@ -73,7 +90,6 @@ type TPaymentConfig = TCryptoPaymentConfig & {
73
90
  transactionFeesSlug: string;
74
91
  paymentOptions?: TPaymentOption[];
75
92
  paymentRedirectUrl?: string;
76
- baseUrl: string;
77
93
  paymentBaseUrl: string;
78
94
  productBaseUrl: string;
79
95
  feeBaseUrl: string;
@@ -170,6 +186,7 @@ export interface ITransactionFeesResponse {
170
186
  appliedFees: IAppliedFee[];
171
187
  appliedFeeIds: string[];
172
188
  tax: any;
189
+ isZeroDecimalCurrency?: boolean;
173
190
  }
174
191
  export interface IOrderAmount {
175
192
  currency: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mainstack-payments",
3
3
  "type": "module",
4
- "version": "2.0.5",
4
+ "version": "2.0.7",
5
5
  "main": "build/mainstack-payments.js",
6
6
  "types": "build/src/index.d.ts",
7
7
  "style": "build/index.css",
@@ -1,114 +0,0 @@
1
- import { jsxs as o, jsx as a } from "react/jsx-runtime";
2
- import { u as I, a as v, C as S, v as b, b as E } from "./index-BUQq9lgH.js";
3
- import { BodyText as z, ChevronRightIcon as N, toast as $ } from "mainstack-design-system";
4
- import { u as j } from "./payments-B3Hm80pK.js";
5
- import { useState as B } from "react";
6
- const M = (i) => /* @__PURE__ */ o(
7
- "svg",
8
- {
9
- viewBox: "0 0 32 32",
10
- fill: "none",
11
- xmlns: "http://www.w3.org/2000/svg",
12
- ...i,
13
- children: [
14
- /* @__PURE__ */ a("g", { clipPath: "url(#clip0_2605_970)", children: /* @__PURE__ */ a(
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__ */ a("defs", { children: /* @__PURE__ */ a("clipPath", { id: "clip0_2605_970", children: /* @__PURE__ */ a("rect", { width: "32", height: "32", fill: "white" }) }) })
22
- ]
23
- }
24
- ), q = ({
25
- ProductRequest: i,
26
- PaymentRequest: C,
27
- metadata: f,
28
- amount: m,
29
- currency: c,
30
- redirectUrl: l,
31
- checkForErrors: u
32
- }) => {
33
- const d = j(), { mutate: g, isLoading: w } = I(i), { mutate: L, isLoading: P } = v(C), [_, r] = B(!1), p = w || P || _, x = async () => {
34
- var y;
35
- const s = b(), h = {
36
- ...f,
37
- reference: s
38
- };
39
- try {
40
- await g(
41
- E({
42
- metadata: h,
43
- amount: m,
44
- currency: c
45
- }),
46
- {
47
- onSuccess: (t) => {
48
- },
49
- onError: (t) => {
50
- var n;
51
- throw ((n = t == null ? void 0 : t.raw) == null ? void 0 : n.message) ?? t;
52
- }
53
- }
54
- );
55
- const { client_secret: e } = await L(
56
- {
57
- amount: m,
58
- currency: c,
59
- metadata: h,
60
- is_crypto_payment: !0
61
- },
62
- {
63
- onSuccess: (t) => {
64
- },
65
- onError: (t) => {
66
- var n;
67
- throw ((n = t == null ? void 0 : t.raw) == null ? void 0 : n.message) ?? t;
68
- }
69
- }
70
- );
71
- if (d) {
72
- r(!0);
73
- const { error: t } = await d.confirmPayment({
74
- clientSecret: e,
75
- confirmParams: {
76
- payment_method_data: {
77
- // @ts-ignore
78
- type: "crypto"
79
- },
80
- return_url: l.includes("?") ? `${l}&reference=${s}` : `${l}?reference=${s}`
81
- }
82
- });
83
- if (t)
84
- throw new Error(t.message ?? "Couldn't load wallet integration");
85
- }
86
- } catch (e) {
87
- r(!1), console.error(e), $.error({
88
- title: "",
89
- description: ((y = e == null ? void 0 : e.raw) == null ? void 0 : y.message) ?? (e == null ? void 0 : e.message) ?? e ?? "We couldn't complete your payment"
90
- });
91
- }
92
- };
93
- return /* @__PURE__ */ a(
94
- S,
95
- {
96
- onClick: async () => {
97
- await u() || x();
98
- },
99
- disabled: p,
100
- isLoading: p,
101
- children: /* @__PURE__ */ o("div", { className: "mpl:flex mpl:justify-between mpl:w-full mpl:items-center", children: [
102
- /* @__PURE__ */ o("div", { className: "mpl:flex mpl:items-center mpl:gap-12", children: [
103
- /* @__PURE__ */ a(M, { className: "mpl:size-32" }),
104
- /* @__PURE__ */ a(z, { size: "extrasmall", weight: "medium", children: "Stablecoins & Crypto" })
105
- ] }),
106
- /* @__PURE__ */ a(N, { className: "mpl:size-20" }),
107
- " "
108
- ] })
109
- }
110
- );
111
- };
112
- export {
113
- q as default
114
- };
@@ -1,121 +0,0 @@
1
- import { IInitPayment, IInitPaymentResponse, ITransactionFeesResponse, TAPIMetadata, TPaymentMethods } from 'types';
2
-
3
- interface IGetTransactionFeesPayload {
4
- merchantId: string;
5
- currencyCode: string;
6
- amount: number;
7
- types: string[];
8
- address?: {
9
- country?: string;
10
- postal_code?: string;
11
- };
12
- ip?: string;
13
- appName?: string;
14
- quantity?: number;
15
- }
16
- export declare const useGetTransactionFees: (payload: IGetTransactionFeesPayload, FeeRequest: any) => {
17
- data: any;
18
- isLoading: boolean;
19
- refetch: () => Promise<import('hooks/useApi').IFetchResponse>;
20
- error: any;
21
- };
22
- export declare const useInitPayment: (ProductRequest: any) => {
23
- data: any;
24
- isLoading: boolean;
25
- mutate: (dataParams: IInitPayment, { onSuccess, onError, }: {
26
- onSuccess: (data: any) => void;
27
- onError: (error: any) => void;
28
- }) => Promise<any>;
29
- };
30
- export declare const buildInitPaymentPayload: ({ metadata, amount, currency, countryISO, totalAmount, }: {
31
- metadata: any;
32
- amount: number;
33
- currency: string;
34
- countryISO?: string | undefined;
35
- totalAmount?: number | undefined;
36
- }) => IInitPayment;
37
- export declare const buildChargePaymentPayload: ({ initResponse, feesResponse, metadata, currency, callbackUrl, paymentToken, paymentMethodId, ip, paymentMethod, }: {
38
- initResponse: IInitPaymentResponse;
39
- feesResponse: ITransactionFeesResponse;
40
- metadata: any;
41
- currency: string;
42
- callbackUrl?: string | undefined;
43
- paymentToken?: string | undefined;
44
- paymentMethodId?: string | undefined;
45
- ip?: string | undefined;
46
- paymentMethod?: "crypto" | "cashapp" | "card" | "transfer" | "mobile_money" | "google_pay" | "apple_pay" | "bank_transfer" | "ussd" | "payattitude" | "qr" | "wechat_pay" | undefined;
47
- }) => IChargePayment;
48
- export interface IChargePayment {
49
- orderId?: string;
50
- reference?: string;
51
- iPAddress?: string;
52
- paymentMethod?: string;
53
- paymentToken?: string;
54
- customerPaymentMethodId?: string;
55
- callbackUrl?: string;
56
- amount: {
57
- currency: string;
58
- value: number;
59
- };
60
- feeAmount?: {
61
- currency: string;
62
- value: number;
63
- };
64
- feeIds?: string[];
65
- merchantId: string;
66
- customer?: {
67
- email?: string;
68
- phone?: string;
69
- name?: string;
70
- };
71
- metadata?: Record<string, any>;
72
- source?: string;
73
- payment_method_id?: string;
74
- }
75
- export declare const useChargePayment: (PaymentRequest: any) => {
76
- data: any;
77
- isLoading: boolean;
78
- mutate: (dataParams: IChargePayment, { onSuccess, onError, }: {
79
- onSuccess: (data: any) => void;
80
- onError: (error: any) => void;
81
- }) => Promise<any>;
82
- };
83
- interface IIntentPayment {
84
- amount: number;
85
- currency: string;
86
- payment_method_id?: string;
87
- metadata: TAPIMetadata;
88
- is_crypto_payment?: boolean;
89
- is_cashapp_payment?: boolean;
90
- }
91
- export declare const useIntentPayment: (Request: any) => {
92
- data: any;
93
- isLoading: boolean;
94
- mutate: (dataParams: IIntentPayment, { onSuccess, onError, }: {
95
- onSuccess: (data: any) => void;
96
- onError: (error: any) => void;
97
- }) => Promise<any>;
98
- };
99
- export declare const useVerifyPayment: (reference: string, Request: any) => {
100
- data: any;
101
- isLoading: boolean;
102
- refetch: () => Promise<import('hooks/useApi').IFetchResponse>;
103
- error: any;
104
- };
105
- interface IApplyDiscount {
106
- discount_code: string;
107
- product_id: string;
108
- account_id: string;
109
- currency: string;
110
- store_id: string;
111
- cart_id?: string;
112
- ticket_payload?: string;
113
- payment_plan_id?: string;
114
- }
115
- export declare const useApplyDiscount: ({ discount_code, product_id, account_id, currency, store_id, ticket_payload, cart_id, payment_plan_id, }: IApplyDiscount, Request: any) => {
116
- data: any;
117
- isLoading: boolean;
118
- refetch: () => Promise<import('hooks/useApi').IFetchResponse>;
119
- error: any;
120
- };
121
- export {};
@@ -1,13 +0,0 @@
1
- /** @format */
2
- /// <reference types="react" />
3
- interface CashAppPaymentProps {
4
- ProductRequest: any;
5
- PaymentRequest: any;
6
- metadata: any;
7
- amount: number;
8
- currency: string;
9
- redirectUrl: string;
10
- checkForErrors: () => Promise<boolean>;
11
- }
12
- declare const CashAppPayment: import('react').MemoExoticComponent<({ ProductRequest, PaymentRequest, metadata, amount, currency, redirectUrl, checkForErrors, }: CashAppPaymentProps) => import("react/jsx-runtime").JSX.Element>;
13
- export default CashAppPayment;
@@ -1,12 +0,0 @@
1
- /** @format */
2
- interface CryptoPaymentsProps {
3
- ProductRequest: any;
4
- PaymentRequest: any;
5
- metadata: any;
6
- amount: number;
7
- currency: string;
8
- redirectUrl: string;
9
- checkForErrors: () => Promise<boolean>;
10
- }
11
- declare const CryptoPayments: ({ ProductRequest, PaymentRequest, metadata, amount, currency, redirectUrl, checkForErrors, }: CryptoPaymentsProps) => import("react/jsx-runtime").JSX.Element;
12
- export default CryptoPayments;
@@ -1,25 +0,0 @@
1
- export interface IFetchResponse {
2
- data: any;
3
- isSuccess: boolean;
4
- error: any;
5
- }
6
- export declare const useQuery: ({ queryFn, enabled, dependingOn, }: {
7
- queryFn: () => Promise<any>;
8
- enabled?: boolean | undefined;
9
- dependingOn?: any[] | undefined;
10
- }) => {
11
- data: any;
12
- isLoading: boolean;
13
- refetch: () => Promise<IFetchResponse>;
14
- error: any;
15
- };
16
- export declare const useMutation: <T>({ mutationFn, }: {
17
- mutationFn: (data: T) => Promise<any>;
18
- }) => {
19
- data: any;
20
- isLoading: boolean;
21
- mutate: (dataParams: T, { onSuccess, onError, }: {
22
- onSuccess: (data: any) => void;
23
- onError: (error: any) => void;
24
- }) => Promise<any>;
25
- };
File without changes