fairsure-checkout-sdk 1.0.0

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 (40) hide show
  1. package/dist/components/CardPayment.d.ts +18 -0
  2. package/dist/components/CardPayment.js +302 -0
  3. package/dist/components/Checkout.d.ts +9 -0
  4. package/dist/components/Checkout.js +520 -0
  5. package/dist/components/OTPInput.d.ts +17 -0
  6. package/dist/components/OTPInput.js +132 -0
  7. package/dist/components/PaymentMethodSelector.d.ts +12 -0
  8. package/dist/components/PaymentMethodSelector.js +67 -0
  9. package/dist/components/PaystackCheckout.d.ts +13 -0
  10. package/dist/components/PaystackCheckout.js +385 -0
  11. package/dist/components/PurchaseModal.d.ts +17 -0
  12. package/dist/components/PurchaseModal.js +415 -0
  13. package/dist/components/TransferPayment.d.ts +16 -0
  14. package/dist/components/TransferPayment.js +311 -0
  15. package/dist/components/USSDPayment.d.ts +21 -0
  16. package/dist/components/USSDPayment.js +316 -0
  17. package/dist/components/usePaymentCheckout.d.ts +61 -0
  18. package/dist/components/usePaymentCheckout.js +398 -0
  19. package/dist/context/CheckoutProvider.d.ts +5 -0
  20. package/dist/context/CheckoutProvider.js +16 -0
  21. package/dist/hooks/useCheckout.d.ts +1 -0
  22. package/dist/hooks/useCheckout.js +8 -0
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.js +2 -0
  25. package/dist/types.d.ts +9 -0
  26. package/dist/types.js +1 -0
  27. package/fairsure-checkout-sdk-1.0.0.tgz +0 -0
  28. package/package.json +24 -0
  29. package/src/components/CardPayment.tsx +386 -0
  30. package/src/components/OTPInput.tsx +204 -0
  31. package/src/components/PaymentMethodSelector.tsx +99 -0
  32. package/src/components/PaystackCheckout.tsx +506 -0
  33. package/src/components/TransferPayment.tsx +372 -0
  34. package/src/components/USSDPayment.tsx +422 -0
  35. package/src/components/usePaymentCheckout.ts +441 -0
  36. package/src/context/CheckoutProvider.tsx +37 -0
  37. package/src/hooks/useCheckout.ts +11 -0
  38. package/src/index.ts +2 -0
  39. package/src/types.ts +9 -0
  40. package/tsconfig.json +22 -0
