react-native-fpay 0.2.9 → 0.3.2

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 (120) hide show
  1. package/lib/module/FountainPayProvider.js +5 -1
  2. package/lib/module/FountainPayProvider.js.map +1 -1
  3. package/lib/module/core/api/index.js +22 -12
  4. package/lib/module/core/api/index.js.map +1 -1
  5. package/lib/module/engine/BLEReceiverService.js.map +1 -1
  6. package/lib/module/engine/FPEngine.js +24 -13
  7. package/lib/module/engine/FPEngine.js.map +1 -1
  8. package/lib/module/engine/useIsForeground.js +17 -0
  9. package/lib/module/engine/useIsForeground.js.map +1 -0
  10. package/lib/module/ui/components/AnimatedDots.js +68 -0
  11. package/lib/module/ui/components/AnimatedDots.js.map +1 -0
  12. package/lib/module/ui/components/ConfirmScreen.js +333 -0
  13. package/lib/module/ui/components/ConfirmScreen.js.map +1 -0
  14. package/lib/module/ui/modals/FPPaymentRequestModal.js +6 -8
  15. package/lib/module/ui/modals/FPPaymentRequestModal.js.map +1 -1
  16. package/lib/module/ui/modals/FPShell.js +7 -4
  17. package/lib/module/ui/modals/FPShell.js.map +1 -1
  18. package/lib/module/ui/screens/ReceiveScreen.js +379 -274
  19. package/lib/module/ui/screens/ReceiveScreen.js.map +1 -1
  20. package/lib/module/ui/screens/SendScreen.js +154 -45
  21. package/lib/module/ui/screens/SendScreen.js.map +1 -1
  22. package/lib/module/ui/screens/styles.js +89 -0
  23. package/lib/module/ui/screens/styles.js.map +1 -0
  24. package/lib/module/ui/screens/sub/receivePayment/Nfc/index.js +361 -0
  25. package/lib/module/ui/screens/sub/receivePayment/Nfc/index.js.map +1 -0
  26. package/lib/module/ui/screens/sub/receivePayment/Qr/index.js +338 -0
  27. package/lib/module/ui/screens/sub/receivePayment/Qr/index.js.map +1 -0
  28. package/lib/module/ui/screens/sub/receivePayment/Transfer/index.js +453 -0
  29. package/lib/module/ui/screens/sub/receivePayment/Transfer/index.js.map +1 -0
  30. package/lib/module/ui/screens/sub/{BluetoothSubScreen.js → sendPayment/BluetoothSubScreen.js} +25 -32
  31. package/lib/module/ui/screens/sub/sendPayment/BluetoothSubScreen.js.map +1 -0
  32. package/lib/module/ui/screens/sub/sendPayment/NFCSubScreen.js +354 -0
  33. package/lib/module/ui/screens/sub/sendPayment/NFCSubScreen.js.map +1 -0
  34. package/lib/module/ui/screens/sub/sendPayment/NQRSubScreen.js +440 -0
  35. package/lib/module/ui/screens/sub/sendPayment/NQRSubScreen.js.map +1 -0
  36. package/lib/module/ui/screens/sub/{ProximitySubScreen.js → sendPayment/ProximitySubScreen.js} +20 -111
  37. package/lib/module/ui/screens/sub/sendPayment/ProximitySubScreen.js.map +1 -0
  38. package/lib/module/ui/screens/sub/sendPayment/TransferSubScreen.js +327 -0
  39. package/lib/module/ui/screens/sub/sendPayment/TransferSubScreen.js.map +1 -0
  40. package/lib/typescript/src/FountainPayProvider.d.ts.map +1 -1
  41. package/lib/typescript/src/core/api/index.d.ts +20 -27
  42. package/lib/typescript/src/core/api/index.d.ts.map +1 -1
  43. package/lib/typescript/src/core/types/index.d.ts +56 -13
  44. package/lib/typescript/src/core/types/index.d.ts.map +1 -1
  45. package/lib/typescript/src/engine/BLEReceiverService.d.ts +2 -0
  46. package/lib/typescript/src/engine/BLEReceiverService.d.ts.map +1 -1
  47. package/lib/typescript/src/engine/FPEngine.d.ts +3 -1
  48. package/lib/typescript/src/engine/FPEngine.d.ts.map +1 -1
  49. package/lib/typescript/src/engine/useIsForeground.d.ts +2 -0
  50. package/lib/typescript/src/engine/useIsForeground.d.ts.map +1 -0
  51. package/lib/typescript/src/ui/components/AnimatedDots.d.ts +2 -0
  52. package/lib/typescript/src/ui/components/AnimatedDots.d.ts.map +1 -0
  53. package/lib/typescript/src/ui/components/ConfirmScreen.d.ts +10 -0
  54. package/lib/typescript/src/ui/components/ConfirmScreen.d.ts.map +1 -0
  55. package/lib/typescript/src/ui/components/OtpInput/Styles.d.ts +3 -3
  56. package/lib/typescript/src/ui/modals/FPPaymentRequestModal.d.ts.map +1 -1
  57. package/lib/typescript/src/ui/modals/FPShell.d.ts.map +1 -1
  58. package/lib/typescript/src/ui/screens/ReceiveScreen.d.ts +2 -9
  59. package/lib/typescript/src/ui/screens/ReceiveScreen.d.ts.map +1 -1
  60. package/lib/typescript/src/ui/screens/SendScreen.d.ts +4 -2
  61. package/lib/typescript/src/ui/screens/SendScreen.d.ts.map +1 -1
  62. package/lib/typescript/src/ui/screens/styles.d.ts +1390 -0
  63. package/lib/typescript/src/ui/screens/styles.d.ts.map +1 -0
  64. package/lib/typescript/src/ui/screens/sub/receivePayment/Nfc/index.d.ts +10 -0
  65. package/lib/typescript/src/ui/screens/sub/receivePayment/Nfc/index.d.ts.map +1 -0
  66. package/lib/typescript/src/ui/screens/sub/receivePayment/Qr/index.d.ts +10 -0
  67. package/lib/typescript/src/ui/screens/sub/receivePayment/Qr/index.d.ts.map +1 -0
  68. package/lib/typescript/src/ui/screens/sub/receivePayment/Transfer/index.d.ts +5 -0
  69. package/lib/typescript/src/ui/screens/sub/receivePayment/Transfer/index.d.ts.map +1 -0
  70. package/lib/typescript/src/ui/screens/sub/{BluetoothSubScreen.d.ts → sendPayment/BluetoothSubScreen.d.ts} +2 -11
  71. package/lib/typescript/src/ui/screens/sub/sendPayment/BluetoothSubScreen.d.ts.map +1 -0
  72. package/lib/typescript/src/ui/screens/sub/sendPayment/NFCSubScreen.d.ts +3 -0
  73. package/lib/typescript/src/ui/screens/sub/sendPayment/NFCSubScreen.d.ts.map +1 -0
  74. package/lib/typescript/src/ui/screens/sub/sendPayment/NQRSubScreen.d.ts +3 -0
  75. package/lib/typescript/src/ui/screens/sub/sendPayment/NQRSubScreen.d.ts.map +1 -0
  76. package/lib/typescript/src/ui/screens/sub/{ProximitySubScreen.d.ts → sendPayment/ProximitySubScreen.d.ts} +2 -10
  77. package/lib/typescript/src/ui/screens/sub/sendPayment/ProximitySubScreen.d.ts.map +1 -0
  78. package/lib/typescript/src/ui/screens/sub/sendPayment/TransferSubScreen.d.ts +3 -0
  79. package/lib/typescript/src/ui/screens/sub/sendPayment/TransferSubScreen.d.ts.map +1 -0
  80. package/package.json +1 -1
  81. package/src/FountainPayProvider.tsx +7 -1
  82. package/src/core/api/index.ts +34 -19
  83. package/src/core/types/index.ts +67 -13
  84. package/src/engine/BLEReceiverService.ts +2 -0
  85. package/src/engine/FPEngine.ts +29 -14
  86. package/src/engine/useIsForeground.ts +18 -0
  87. package/src/ui/components/AnimatedDots.tsx +81 -0
  88. package/src/ui/components/ConfirmScreen.tsx +421 -0
  89. package/src/ui/modals/FPPaymentRequestModal.tsx +7 -6
  90. package/src/ui/modals/FPShell.tsx +9 -9
  91. package/src/ui/screens/ReceiveScreen.tsx +266 -115
  92. package/src/ui/screens/SendScreen.tsx +141 -19
  93. package/src/ui/screens/styles.ts +101 -0
  94. package/src/ui/screens/sub/receivePayment/Nfc/index.tsx +418 -0
  95. package/src/ui/screens/sub/receivePayment/Qr/index.tsx +391 -0
  96. package/src/ui/screens/sub/receivePayment/Transfer/index.tsx +512 -0
  97. package/src/ui/screens/sub/{BluetoothSubScreen.tsx → sendPayment/BluetoothSubScreen.tsx} +27 -46
  98. package/src/ui/screens/sub/sendPayment/NFCSubScreen.tsx +302 -0
  99. package/src/ui/screens/sub/sendPayment/NQRSubScreen.tsx +490 -0
  100. package/src/ui/screens/sub/{ProximitySubScreen.tsx → sendPayment/ProximitySubScreen.tsx} +24 -44
  101. package/src/ui/screens/sub/sendPayment/TransferSubScreen.tsx +345 -0
  102. package/lib/module/ui/screens/sub/BluetoothSubScreen.js.map +0 -1
  103. package/lib/module/ui/screens/sub/NFCSubScreen.js +0 -164
  104. package/lib/module/ui/screens/sub/NFCSubScreen.js.map +0 -1
  105. package/lib/module/ui/screens/sub/NQRSubScreen.js +0 -131
  106. package/lib/module/ui/screens/sub/NQRSubScreen.js.map +0 -1
  107. package/lib/module/ui/screens/sub/ProximitySubScreen.js.map +0 -1
  108. package/lib/module/ui/screens/sub/TransferSubScreen.js +0 -353
  109. package/lib/module/ui/screens/sub/TransferSubScreen.js.map +0 -1
  110. package/lib/typescript/src/ui/screens/sub/BluetoothSubScreen.d.ts.map +0 -1
  111. package/lib/typescript/src/ui/screens/sub/NFCSubScreen.d.ts +0 -18
  112. package/lib/typescript/src/ui/screens/sub/NFCSubScreen.d.ts.map +0 -1
  113. package/lib/typescript/src/ui/screens/sub/NQRSubScreen.d.ts +0 -12
  114. package/lib/typescript/src/ui/screens/sub/NQRSubScreen.d.ts.map +0 -1
  115. package/lib/typescript/src/ui/screens/sub/ProximitySubScreen.d.ts.map +0 -1
  116. package/lib/typescript/src/ui/screens/sub/TransferSubScreen.d.ts +0 -11
  117. package/lib/typescript/src/ui/screens/sub/TransferSubScreen.d.ts.map +0 -1
  118. package/src/ui/screens/sub/NFCSubScreen.tsx +0 -86
  119. package/src/ui/screens/sub/NQRSubScreen.tsx +0 -62
  120. package/src/ui/screens/sub/TransferSubScreen.tsx +0 -147
