@zezosoft/react-native-zezopay 1.0.2 → 1.0.3
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/README.md +4 -4
- package/lib/module/ZezoPay/ZezoPay.js +41 -27
- package/lib/module/ZezoPay/ZezoPay.js.map +1 -1
- package/lib/module/ZezoPay/components/PaymentMethod.js.map +1 -1
- package/lib/module/ZezoPay/components/Summary.js.map +1 -1
- package/lib/module/ZezoPay/components/VoucherBox.js +76 -27
- package/lib/module/ZezoPay/components/VoucherBox.js.map +1 -1
- package/lib/module/ZezoPay/http/api-sdk.js +14 -0
- package/lib/module/ZezoPay/http/api-sdk.js.map +1 -0
- package/lib/module/ZezoPay/http/services/baseService.js +28 -0
- package/lib/module/ZezoPay/http/services/baseService.js.map +1 -0
- package/lib/module/ZezoPay/http/services/payments/payments.js +51 -0
- package/lib/module/ZezoPay/http/services/payments/payments.js.map +1 -0
- package/lib/module/ZezoPay/http/services/payments/payments.types.js +2 -0
- package/lib/module/ZezoPay/http/services/payments/payments.types.js.map +1 -0
- package/lib/module/ZezoPay/http/utils/errorFormatter.js +49 -0
- package/lib/module/ZezoPay/http/utils/errorFormatter.js.map +1 -0
- package/lib/module/ZezoPay/utils/hooks/useZezoPay.js +187 -203
- package/lib/module/ZezoPay/utils/hooks/useZezoPay.js.map +1 -1
- package/lib/typescript/src/ZezoPay/ZezoPay.d.ts.map +1 -1
- package/lib/typescript/src/ZezoPay/components/PaymentMethod.d.ts +2 -2
- package/lib/typescript/src/ZezoPay/components/PaymentMethod.d.ts.map +1 -1
- package/lib/typescript/src/ZezoPay/components/Summary.d.ts +1 -1
- package/lib/typescript/src/ZezoPay/components/Summary.d.ts.map +1 -1
- package/lib/typescript/src/ZezoPay/components/VoucherBox.d.ts +6 -3
- package/lib/typescript/src/ZezoPay/components/VoucherBox.d.ts.map +1 -1
- package/lib/typescript/src/ZezoPay/http/api-sdk.d.ts +21 -0
- package/lib/typescript/src/ZezoPay/http/api-sdk.d.ts.map +1 -0
- package/lib/typescript/src/ZezoPay/http/services/baseService.d.ts +9 -0
- package/lib/typescript/src/ZezoPay/http/services/baseService.d.ts.map +1 -0
- package/lib/typescript/src/ZezoPay/http/services/payments/payments.d.ts +25 -0
- package/lib/typescript/src/ZezoPay/http/services/payments/payments.d.ts.map +1 -0
- package/lib/typescript/src/ZezoPay/http/services/payments/payments.types.d.ts +100 -0
- package/lib/typescript/src/ZezoPay/http/services/payments/payments.types.d.ts.map +1 -0
- package/lib/typescript/src/ZezoPay/http/utils/errorFormatter.d.ts +6 -0
- package/lib/typescript/src/ZezoPay/http/utils/errorFormatter.d.ts.map +1 -0
- package/lib/typescript/src/ZezoPay/types/index.d.ts +27 -6
- package/lib/typescript/src/ZezoPay/types/index.d.ts.map +1 -1
- package/lib/typescript/src/ZezoPay/utils/hooks/useZezoPay.d.ts +23 -29
- package/lib/typescript/src/ZezoPay/utils/hooks/useZezoPay.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/ZezoPay/ZezoPay.tsx +49 -28
- package/src/ZezoPay/components/PaymentMethod.tsx +4 -4
- package/src/ZezoPay/components/Summary.tsx +1 -1
- package/src/ZezoPay/components/VoucherBox.tsx +100 -51
- package/src/ZezoPay/http/api-sdk.ts +27 -0
- package/src/ZezoPay/http/services/baseService.ts +37 -0
- package/src/ZezoPay/http/services/payments/payments.ts +66 -0
- package/src/ZezoPay/http/services/payments/payments.types.ts +120 -0
- package/src/ZezoPay/http/utils/errorFormatter.ts +88 -0
- package/src/ZezoPay/types/index.ts +41 -7
- package/src/ZezoPay/utils/hooks/useZezoPay.ts +234 -231
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// utils/formatAPIError.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Converts any kind of error (network, backend, unknown) into a consistent APIError format
|
|
7
|
+
*/
|
|
8
|
+
export function formatAPIError(err) {
|
|
9
|
+
const error = err;
|
|
10
|
+
if (error?.code === 'ECONNREFUSED' || error?.message?.includes('Network Error')) {
|
|
11
|
+
return {
|
|
12
|
+
type: 'network_error',
|
|
13
|
+
status: error.code,
|
|
14
|
+
message: 'Network error: check your connection.',
|
|
15
|
+
path: error?.config?.url || '',
|
|
16
|
+
location: ''
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const isHtml = error?.response?.headers?.['content-type']?.includes('text/html') || typeof error?.response?.data === 'string' && error.response.data.startsWith('<!DOCTYPE html>');
|
|
20
|
+
if (isHtml) {
|
|
21
|
+
return {
|
|
22
|
+
type: 'invalid_route',
|
|
23
|
+
status: error?.response?.status || 404,
|
|
24
|
+
message: 'This API endpoint does not exist or cannot be called.',
|
|
25
|
+
path: error?.config?.url || '',
|
|
26
|
+
location: ''
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const firstError = error?.response?.data?.errors?.[0];
|
|
30
|
+
const errorObj = error?.response?.data?.error;
|
|
31
|
+
const message = firstError?.msg || errorObj?.message || error?.response?.data?.message;
|
|
32
|
+
if (message) {
|
|
33
|
+
return {
|
|
34
|
+
type: firstError?.type || errorObj?.type || 'backend_error',
|
|
35
|
+
status: error?.response?.status,
|
|
36
|
+
message,
|
|
37
|
+
path: firstError?.path || errorObj?.path || error?.config?.url || '',
|
|
38
|
+
location: firstError?.location || errorObj?.location || ''
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
type: 'unknown_error',
|
|
43
|
+
status: error?.response?.status,
|
|
44
|
+
message: error?.message || 'An unknown error occurred.',
|
|
45
|
+
path: error?.config?.url || '',
|
|
46
|
+
location: ''
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=errorFormatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["formatAPIError","err","error","code","message","includes","type","status","path","config","url","location","isHtml","response","headers","data","startsWith","firstError","errors","errorObj","msg"],"sourceRoot":"../../../../../src","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,EAAEX,OAAO;EAExE,IAAIA,OAAO,EAAE;IACX,OAAO;MACLE,IAAI,EAAEW,UAAU,EAAEX,IAAI,IAAIa,QAAQ,EAAEb,IAAI,IAAI,eAAe;MAC3DC,MAAM,EAAEL,KAAK,EAAEW,QAAQ,EAAEN,MAAM;MAC/BH,OAAO;MACPI,IAAI,EAAES,UAAU,EAAET,IAAI,IAAIW,QAAQ,EAAEX,IAAI,IAAIN,KAAK,EAAEO,MAAM,EAAEC,GAAG,IAAI,EAAE;MACpEC,QAAQ,EAAEM,UAAU,EAAEN,QAAQ,IAAIQ,QAAQ,EAAER,QAAQ,IAAI;IAC1D,CAAC;EACH;EAEA,OAAO;IACLL,IAAI,EAAE,eAAe;IACrBC,MAAM,EAAEL,KAAK,EAAEW,QAAQ,EAAEN,MAAM;IAC/BH,OAAO,EAAEF,KAAK,EAAEE,OAAO,IAAI,4BAA4B;IACvDI,IAAI,EAAEN,KAAK,EAAEO,MAAM,EAAEC,GAAG,IAAI,EAAE;IAC9BC,QAAQ,EAAE;EACZ,CAAC;AACH","ignoreList":[]}
|
|
@@ -2,264 +2,248 @@
|
|
|
2
2
|
|
|
3
3
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
4
4
|
import { useAsync } from "./useAsync.js";
|
|
5
|
-
import { ZezoPayClient } from
|
|
6
|
-
import { Platform } from 'react-native';
|
|
5
|
+
import { ZezoPayClient } from "../../http/api-sdk.js";
|
|
7
6
|
import { Razorpay } from "../../Payments/Providers/index.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Parameters for the useZezoPay hook
|
|
12
|
-
* @interface UseZezoPayParams
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Custom hook to handle payments with ZezoPay SDK.
|
|
17
|
-
* Manages payment providers, summary items, and checkout process.
|
|
18
|
-
* @param params - Configuration for the ZezoPay client
|
|
19
|
-
* @returns Object with payment state and methods
|
|
20
|
-
*/
|
|
7
|
+
import { Platform } from 'react-native';
|
|
8
|
+
export const SUPPORTED_PROVIDERS = ['razorpay'];
|
|
21
9
|
export const useZezoPay = ({
|
|
22
10
|
publicKey,
|
|
23
|
-
|
|
11
|
+
user,
|
|
24
12
|
subscriptionId,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
13
|
+
productId,
|
|
14
|
+
cart: initialCart = [],
|
|
15
|
+
paymentHandler: customHandler,
|
|
16
|
+
callbacks
|
|
29
17
|
}) => {
|
|
30
|
-
// Input validation
|
|
31
18
|
if (!publicKey) throw new Error('publicKey is required');
|
|
32
|
-
if (!
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const zezopay = useMemo(() => new ZezoPayClient({
|
|
36
|
-
publicKey,
|
|
37
|
-
platform: Platform.OS === 'ios' ? 'ios' : 'android'
|
|
19
|
+
if (!user?._id || !user?.name) throw new Error('User must have _id and name');
|
|
20
|
+
const client = useMemo(() => new ZezoPayClient({
|
|
21
|
+
publicKey
|
|
38
22
|
}), [publicKey]);
|
|
39
23
|
|
|
40
24
|
// States
|
|
41
|
-
const [
|
|
42
|
-
const [
|
|
43
|
-
const [
|
|
44
|
-
const [
|
|
45
|
-
const [
|
|
25
|
+
const [provider, setProvider] = useState(null);
|
|
26
|
+
const [cartItems, setCartItems] = useState(initialCart);
|
|
27
|
+
const [coupon, setCoupon] = useState('');
|
|
28
|
+
const [loadingPayment, setLoadingPayment] = useState(false);
|
|
29
|
+
const [couponLoading, setCouponLoading] = useState(false); // ✅ coupon loading
|
|
30
|
+
const [success, setSuccess] = useState(false);
|
|
46
31
|
const [error, setError] = useState('');
|
|
47
32
|
|
|
48
|
-
//
|
|
33
|
+
// Fetch available providers
|
|
49
34
|
const {
|
|
50
35
|
result: providers,
|
|
51
36
|
loading,
|
|
52
|
-
error:
|
|
37
|
+
error: providersError
|
|
53
38
|
} = useAsync(async () => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return filtered;
|
|
61
|
-
} catch (err) {
|
|
62
|
-
throw err;
|
|
63
|
-
}
|
|
39
|
+
const data = (await client.payments.providers({
|
|
40
|
+
platform: Platform.OS
|
|
41
|
+
}))?.data || [];
|
|
42
|
+
const supported = data.filter(p => SUPPORTED_PROVIDERS.includes(p.provider));
|
|
43
|
+
if (!supported.length) throw new Error('No supported payment providers available');
|
|
44
|
+
return supported;
|
|
64
45
|
}, [publicKey]);
|
|
65
46
|
|
|
66
|
-
// Auto
|
|
47
|
+
// Auto select first provider
|
|
67
48
|
useEffect(() => {
|
|
68
|
-
if (providers?.length && !
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
}, [providers, selectedPayment]);
|
|
49
|
+
if (providers?.length && !provider) setProvider(providers?.[0]?.provider);
|
|
50
|
+
}, [providers, provider]);
|
|
72
51
|
|
|
73
|
-
//
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
return Number(summaryItems.reduce((sum, item) => {
|
|
52
|
+
// Cart totals
|
|
53
|
+
const totalAmount = useMemo(() => {
|
|
54
|
+
return cartItems.reduce((sum, item) => {
|
|
77
55
|
let price = item.price || 0;
|
|
78
56
|
if (item.discount) {
|
|
79
|
-
if (typeof item.discount === 'number')
|
|
80
|
-
price = price * (100 - item.discount) / 100;
|
|
81
|
-
} else if (item.discount.type === 'percentage') {
|
|
82
|
-
price = price * (100 - item.discount.amount) / 100;
|
|
83
|
-
} else if (item.discount.type === 'fixed') {
|
|
84
|
-
price = Math.max(0, price - item.discount.amount); // Prevent negative prices
|
|
85
|
-
}
|
|
57
|
+
if (typeof item.discount === 'number') price *= (100 - item.discount) / 100;else if (item.discount.type === 'percentage') price *= (100 - item.discount.amount) / 100;else if (item.discount.type === 'fixed') price = Math.max(0, price - item.discount.amount);
|
|
86
58
|
}
|
|
87
59
|
return sum + price;
|
|
88
|
-
}, 0)
|
|
89
|
-
}, [
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const removeItem = useCallback(id => {
|
|
93
|
-
setSummaryItems(prev => prev.filter(item => item.id !== id));
|
|
94
|
-
}, []);
|
|
60
|
+
}, 0);
|
|
61
|
+
}, [cartItems]);
|
|
62
|
+
const rawAmount = useMemo(() => cartItems.reduce((sum, item) => sum + (item.price || 0), 0), [cartItems]);
|
|
63
|
+
const removeItem = useCallback(id => setCartItems(prev => prev.filter(item => item.id !== id)), []);
|
|
95
64
|
|
|
96
65
|
// Default checkout handler
|
|
97
|
-
const
|
|
98
|
-
provider,
|
|
66
|
+
const defaultHandler = useCallback(async ({
|
|
67
|
+
provider: checkoutProvider,
|
|
99
68
|
subscriptionId: subId,
|
|
100
|
-
digitalProductId:
|
|
101
|
-
userInfo
|
|
69
|
+
digitalProductId: prodId,
|
|
70
|
+
userInfo
|
|
102
71
|
}) => {
|
|
103
|
-
if (!
|
|
104
|
-
throw new Error(`Invalid payment provider: ${provider || 'none'}`);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Common payload properties
|
|
72
|
+
if (!checkoutProvider || !SUPPORTED_PROVIDERS.includes(checkoutProvider)) throw new Error(`Invalid provider: ${checkoutProvider}`);
|
|
108
73
|
const basePayload = {
|
|
109
|
-
provider,
|
|
110
|
-
userId:
|
|
74
|
+
provider: checkoutProvider,
|
|
75
|
+
userId: userInfo._id,
|
|
111
76
|
metadata: {
|
|
112
|
-
userInfo
|
|
77
|
+
userInfo,
|
|
78
|
+
...(cartItems.length && {
|
|
79
|
+
summary: cartItems
|
|
80
|
+
})
|
|
113
81
|
},
|
|
114
|
-
...(
|
|
115
|
-
coupon_code:
|
|
116
|
-
})
|
|
82
|
+
...(coupon && {
|
|
83
|
+
coupon_code: coupon
|
|
84
|
+
})
|
|
117
85
|
};
|
|
118
|
-
|
|
119
|
-
// Construct payload based on type
|
|
120
86
|
let payload;
|
|
121
|
-
if (subId) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
digitalProductId: dpId
|
|
132
|
-
};
|
|
133
|
-
} else {
|
|
134
|
-
if (totalPrice <= 0) {
|
|
135
|
-
throw new Error('Price must be greater than zero for normal payments');
|
|
136
|
-
}
|
|
87
|
+
if (subId) payload = {
|
|
88
|
+
...basePayload,
|
|
89
|
+
type: 'subscription',
|
|
90
|
+
subscriptionId: subId
|
|
91
|
+
};else if (prodId) payload = {
|
|
92
|
+
...basePayload,
|
|
93
|
+
type: 'digital-product',
|
|
94
|
+
digitalProductId: prodId
|
|
95
|
+
};else {
|
|
96
|
+
if (rawAmount <= 0) throw new Error('Amount must be greater than zero');
|
|
137
97
|
payload = {
|
|
138
98
|
...basePayload,
|
|
139
99
|
type: 'normal',
|
|
140
|
-
price:
|
|
100
|
+
price: rawAmount
|
|
141
101
|
};
|
|
142
102
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const paymentFn = handlePayment || defaultHandlePayment;
|
|
103
|
+
const result = await client.payments.checkout({
|
|
104
|
+
...payload,
|
|
105
|
+
...(coupon && {
|
|
106
|
+
coupon_code: coupon
|
|
107
|
+
})
|
|
108
|
+
});
|
|
109
|
+
if (result.status !== 200) throw new Error(`Checkout failed with status ${result.status}`);
|
|
110
|
+
return result.data;
|
|
111
|
+
}, [coupon, client.payments, cartItems, rawAmount]);
|
|
112
|
+
const executePayment = customHandler || defaultHandler;
|
|
154
113
|
|
|
155
|
-
//
|
|
156
|
-
const
|
|
157
|
-
if (!
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
setIsSuccess(true);
|
|
181
|
-
setError('');
|
|
182
|
-
} else {
|
|
183
|
-
const err = new Error('Payment failed: No payment ID received');
|
|
184
|
-
setError(err.message);
|
|
185
|
-
callback?.onFailure?.(err);
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
OnError(err) {
|
|
189
|
-
const errorMessage = err?.description || err?.message || err?.details?.error?.description || 'Payment failed unexpectedly';
|
|
190
|
-
setError(errorMessage);
|
|
191
|
-
callback?.onFailure?.(err);
|
|
192
|
-
},
|
|
193
|
-
prefill: {
|
|
194
|
-
user_email: userInfo.email,
|
|
195
|
-
user_name: userInfo.name,
|
|
196
|
-
user_phone: userInfo.phone
|
|
114
|
+
// Razorpay payment processor
|
|
115
|
+
const processPayment = useCallback(async order => {
|
|
116
|
+
if (!provider) throw new Error('No payment provider selected');
|
|
117
|
+
if (!order?.orderId || !order?.price || !order?.currency) throw new Error('Invalid order');
|
|
118
|
+
if (provider === 'razorpay') {
|
|
119
|
+
const razorpay = new Razorpay();
|
|
120
|
+
await razorpay.open({
|
|
121
|
+
amount: order.price * 100,
|
|
122
|
+
currency: order.currency,
|
|
123
|
+
order_id: order.orderId,
|
|
124
|
+
publicKey: order.publicKey || publicKey,
|
|
125
|
+
handler(response) {
|
|
126
|
+
if (response.razorpay_payment_id) {
|
|
127
|
+
callbacks?.onSuccess?.({
|
|
128
|
+
status: 'success',
|
|
129
|
+
order_id: response.razorpay_order_id,
|
|
130
|
+
signature: response.razorpay_signature,
|
|
131
|
+
payment_id: response.razorpay_payment_id
|
|
132
|
+
});
|
|
133
|
+
setSuccess(true);
|
|
134
|
+
setError('');
|
|
135
|
+
} else {
|
|
136
|
+
const err = new Error('Payment failed: missing payment ID');
|
|
137
|
+
setError(err.message);
|
|
138
|
+
callbacks?.onFailure?.(err);
|
|
197
139
|
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
140
|
+
},
|
|
141
|
+
OnError(err) {
|
|
142
|
+
const msg = err?.description || err?.message || err?.details?.error?.description || 'Payment failed';
|
|
143
|
+
setError(msg);
|
|
144
|
+
callbacks?.onFailure?.(err);
|
|
145
|
+
},
|
|
146
|
+
prefill: {
|
|
147
|
+
user_email: user.email,
|
|
148
|
+
user_name: user.name,
|
|
149
|
+
user_phone: user.phone
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
} else throw new Error(`Unsupported provider: ${provider}`);
|
|
153
|
+
}, [provider, user, callbacks, publicKey]);
|
|
154
|
+
|
|
155
|
+
// Apply coupon
|
|
156
|
+
const applyCoupon = useCallback(async code => {
|
|
157
|
+
if (!code) return;
|
|
158
|
+
setCouponLoading(true);
|
|
159
|
+
setError('');
|
|
160
|
+
try {
|
|
161
|
+
const res = await client.payments.verifyCoupon({
|
|
162
|
+
userId: user._id,
|
|
163
|
+
code
|
|
164
|
+
});
|
|
165
|
+
const data = res?.data?.data;
|
|
166
|
+
if (!data || res.status !== 200) return setError(res?.data?.message || 'Invalid or expired coupon');
|
|
167
|
+
if (data.type === 'percentage') setCartItems(prev => prev.map(item => ({
|
|
168
|
+
...item,
|
|
169
|
+
discount: {
|
|
170
|
+
type: 'percentage',
|
|
171
|
+
amount: data.discount
|
|
172
|
+
}
|
|
173
|
+
})));else if (data.type === 'amount') setCartItems(prev => prev.map((item, i) => i === 0 ? {
|
|
174
|
+
...item,
|
|
175
|
+
discount: {
|
|
176
|
+
type: 'fixed',
|
|
177
|
+
amount: data.discount
|
|
178
|
+
}
|
|
179
|
+
} : item));
|
|
180
|
+
setCoupon(code);
|
|
202
181
|
} catch (err) {
|
|
203
|
-
|
|
182
|
+
setError(err?.message || 'Coupon verification failed');
|
|
183
|
+
} finally {
|
|
184
|
+
setCouponLoading(false);
|
|
204
185
|
}
|
|
205
|
-
}, [
|
|
186
|
+
}, [client.payments, user._id]);
|
|
206
187
|
|
|
207
|
-
//
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
if (!summaryItems.length) {
|
|
215
|
-
setError('Cart is empty. Add items to proceed.');
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
if (totalPrice <= 0) {
|
|
219
|
-
setError('Total price must be greater than zero');
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
188
|
+
// Remove coupon
|
|
189
|
+
const removeCoupon = useCallback(() => {
|
|
190
|
+
setCoupon('');
|
|
191
|
+
setCartItems(prev => prev.map(item => ({
|
|
192
|
+
...item,
|
|
193
|
+
discount: undefined
|
|
194
|
+
})));
|
|
222
195
|
setError('');
|
|
223
|
-
|
|
196
|
+
}, []);
|
|
224
197
|
|
|
198
|
+
// Pay now
|
|
199
|
+
const payNow = useCallback(async () => {
|
|
200
|
+
if (loadingPayment) return;
|
|
201
|
+
if (!provider) return setError('Select a payment provider');
|
|
202
|
+
if (!cartItems.length) return setError('Cart is empty');
|
|
203
|
+
if (totalAmount <= 0) return setError('Amount must be greater than zero');
|
|
204
|
+
setError('');
|
|
205
|
+
setLoadingPayment(true);
|
|
225
206
|
try {
|
|
226
|
-
const order = await
|
|
227
|
-
provider
|
|
207
|
+
const order = await executePayment({
|
|
208
|
+
provider,
|
|
228
209
|
subscriptionId,
|
|
229
|
-
digitalProductId,
|
|
230
|
-
userInfo
|
|
210
|
+
digitalProductId: productId,
|
|
211
|
+
userInfo: user,
|
|
212
|
+
metadata: {
|
|
213
|
+
userInfo: user,
|
|
214
|
+
...(cartItems.length && {
|
|
215
|
+
summary: cartItems
|
|
216
|
+
})
|
|
217
|
+
}
|
|
231
218
|
});
|
|
232
|
-
if (!order)
|
|
233
|
-
|
|
234
|
-
setError(err.message);
|
|
235
|
-
callback?.onError?.(err);
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
await paymentHandler(order);
|
|
219
|
+
if (!order) throw new Error('No order data returned');
|
|
220
|
+
await processPayment(order);
|
|
239
221
|
} catch (err) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
callback?.onError?.(err);
|
|
222
|
+
setError(err.message || 'Payment failed');
|
|
223
|
+
callbacks?.onError?.(err);
|
|
243
224
|
} finally {
|
|
244
|
-
|
|
225
|
+
setLoadingPayment(false);
|
|
245
226
|
}
|
|
246
|
-
}, [
|
|
227
|
+
}, [loadingPayment, provider, cartItems, totalAmount, executePayment, subscriptionId, productId, user, processPayment, callbacks]);
|
|
247
228
|
return {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
229
|
+
provider,
|
|
230
|
+
setProvider,
|
|
231
|
+
cartItems,
|
|
232
|
+
setCartItems,
|
|
233
|
+
totalAmount,
|
|
234
|
+
coupon,
|
|
235
|
+
setCoupon,
|
|
236
|
+
couponLoading,
|
|
237
|
+
removeCoupon,
|
|
238
|
+
loadingPayment,
|
|
239
|
+
success,
|
|
257
240
|
error,
|
|
258
241
|
providers: providers || [],
|
|
259
242
|
loading,
|
|
260
|
-
|
|
243
|
+
providersError,
|
|
261
244
|
removeItem,
|
|
262
|
-
|
|
245
|
+
payNow,
|
|
246
|
+
applyCoupon
|
|
263
247
|
};
|
|
264
248
|
};
|
|
265
249
|
//# sourceMappingURL=useZezoPay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","useEffect","useMemo","useState","useAsync","ZezoPayClient","
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useMemo","useState","useAsync","ZezoPayClient","Razorpay","Platform","SUPPORTED_PROVIDERS","useZezoPay","publicKey","user","subscriptionId","productId","cart","initialCart","paymentHandler","customHandler","callbacks","Error","_id","name","client","provider","setProvider","cartItems","setCartItems","coupon","setCoupon","loadingPayment","setLoadingPayment","couponLoading","setCouponLoading","success","setSuccess","error","setError","result","providers","loading","providersError","data","payments","platform","OS","supported","filter","p","includes","length","totalAmount","reduce","sum","item","price","discount","type","amount","Math","max","rawAmount","removeItem","id","prev","defaultHandler","checkoutProvider","subId","digitalProductId","prodId","userInfo","basePayload","userId","metadata","summary","coupon_code","payload","checkout","status","executePayment","processPayment","order","orderId","currency","razorpay","open","order_id","handler","response","razorpay_payment_id","onSuccess","razorpay_order_id","signature","razorpay_signature","payment_id","err","message","onFailure","OnError","msg","description","details","prefill","user_email","email","user_name","user_phone","phone","applyCoupon","code","res","verifyCoupon","map","i","removeCoupon","undefined","payNow","onError"],"sourceRoot":"../../../../../src","sources":["ZezoPay/utils/hooks/useZezoPay.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACjE,SAASC,QAAQ,QAAQ,eAAY;AACrC,SACEC,aAAa,QAMR,uBAAoB;AAC3B,SAASC,QAAQ,QAAQ,mCAA0B;AAMnD,SAASC,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,mBAAsC,GAAG,CAAC,UAAU,CAAC;AAYlE,OAAO,MAAMC,UAAU,GAAGA,CAAC;EACzBC,SAAS;EACTC,IAAI;EACJC,cAAc;EACdC,SAAS;EACTC,IAAI,EAAEC,WAAW,GAAG,EAAE;EACtBC,cAAc,EAAEC,aAAa;EAC7BC;AACgB,CAAC,KAAK;EACtB,IAAI,CAACR,SAAS,EAAE,MAAM,IAAIS,KAAK,CAAC,uBAAuB,CAAC;EACxD,IAAI,CAACR,IAAI,EAAES,GAAG,IAAI,CAACT,IAAI,EAAEU,IAAI,EAAE,MAAM,IAAIF,KAAK,CAAC,6BAA6B,CAAC;EAE7E,MAAMG,MAAM,GAAGpB,OAAO,CAAC,MAAM,IAAIG,aAAa,CAAC;IAAEK;EAAU,CAAC,CAAC,EAAE,CAACA,SAAS,CAAC,CAAC;;EAE3E;EACA,MAAM,CAACa,QAAQ,EAAEC,WAAW,CAAC,GAAGrB,QAAQ,CAAyB,IA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IACdI,OAAO;IACPE,KAAK;IACLG,SAAS,EAAEA,SAAS,IAAI,EAAE;IAC1BC,OAAO;IACPC,cAAc;IACdqB,UAAU;IACVsD,MAAM;IACNR;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZezoPay.d.ts","sourceRoot":"","sources":["../../../../src/ZezoPay/ZezoPay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAc1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"ZezoPay.d.ts","sourceRoot":"","sources":["../../../../src/ZezoPay/ZezoPay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAc1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQ5C,QAAA,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAkInC,CAAC;AA4CF,eAAe,OAAO,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { PaymentProviderData } from '@zezosoft/zezopay-client';
|
|
2
1
|
import React from 'react';
|
|
2
|
+
import type { IReadyPaymentProvider } from '../http/api-sdk';
|
|
3
3
|
interface PaymentMethodProps {
|
|
4
|
-
providers:
|
|
4
|
+
providers: IReadyPaymentProvider[];
|
|
5
5
|
selectedProvider: string | null;
|
|
6
6
|
onProviderChange: (provider: string) => void;
|
|
7
7
|
isLoading?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaymentMethod.d.ts","sourceRoot":"","sources":["../../../../../src/ZezoPay/components/PaymentMethod.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"PaymentMethod.d.ts","sourceRoot":"","sources":["../../../../../src/ZezoPay/components/PaymentMethod.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAGjD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,UAAU,kBAAkB;IAC1B,SAAS,EAAE,qBAAqB,EAAE,CAAC;IACnC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;;AA2PD,wBAAmC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Summary.d.ts","sourceRoot":"","sources":["../../../../../src/ZezoPay/components/Summary.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Summary.d.ts","sourceRoot":"","sources":["../../../../../src/ZezoPay/components/Summary.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,eAAO,MAAM,OAAO,8CAIjB;IACD,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,YAAY,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;CACjD,4CA4FA,CAAC"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
interface VoucherBoxProps {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
onApply?: ({ voucherCode }: {
|
|
4
|
+
voucherCode: string;
|
|
5
|
+
}) => void;
|
|
6
|
+
loading?: boolean;
|
|
7
|
+
couponApplied?: boolean;
|
|
8
|
+
onRemove?: () => void;
|
|
6
9
|
}
|
|
7
10
|
declare const VoucherBox: React.FC<VoucherBoxProps>;
|
|
8
11
|
export default VoucherBox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoucherBox.d.ts","sourceRoot":"","sources":["../../../../../src/ZezoPay/components/VoucherBox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAqB1B,UAAU,eAAe;IACvB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"VoucherBox.d.ts","sourceRoot":"","sources":["../../../../../src/ZezoPay/components/VoucherBox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAqB1B,UAAU,eAAe;IACvB,OAAO,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA4EzC,CAAC;AA6EF,eAAe,UAAU,CAAC"}
|