@@ -0,0 +1,372 @@
1
+ import { Ionicons } from "@expo/vector-icons";
2
+ import {
3
+ ActivityIndicator,
4
+ StyleSheet,
5
+ Text,
6
+ TouchableOpacity,
7
+ View,
8
+ } from "react-native";
9
+
10
+ type TransferPaymentProps = {
11
+ loading: boolean;
12
+ amount: number;
13
+ transferDetail: {
14
+ bankName: string;
15
+ accountNumber: string;
16
+ accountName: string;
17
+ };
18
+ timeLeft: number;
19
+ copied: boolean;
20
+ handleCopy: (text: string) => void;
21
+ formatAmount: (value: number) => string;
22
+ formatTime: (seconds: number) => string;
23
+ };
24
+
25
+ export default function TransferPayment({
26
+ loading,
27
+ amount,
28
+ transferDetail,
29
+ timeLeft,
30
+ copied,
31
+ handleCopy,
32
+ formatAmount,
33
+ formatTime,
34
+ }: TransferPaymentProps) {
35
+ if (loading) {
36
+ return <ActivityIndicator size="large" color="#4F46E5" />;
37
+ }
38
+
39
+ return (
40
+ <View>
41
+ <View style={styles.transferBox}>
42
+ <Text style={styles.transferText}>
43
+ Transfer ₦{formatAmount(amount)} to the account below
44
+ </Text>
45
+
46
+ <View>
47
+ <TransferDetailItem
48
+ label="Bank Name"
49
+ value={transferDetail.bankName}
50
+ />
51
+
52
+ <View style={styles.transferDetail}>
53
+ <Text style={styles.transferLabel}>Account Number</Text>
54
+ <View style={styles.row}>
55
+ <Text style={styles.accountNumber}>
56
+ {transferDetail.accountNumber}
57
+ </Text>
58
+ <TouchableOpacity
59
+ onPress={() => handleCopy(transferDetail.accountNumber)}
60
+ >
61
+ <Ionicons
62
+ name={copied ? "checkmark" : "copy-outline"}
63
+ size={20}
64
+ color="#4F46E5"
65
+ />
66
+ </TouchableOpacity>
67
+ </View>
68
+ </View>
69
+
70
+ <TransferDetailItem
71
+ label="Account Name"
72
+ value={transferDetail.accountName}
73
+ />
74
+ </View>
75
+ </View>
76
+
77
+ <View style={styles.transferNote}>
78
+ <Text style={styles.transferNoteText}>
79
+ <Text style={{ fontWeight: "bold" }}>Note:</Text> This account expires
80
+ in{" "}
81
+ <Text
82
+ style={{
83
+ fontWeight: "bold",
84
+ color: timeLeft <= 10 * 60 ? "#FF0000" : "#4F46E5",
85
+ }}
86
+ >
87
+ {formatTime(timeLeft)}
88
+ </Text>{" "}
89
+ minutes. Please click "I have sent the Money" button once you have
90
+ sent the money.
91
+ </Text>
92
+ </View>
93
+ </View>
94
+ );
95
+ }
96
+
97
+ function TransferDetailItem({
98
+ label,
99
+ value,
100
+ }: {
101
+ label: string;
102
+ value: string;
103
+ }) {
104
+ return (
105
+ <View style={styles.transferDetail}>
106
+ <Text style={styles.transferLabel}>{label}</Text>
107
+ <Text style={styles.transferValue}>{value}</Text>
108
+ </View>
109
+ );
110
+ }
111
+
112
+ const styles = StyleSheet.create({
113
+ overlay: {
114
+ flex: 1,
115
+ backgroundColor: "rgba(0,0,0,0.5)",
116
+ justifyContent: "center",
117
+ },
118
+ modalContainer: {
119
+ position: "relative",
120
+ width: "90%",
121
+ alignSelf: "center",
122
+ borderRadius: 20,
123
+ height: "80%",
124
+ backgroundColor: "white",
125
+ },
126
+
127
+ otpContainer: {
128
+ width: "100%",
129
+ marginHorizontal: "auto",
130
+ marginTop: 20,
131
+ marginBottom: 40,
132
+ },
133
+ header: {
134
+ backgroundColor: "#6B21A8",
135
+ padding: 16,
136
+ borderTopLeftRadius: 20,
137
+ borderTopRightRadius: 20,
138
+ },
139
+ pinWrapper: {
140
+ flexDirection: "row",
141
+ alignItems: "center",
142
+ },
143
+ eyeButton: {
144
+ paddingHorizontal: 10,
145
+ },
146
+ eyeText: {
147
+ color: "#007AFF",
148
+ },
149
+
150
+ headerTop: {
151
+ flexDirection: "row",
152
+ justifyContent: "space-between",
153
+ alignItems: "flex-start",
154
+ marginBottom: 16,
155
+ },
156
+ headerTitle: { color: "white", fontSize: 24, fontWeight: "bold" },
157
+ headerSubtitle: { color: "#E0E7FF", fontSize: 14, marginTop: 4 },
158
+ closeBtn: {
159
+ backgroundColor: "rgba(255,255,255,0.2)",
160
+ borderRadius: 999,
161
+ padding: 8,
162
+ },
163
+ amountBox: {
164
+ backgroundColor: "rgba(255,255,255,0.2)",
165
+ borderRadius: 12,
166
+ padding: 8,
167
+ },
168
+ amountLabel: { color: "#E0E7FF", fontSize: 12, marginBottom: 4 },
169
+ amountText: { color: "white", fontSize: 20, fontWeight: "bold" },
170
+ scrollContainer: { flex: 1, marginBottom: 16 },
171
+ body: {
172
+ padding: 24,
173
+ backgroundColor: "white",
174
+ borderBottomLeftRadius: 20,
175
+ borderBottomRightRadius: 20,
176
+ },
177
+ paymentMethodsContainer: {
178
+ flexDirection: "row",
179
+ marginBottom: 24,
180
+ backgroundColor: "#F3F4F6",
181
+ padding: 4,
182
+ borderRadius: 12,
183
+ },
184
+ paymentMethod: {
185
+ flex: 1,
186
+ flexDirection: "row",
187
+ alignItems: "center",
188
+ justifyContent: "center",
189
+ paddingVertical: 12,
190
+ borderRadius: 12,
191
+ marginHorizontal: 4,
192
+ },
193
+ paymentMethodSelected: { backgroundColor: "white" },
194
+ paymentMethodText: { fontSize: 14, color: "#4B5563", marginLeft: 8 },
195
+ paymentMethodTextSelected: { color: "#4F46E5", fontWeight: "600" },
196
+ inputGroup: { marginBottom: 16 },
197
+ inputLabel: {
198
+ fontSize: 14,
199
+ fontWeight: "500",
200
+ color: "#374151",
201
+ marginBottom: 4,
202
+ },
203
+ inputWrapper: { position: "relative" },
204
+ input: {
205
+ width: "100%",
206
+ paddingHorizontal: 16,
207
+ paddingVertical: 12,
208
+ borderWidth: 1,
209
+ borderColor: "#D1D5DB",
210
+ borderRadius: 12,
211
+ backgroundColor: "white",
212
+ },
213
+ inputIcon: { position: "absolute", right: 16, top: 14 },
214
+ row: { flexDirection: "row", gap: 16, marginBottom: 12 },
215
+ flex1: { flex: 1 },
216
+ secureBox: {
217
+ flexDirection: "row",
218
+ alignItems: "center",
219
+ backgroundColor: "#F9FAFB",
220
+ padding: 12,
221
+ borderRadius: 12,
222
+ gap: 8,
223
+ marginBottom: 16,
224
+ },
225
+ secureText: { fontSize: 12, color: "#4B5563", flex: 1 },
226
+ transferBox: {
227
+ backgroundColor: "#EFF6FF",
228
+ borderWidth: 1,
229
+ borderColor: "#BFDBFE",
230
+ borderRadius: 12,
231
+ padding: 8,
232
+ marginBottom: 8,
233
+ },
234
+ transferText: {
235
+ fontSize: 14,
236
+ color: "#1E3A8A",
237
+ fontWeight: "500",
238
+ marginBottom: 12,
239
+ },
240
+ transferDetail: {
241
+ backgroundColor: "white",
242
+ borderRadius: 12,
243
+ padding: 8,
244
+ marginBottom: 12,
245
+ },
246
+ transferLabel: { fontSize: 10, color: "#4B5563", marginBottom: 4 },
247
+ transferValue: { fontWeight: "600", color: "#111827" },
248
+ accountNumber: {
249
+ fontWeight: "600",
250
+ color: "#111827",
251
+ fontSize: 16,
252
+ letterSpacing: 2,
253
+ flex: 1,
254
+ },
255
+ transferNote: {
256
+ backgroundColor: "#FEF3C7",
257
+ borderWidth: 1,
258
+ borderColor: "#FDE68A",
259
+ borderRadius: 12,
260
+ padding: 8,
261
+ },
262
+ transferNoteText: { fontSize: 14, color: "#78350F" },
263
+ dropdown: {
264
+ width: "100%",
265
+ paddingHorizontal: 16,
266
+ paddingVertical: 12,
267
+ borderWidth: 1,
268
+ borderColor: "#D1D5DB",
269
+ borderRadius: 12,
270
+ flexDirection: "row",
271
+ justifyContent: "space-between",
272
+ alignItems: "center",
273
+ },
274
+ dropdownText: { color: "#111827" },
275
+ dropdownPlaceholder: { color: "#9CA3AF" },
276
+ dropdownList: {
277
+ marginTop: 8,
278
+ backgroundColor: "white",
279
+ borderWidth: 1,
280
+ borderColor: "#E5E7EB",
281
+ borderRadius: 12,
282
+ overflow: "hidden",
283
+ maxHeight: 240,
284
+ },
285
+ dropdownItem: {
286
+ paddingVertical: 12,
287
+ paddingHorizontal: 16,
288
+ borderBottomWidth: 1,
289
+ borderBottomColor: "#F3F4F6",
290
+ },
291
+ dropdownItemText: { color: "#111827" },
292
+
293
+ ussdContainer: {
294
+ backgroundColor: "#E0E7FF", // bg-indigo-50
295
+ borderWidth: 1,
296
+ borderColor: "#C7D2FE", // border-indigo-200
297
+ borderRadius: 12, // rounded-xl
298
+ padding: 16, // p-4
299
+ marginBottom: 16,
300
+ },
301
+ ussdTitle: {
302
+ fontSize: 14, // text-sm
303
+ color: "#1E3A8A", // text-indigo-900
304
+ fontWeight: "500", // font-medium
305
+ marginBottom: 12, // mb-3
306
+ },
307
+ ussdCodeContainer: {
308
+ backgroundColor: "white", // bg-white
309
+ borderRadius: 12, // rounded-xl
310
+ padding: 16, // p-4
311
+ marginBottom: 12, // mb-3
312
+ },
313
+ ussdCodeRow: {
314
+ flexDirection: "row",
315
+ justifyContent: "space-between",
316
+ alignItems: "center",
317
+ },
318
+ ussdCodeText: {
319
+ fontFamily: "monospace", // font-mono
320
+ fontSize: 16, // text-base
321
+ fontWeight: "700", // font-bold
322
+ color: "#111827", // text-gray-900
323
+ flex: 1,
324
+ },
325
+ ussdCopyBtn: {
326
+ padding: 8, // p-2
327
+ },
328
+ ussdStepsLabel: {
329
+ fontSize: 14, // text-sm
330
+ color: "#1E3A8A", // text-indigo-900
331
+ fontWeight: "600", // font-semibold
332
+ marginBottom: 8, // mb-2
333
+ },
334
+ ussdStepsText: {
335
+ fontSize: 14, // text-sm
336
+ color: "#1E40AF", // text-indigo-800
337
+ },
338
+ payButton: {
339
+ display: "flex",
340
+ flexDirection: "row",
341
+ justifyContent: "center",
342
+ gap: 8,
343
+ width: "100%",
344
+ paddingVertical: 16, // py-4
345
+ borderRadius: 12, // rounded-xl
346
+ marginTop: 8, // mt-2
347
+ alignItems: "center",
348
+ },
349
+ payButtonActive: {
350
+ backgroundColor: "#4F46E5", // bg-indigo-600
351
+ },
352
+ payButtonDisabled: {
353
+ backgroundColor: "#D1D5DB", // bg-gray-300
354
+ },
355
+ payButtonText: {
356
+ color: "white",
357
+ fontWeight: "600",
358
+ fontSize: 18, // text-lg
359
+ textAlign: "center",
360
+ },
361
+ footer: {
362
+ flexDirection: "row",
363
+ justifyContent: "center",
364
+ alignItems: "center",
365
+ marginTop: 8, // mt-2
366
+ gap: 8, // supported in RN 0.71+, acts like Tailwind gap-2
367
+ },
368
+ footerText: {
369
+ fontSize: 14, // text-sm
370
+ color: "#6B7280", // text-gray-500
371
+ },
372
+ });