@@ -1,147 +0,0 @@
1
- import React, { useState, useEffect } from 'react';
2
- import { View, Text, TextInput, FlatList, TouchableOpacity, StyleSheet, ActivityIndicator } from 'react-native';
3
- import { transferAPI } from '../../../core/api';
4
- import { FPButton } from '../../components/FPButton';
5
- import { C, R, S, F, shadow } from '../../theme';
6
- import type { FPCurrency, FPTransaction, FPError } from '../../../core/types';
7
-
8
- type Step = 'bank' | 'account' | 'confirm' | 'processing' | 'done';
9
-
10
- interface Props {
11
- amount: number;
12
- currency: FPCurrency;
13
- onDone: () => void;
14
- onSuccess?: (tx: FPTransaction) => void;
15
- onError?: (err: FPError) => void;
16
- }
17
-
18
- export function TransferSubScreen({ amount, currency, onDone, onSuccess, onError }: Props) {
19
- const [step, setStep] = useState<Step>('bank');
20
- const [banks, setBanks] = useState<{ name: string; code: string }[]>([]);
21
- const [search, setSearch] = useState('');
22
- const [selectedBank, setSelectedBank] = useState<{ name: string; code: string } | null>(null);
23
- const [accountNumber, setAccountNumber] = useState('');
24
- const [verifiedName, setVerifiedName] = useState('');
25
- const [isVerifying, setIsVerifying] = useState(false);
26
- const [narration, setNarration] = useState('');
27
- const [loading, setLoading] = useState(false);
28
- const [error, setError] = useState('');
29
-
30
- useEffect(() => { transferAPI.getBanks().then(setBanks).catch(() => {}); }, []);
31
-
32
- useEffect(() => {
33
- if (accountNumber.length === 10 && selectedBank) {
34
- setIsVerifying(true); setVerifiedName('');
35
- transferAPI.verifyAccount(accountNumber, selectedBank.code)
36
- .then(r => setVerifiedName(r.accountName))
37
- .catch(() => setVerifiedName(''))
38
- .finally(() => setIsVerifying(false));
39
- }
40
- }, [accountNumber, selectedBank]);
41
-
42
- const handleSend = async () => {
43
- if (!selectedBank || !verifiedName) return;
44
- setLoading(true); setStep('processing');
45
- try {
46
- const result = await transferAPI.send({ accountNumber, bankCode: selectedBank.code, amount: amount * 100, narration });
47
- onSuccess?.({ id: result.reference, reference: result.reference, type: 'debit', channel: 'transfer', amount: result.amount, currency: result.currency, status: result.status, recipient: { accountName: result.recipient.accountName }, createdAt: result.createdAt });
48
- setStep('done');
49
- } catch (err) {
50
- setError((err as FPError).message); setStep('confirm');
51
- onError?.(err as FPError);
52
- } finally { setLoading(false); }
53
- };
54
-
55
- const filtered = banks.filter(b => b.name.toLowerCase().includes(search.toLowerCase()));
56
-
57
- if (step === 'bank') return (
58
- <View style={st.wrap}>
59
- <Text style={st.title}>Select Bank</Text>
60
- <TextInput style={st.input} placeholder="Search..." value={search} onChangeText={setSearch} placeholderTextColor={C.ghost} />
61
- <FlatList data={filtered} keyExtractor={i => i.code}
62
- renderItem={({ item }) => (
63
- <TouchableOpacity style={st.bankRow} onPress={() => { setSelectedBank(item); setStep('account'); }}>
64
- <Text style={st.bankName}>{item.name}</Text><Text style={st.arrow}>{">"}</Text>
65
- </TouchableOpacity>
66
- )}
67
- ItemSeparatorComponent={() => <View style={{ height: 1, backgroundColor: C.border }} />}
68
- />
69
- </View>
70
- );
71
-
72
- if (step === 'account') return (
73
- <View style={st.wrap}>
74
- <TouchableOpacity onPress={() => setStep('bank')} style={st.back}><Text style={st.backText}>{selectedBank?.name}</Text></TouchableOpacity>
75
- <Text style={st.title}>Account Number</Text>
76
- <TextInput style={st.bigInput} placeholder="0000000000" value={accountNumber}
77
- onChangeText={v => setAccountNumber(v.replace(/[^0-9]/g, '').slice(0, 10))}
78
- keyboardType="number-pad" maxLength={10} placeholderTextColor={C.ghost} />
79
- {isVerifying && <ActivityIndicator color={C.brand} />}
80
- {verifiedName ? <View style={st.verified}><Text style={st.verifiedText}>Verified: {verifiedName}</Text></View> : null}
81
- <FPButton label="Continue" onPress={() => setStep('confirm')} disabled={!verifiedName} style={st.btn} />
82
- </View>
83
- );
84
-
85
- if (step === 'confirm') return (
86
- <View style={st.wrap}>
87
- <TouchableOpacity onPress={() => setStep('account')} style={st.back}><Text style={st.backText}>Back</Text></TouchableOpacity>
88
- <Text style={st.title}>Confirm Transfer</Text>
89
- <View style={st.card}>
90
- <Row label="Recipient" value={verifiedName} />
91
- <Row label="Bank" value={selectedBank?.name ?? ''} />
92
- <Row label="Account" value={accountNumber} />
93
- <Row label="Amount" value={currency + ' ' + amount.toLocaleString('en-NG', { minimumFractionDigits: 2 })} bold />
94
- </View>
95
- <TextInput style={st.input} placeholder="Add a note (optional)" value={narration} onChangeText={setNarration} placeholderTextColor={C.ghost} />
96
- {error ? <Text style={st.error}>{error}</Text> : null}
97
- <FPButton label="Send Money" onPress={handleSend} loading={loading} style={st.btn} />
98
- </View>
99
- );
100
-
101
- if (step === 'processing') return (
102
- <View style={[st.wrap, st.centered]}>
103
- <ActivityIndicator size="large" color={C.brand} />
104
- <Text style={st.title}>Sending...</Text>
105
- </View>
106
- );
107
-
108
- if (step === 'done') return (
109
- <View style={[st.wrap, st.centered]}>
110
- <View style={st.successCircle}><Text style={{ fontSize: 28, color: C.green }}>OK</Text></View>
111
- <Text style={st.title}>Sent!</Text>
112
- <Text style={st.sub}>{currency} {amount.toLocaleString()} to {verifiedName}</Text>
113
- <FPButton label="Done" onPress={onDone} style={st.btn} />
114
- </View>
115
- );
116
-
117
- return null;
118
- }
119
-
120
- function Row({ label, value, bold }: { label: string; value: string; bold?: boolean }) {
121
- return (
122
- <View style={{ flexDirection: 'row', justifyContent: 'space-between', paddingVertical: S.sm, borderBottomWidth: 1, borderBottomColor: C.border }}>
123
- <Text style={{ color: C.muted, fontSize: F.sm }}>{label}</Text>
124
- <Text style={{ color: C.ink, fontWeight: bold ? '800' : '600', fontSize: F.sm }}>{value}</Text>
125
- </View>
126
- );
127
- }
128
-
129
- const st = StyleSheet.create({
130
- wrap: { flex: 1, padding: S.lg },
131
- centered: { justifyContent: 'center', alignItems: 'center' },
132
- back: { marginBottom: S.md },
133
- backText: { color: C.brand, fontSize: F.md, fontWeight: '600' },
134
- title: { fontSize: F.xl, fontWeight: '800', color: C.ink, marginBottom: S.lg },
135
- input: { backgroundColor: C.surface, borderRadius: R.md, padding: S.md, fontSize: F.md, color: C.ink, borderWidth: 1, borderColor: C.border, marginBottom: S.md },
136
- bigInput: { backgroundColor: C.surface, borderRadius: R.md, padding: S.md, fontSize: 28, fontWeight: '800', color: C.ink, textAlign: 'center', letterSpacing: 3, borderWidth: 1, borderColor: C.border, marginBottom: S.md },
137
- verified: { backgroundColor: C.greenLight, borderRadius: R.md, padding: S.sm, marginBottom: S.md },
138
- verifiedText: { color: C.green, fontWeight: '700', fontSize: F.sm },
139
- btn: { marginTop: S.sm },
140
- bankRow: { flexDirection: 'row', justifyContent: 'space-between', paddingVertical: S.md, alignItems: 'center' },
141
- bankName: { fontSize: F.md, color: C.ink },
142
- arrow: { color: C.ghost, fontSize: F.lg },
143
- card: { backgroundColor: C.surface, borderRadius: R.lg, padding: S.md, marginBottom: S.md },
144
- error: { color: C.red, fontSize: F.sm, marginBottom: S.sm },
145
- successCircle: { width: 80, height: 80, borderRadius: 40, backgroundColor: C.greenLight, justifyContent: 'center', alignItems: 'center', marginBottom: S.lg },
146
- sub: { color: C.muted, fontSize: F.md, marginBottom: S.xl },
147
- });