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,18 @@
1
+ type CardPaymentProps = {
2
+ cardNumber: string;
3
+ setCardNumber: (value: string) => void;
4
+ expiryDate: string;
5
+ setExpiryDate: (value: string) => void;
6
+ cvv: string;
7
+ message?: string;
8
+ setCvv: (value: string) => void;
9
+ cardcontinue: boolean;
10
+ showOtp: boolean;
11
+ handleOTPComplete: (otp: string) => void;
12
+ handleOTPChange: (otp: string) => void;
13
+ handlePinChange: (pin: string) => void;
14
+ formatCardNumber: (value: string) => string;
15
+ formatExpiry: (value: string) => string;
16
+ };
17
+ export default function CardPayment({ cardNumber, message, setCardNumber, expiryDate, setExpiryDate, cvv, setCvv, cardcontinue, showOtp, handleOTPComplete, handleOTPChange, handlePinChange, formatCardNumber, formatExpiry, }: CardPaymentProps): import("react").JSX.Element;
18
+ export {};
@@ -0,0 +1,302 @@
1
+ import { Ionicons } from "@expo/vector-icons";
2
+ import { StyleSheet, Text, TextInput, View } from "react-native";
3
+ import OTPInput from "./OTPInput";
4
+ export default function CardPayment({ cardNumber, message, setCardNumber, expiryDate, setExpiryDate, cvv, setCvv, cardcontinue, showOtp, handleOTPComplete, handleOTPChange, handlePinChange, formatCardNumber, formatExpiry, }) {
5
+ if (cardcontinue) {
6
+ return (<View>
7
+ {showOtp ? (<View style={styles.otpContainer}>
8
+ {message && <Text style={styles.inputLabel}>{message}</Text>}
9
+ <Text style={styles.inputLabel}>Enter OTP</Text>
10
+ <OTPInput length={6} onComplete={handleOTPComplete} onChangeOTP={handleOTPChange} autoFocus={true}/>
11
+ </View>) : (<View style={styles.otpContainer}>
12
+ <Text style={styles.inputLabel}>Enter PIN</Text>
13
+ <OTPInput length={4} onComplete={handleOTPComplete} onChangeOTP={handlePinChange} autoFocus={true} secureTextEntry={true}/>
14
+ </View>)}
15
+ </View>);
16
+ }
17
+ return (<View>
18
+ <View style={styles.inputGroup}>
19
+ <Text style={styles.inputLabel}>Card Number</Text>
20
+ <View style={styles.inputWrapper}>
21
+ <TextInput value={cardNumber} onChangeText={(text) => setCardNumber(formatCardNumber(text))} placeholder="0000 0000 0000 0000" maxLength={19} keyboardType="number-pad" style={styles.input}/>
22
+ <Ionicons name="card-outline" size={20} color="#9CA3AF" style={styles.inputIcon}/>
23
+ </View>
24
+ </View>
25
+
26
+ <View style={styles.row}>
27
+ <View style={styles.flex1}>
28
+ <Text style={styles.inputLabel}>Expiry Date</Text>
29
+ <TextInput value={expiryDate} onChangeText={(text) => setExpiryDate(formatExpiry(text))} placeholder="MM/YY" maxLength={5} keyboardType="number-pad" style={styles.input}/>
30
+ </View>
31
+ <View style={styles.flex1}>
32
+ <Text style={styles.inputLabel}>CVV</Text>
33
+ <TextInput value={cvv} onChangeText={(text) => setCvv(text.replace(/\D/g, "").slice(0, 3))} placeholder="123" maxLength={3} keyboardType="number-pad" secureTextEntry style={styles.input}/>
34
+ </View>
35
+ </View>
36
+
37
+ <View style={styles.secureBox}>
38
+ <Ionicons name="lock-closed" size={16} color="#6B7280"/>
39
+ <Text style={styles.secureText}>
40
+ Your payment is secured with 256-bit SSL encryption
41
+ </Text>
42
+ </View>
43
+ </View>);
44
+ }
45
+ const styles = StyleSheet.create({
46
+ overlay: {
47
+ flex: 1,
48
+ backgroundColor: "rgba(0,0,0,0.5)",
49
+ justifyContent: "center",
50
+ },
51
+ modalContainer: {
52
+ position: "relative",
53
+ width: "90%",
54
+ alignSelf: "center",
55
+ borderRadius: 20,
56
+ height: "80%",
57
+ backgroundColor: "white",
58
+ },
59
+ otpContainer: {
60
+ width: "100%",
61
+ marginHorizontal: "auto",
62
+ marginTop: 20,
63
+ marginBottom: 40,
64
+ },
65
+ header: {
66
+ backgroundColor: "#6B21A8",
67
+ padding: 16,
68
+ borderTopLeftRadius: 20,
69
+ borderTopRightRadius: 20,
70
+ },
71
+ pinWrapper: {
72
+ flexDirection: "row",
73
+ alignItems: "center",
74
+ },
75
+ eyeButton: {
76
+ paddingHorizontal: 10,
77
+ },
78
+ eyeText: {
79
+ color: "#007AFF",
80
+ },
81
+ headerTop: {
82
+ flexDirection: "row",
83
+ justifyContent: "space-between",
84
+ alignItems: "flex-start",
85
+ marginBottom: 16,
86
+ },
87
+ headerTitle: { color: "white", fontSize: 24, fontWeight: "bold" },
88
+ headerSubtitle: { color: "#E0E7FF", fontSize: 14, marginTop: 4 },
89
+ closeBtn: {
90
+ backgroundColor: "rgba(255,255,255,0.2)",
91
+ borderRadius: 999,
92
+ padding: 8,
93
+ },
94
+ amountBox: {
95
+ backgroundColor: "rgba(255,255,255,0.2)",
96
+ borderRadius: 12,
97
+ padding: 8,
98
+ },
99
+ amountLabel: { color: "#E0E7FF", fontSize: 12, marginBottom: 4 },
100
+ amountText: { color: "white", fontSize: 20, fontWeight: "bold" },
101
+ scrollContainer: { flex: 1, marginBottom: 16 },
102
+ body: {
103
+ padding: 24,
104
+ backgroundColor: "white",
105
+ borderBottomLeftRadius: 20,
106
+ borderBottomRightRadius: 20,
107
+ },
108
+ paymentMethodsContainer: {
109
+ flexDirection: "row",
110
+ marginBottom: 24,
111
+ backgroundColor: "#F3F4F6",
112
+ padding: 4,
113
+ borderRadius: 12,
114
+ },
115
+ paymentMethod: {
116
+ flex: 1,
117
+ flexDirection: "row",
118
+ alignItems: "center",
119
+ justifyContent: "center",
120
+ paddingVertical: 12,
121
+ borderRadius: 12,
122
+ marginHorizontal: 4,
123
+ },
124
+ paymentMethodSelected: { backgroundColor: "white" },
125
+ paymentMethodText: { fontSize: 14, color: "#4B5563", marginLeft: 8 },
126
+ paymentMethodTextSelected: { color: "#4F46E5", fontWeight: "600" },
127
+ inputGroup: { marginBottom: 16 },
128
+ inputLabel: {
129
+ fontSize: 14,
130
+ fontWeight: "500",
131
+ color: "#374151",
132
+ marginBottom: 6,
133
+ },
134
+ inputWrapper: { position: "relative" },
135
+ input: {
136
+ width: "100%",
137
+ paddingHorizontal: 16,
138
+ paddingVertical: 12,
139
+ borderWidth: 1,
140
+ borderColor: "#D1D5DB",
141
+ borderRadius: 12,
142
+ backgroundColor: "white",
143
+ },
144
+ inputIcon: { position: "absolute", right: 16, top: 14 },
145
+ row: { flexDirection: "row", gap: 16, marginBottom: 12 },
146
+ flex1: { flex: 1 },
147
+ secureBox: {
148
+ flexDirection: "row",
149
+ alignItems: "center",
150
+ backgroundColor: "#F9FAFB",
151
+ padding: 12,
152
+ borderRadius: 12,
153
+ gap: 8,
154
+ marginBottom: 16,
155
+ },
156
+ secureText: { fontSize: 12, color: "#4B5563", flex: 1 },
157
+ transferBox: {
158
+ backgroundColor: "#EFF6FF",
159
+ borderWidth: 1,
160
+ borderColor: "#BFDBFE",
161
+ borderRadius: 12,
162
+ padding: 8,
163
+ marginBottom: 8,
164
+ },
165
+ transferText: {
166
+ fontSize: 14,
167
+ color: "#1E3A8A",
168
+ fontWeight: "500",
169
+ marginBottom: 12,
170
+ },
171
+ transferDetail: {
172
+ backgroundColor: "white",
173
+ borderRadius: 12,
174
+ padding: 8,
175
+ marginBottom: 12,
176
+ },
177
+ transferLabel: { fontSize: 10, color: "#4B5563", marginBottom: 4 },
178
+ transferValue: { fontWeight: "600", color: "#111827" },
179
+ accountNumber: {
180
+ fontWeight: "600",
181
+ color: "#111827",
182
+ fontSize: 16,
183
+ letterSpacing: 2,
184
+ flex: 1,
185
+ },
186
+ transferNote: {
187
+ backgroundColor: "#FEF3C7",
188
+ borderWidth: 1,
189
+ borderColor: "#FDE68A",
190
+ borderRadius: 12,
191
+ padding: 8,
192
+ },
193
+ transferNoteText: { fontSize: 14, color: "#78350F" },
194
+ dropdown: {
195
+ width: "100%",
196
+ paddingHorizontal: 16,
197
+ paddingVertical: 12,
198
+ borderWidth: 1,
199
+ borderColor: "#D1D5DB",
200
+ borderRadius: 12,
201
+ flexDirection: "row",
202
+ justifyContent: "space-between",
203
+ alignItems: "center",
204
+ },
205
+ dropdownText: { color: "#111827" },
206
+ dropdownPlaceholder: { color: "#9CA3AF" },
207
+ dropdownList: {
208
+ marginTop: 8,
209
+ backgroundColor: "white",
210
+ borderWidth: 1,
211
+ borderColor: "#E5E7EB",
212
+ borderRadius: 12,
213
+ overflow: "hidden",
214
+ maxHeight: 240,
215
+ },
216
+ dropdownItem: {
217
+ paddingVertical: 12,
218
+ paddingHorizontal: 16,
219
+ borderBottomWidth: 1,
220
+ borderBottomColor: "#F3F4F6",
221
+ },
222
+ dropdownItemText: { color: "#111827" },
223
+ ussdContainer: {
224
+ backgroundColor: "#E0E7FF", // bg-indigo-50
225
+ borderWidth: 1,
226
+ borderColor: "#C7D2FE", // border-indigo-200
227
+ borderRadius: 12, // rounded-xl
228
+ padding: 16, // p-4
229
+ marginBottom: 16,
230
+ },
231
+ ussdTitle: {
232
+ fontSize: 14, // text-sm
233
+ color: "#1E3A8A", // text-indigo-900
234
+ fontWeight: "500", // font-medium
235
+ marginBottom: 12, // mb-3
236
+ },
237
+ ussdCodeContainer: {
238
+ backgroundColor: "white", // bg-white
239
+ borderRadius: 12, // rounded-xl
240
+ padding: 16, // p-4
241
+ marginBottom: 12, // mb-3
242
+ },
243
+ ussdCodeRow: {
244
+ flexDirection: "row",
245
+ justifyContent: "space-between",
246
+ alignItems: "center",
247
+ },
248
+ ussdCodeText: {
249
+ fontFamily: "monospace", // font-mono
250
+ fontSize: 16, // text-base
251
+ fontWeight: "700", // font-bold
252
+ color: "#111827", // text-gray-900
253
+ flex: 1,
254
+ },
255
+ ussdCopyBtn: {
256
+ padding: 8, // p-2
257
+ },
258
+ ussdStepsLabel: {
259
+ fontSize: 14, // text-sm
260
+ color: "#1E3A8A", // text-indigo-900
261
+ fontWeight: "600", // font-semibold
262
+ marginBottom: 8, // mb-2
263
+ },
264
+ ussdStepsText: {
265
+ fontSize: 14, // text-sm
266
+ color: "#1E40AF", // text-indigo-800
267
+ },
268
+ payButton: {
269
+ display: "flex",
270
+ flexDirection: "row",
271
+ justifyContent: "center",
272
+ gap: 8,
273
+ width: "100%",
274
+ paddingVertical: 16, // py-4
275
+ borderRadius: 12, // rounded-xl
276
+ marginTop: 8, // mt-2
277
+ alignItems: "center",
278
+ },
279
+ payButtonActive: {
280
+ backgroundColor: "#4F46E5", // bg-indigo-600
281
+ },
282
+ payButtonDisabled: {
283
+ backgroundColor: "#D1D5DB", // bg-gray-300
284
+ },
285
+ payButtonText: {
286
+ color: "white",
287
+ fontWeight: "600",
288
+ fontSize: 18, // text-lg
289
+ textAlign: "center",
290
+ },
291
+ footer: {
292
+ flexDirection: "row",
293
+ justifyContent: "center",
294
+ alignItems: "center",
295
+ marginTop: 8, // mt-2
296
+ gap: 8, // supported in RN 0.71+, acts like Tailwind gap-2
297
+ },
298
+ footerText: {
299
+ fontSize: 14, // text-sm
300
+ color: "#6B7280", // text-gray-500
301
+ },
302
+ });
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ interface PaystackCheckoutProps {
3
+ amount: number;
4
+ merchantName?: string;
5
+ onClose: () => void;
6
+ onSuccess?: (reference: string) => void;
7
+ }
8
+ export default function Checkout({ amount, merchantName, onClose, onSuccess, }: PaystackCheckoutProps): React.JSX.Element;
9
+ export {};