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
@@ -0,0 +1,391 @@
1
+ import React, { useState, useEffect, useRef } from 'react';
2
+ import { View, Animated, Easing } from 'react-native';
3
+ import styled from 'styled-components/native';
4
+ import QRCode from 'react-native-qrcode-svg';
5
+ import Share from 'react-native-share';
6
+ import Ionicons from 'react-native-vector-icons/Ionicons';
7
+ import { AnimatedDots } from '../../../../components/AnimatedDots';
8
+
9
+ // Styled Components
10
+ const Container = styled.View`
11
+ flex: 1;
12
+ background-color: #f5f5f5;
13
+ padding-bottom: 60%;
14
+ `;
15
+
16
+ const Header = styled.View`
17
+ flex-direction: row;
18
+ align-items: center;
19
+ padding: 16px;
20
+ padding-top: 40px;
21
+ background-color: #ffffff;
22
+ border-bottom-width: 1px;
23
+ border-bottom-color: #e0e0e0;
24
+ `;
25
+
26
+ const BackButton = styled.TouchableOpacity`
27
+ padding: 8px;
28
+ `;
29
+
30
+ const BackIcon = styled.Text`
31
+ font-size: 24px;
32
+ color: #000000;
33
+ `;
34
+
35
+ const HeaderTitle = styled.Text`
36
+ flex: 1;
37
+ font-size: 18px;
38
+ font-weight: 600;
39
+ color: #000000;
40
+ text-align: center;
41
+ margin-right: 40px;
42
+ `;
43
+
44
+ const ScrollContainer = styled.ScrollView`
45
+ flex: 1;
46
+ `;
47
+
48
+ const ContentContainer = styled.View`
49
+ padding: 24px;
50
+ align-items: center;
51
+ `;
52
+
53
+ const AmountContainer = styled.View`
54
+ background-color: #ffffff;
55
+ border-radius: 16px;
56
+ padding: 24px;
57
+ width: 100%;
58
+ align-items: center;
59
+ margin-bottom: 24px;
60
+ shadow-color: #000;
61
+ shadow-offset: 0px 2px;
62
+ shadow-opacity: 0.05;
63
+ shadow-radius: 8px;
64
+ elevation: 3;
65
+ `;
66
+
67
+ const AmountLabel = styled.Text`
68
+ font-size: 14px;
69
+ color: #666666;
70
+ margin-bottom: 8px;
71
+ `;
72
+
73
+ const AmountText = styled.Text`
74
+ font-size: 36px;
75
+ font-weight: 700;
76
+ color: #0a3d2e;
77
+ margin-bottom: 8px;
78
+ `;
79
+
80
+ const DescriptionText = styled.Text`
81
+ font-size: 14px;
82
+ color: #999999;
83
+ font-style: italic;
84
+ `;
85
+
86
+ const QRContainer = styled.View`
87
+ background-color: #ffffff;
88
+ border-radius: 16px;
89
+ padding: 32px;
90
+ align-items: center;
91
+ margin-bottom: 24px;
92
+ shadow-color: #000;
93
+ shadow-offset: 0px 2px;
94
+ shadow-opacity: 0.05;
95
+ shadow-radius: 8px;
96
+ elevation: 3;
97
+ `;
98
+
99
+ const QRCodePlaceholder = styled.View`
100
+ width: 240px;
101
+ height: 240px;
102
+ background-color: #000000;
103
+ border-radius: 12px;
104
+ margin-bottom: 16px;
105
+ `;
106
+
107
+ const StatusContainer = styled.View`
108
+ align-items: center;
109
+ margin-bottom: 16px;
110
+ `;
111
+
112
+ const StatusText = styled.Text`
113
+ font-size: 16px;
114
+ color: #333333;
115
+ margin-bottom: 8px;
116
+ `;
117
+
118
+ const DotsContainer = styled.View`
119
+ flex-direction: row;
120
+ align-items: center;
121
+ `;
122
+
123
+ const Dot = styled(Animated.View)<{ delay: number }>`
124
+ width: 8px;
125
+ height: 8px;
126
+ border-radius: 4px;
127
+ background-color: #0a3d2e;
128
+ margin: 0 4px;
129
+ `;
130
+
131
+ const TimerContainer = styled.View`
132
+ background-color: #FFF3E0;
133
+ border-radius: 20px;
134
+ padding: 12px 20px;
135
+ margin-bottom: 24px;
136
+ `;
137
+
138
+ const TimerText = styled.Text`
139
+ font-size: 14px;
140
+ color: #F57C00;
141
+ font-weight: 600;
142
+ `;
143
+
144
+ const InfoBox = styled.View`
145
+ background-color: #E8F5F1;
146
+ border-radius: 12px;
147
+ padding: 16px;
148
+ width: 100%;
149
+ margin-bottom: 24px;
150
+ `;
151
+
152
+ const InfoText = styled.Text`
153
+ font-size: 13px;
154
+ color: #00A876;
155
+ line-height: 20px;
156
+ text-align: center;
157
+ `;
158
+
159
+ const ButtonRow = styled.View`
160
+ flex-direction: row;
161
+ width: 100%;
162
+ gap: 12px;
163
+ margin-bottom: 16px;
164
+ `;
165
+
166
+ const OutlineButton = styled.TouchableOpacity`
167
+ flex: 1;
168
+ background-color: #ffffff;
169
+ border: 1.5px solid #0a3d2e;
170
+ border-radius: 28px;
171
+ padding: 16px;
172
+ align-items: center;
173
+ `;
174
+
175
+ const OutlineButtonText = styled.Text`
176
+ font-size: 15px;
177
+ font-weight: 600;
178
+ color: #0a3d2e;
179
+ `;
180
+
181
+ const PrimaryButton = styled.TouchableOpacity`
182
+ flex: 1;
183
+ background-color: #0a3d2e;
184
+ border-radius: 28px;
185
+ padding: 16px;
186
+ align-items: center;
187
+ `;
188
+
189
+ const PrimaryButtonText = styled.Text`
190
+ font-size: 15px;
191
+ font-weight: 600;
192
+ color: #ffffff;
193
+ `;
194
+
195
+ const SecondaryButton = styled.TouchableOpacity`
196
+ background-color: #ffffff;
197
+ border: 1.5px solid #E0E0E0;
198
+ border-radius: 28px;
199
+ padding: 16px;
200
+ align-items: center;
201
+ width: 100%;
202
+ `;
203
+
204
+ const SecondaryButtonText = styled.Text`
205
+ font-size: 15px;
206
+ font-weight: 600;
207
+ color: #666666;
208
+ `;
209
+
210
+ const Footer = styled.View`
211
+ padding: 16px;
212
+ background-color: #ffffff;
213
+ border-top-width: 1px;
214
+ border-top-color: #e0e0e0;
215
+ `;
216
+
217
+ const FooterText = styled.Text`
218
+ font-size: 12px;
219
+ color: #999999;
220
+ text-align: center;
221
+ line-height: 18px;
222
+ `;
223
+
224
+
225
+ // Main Component
226
+ interface ReceiveQRCodeScreenProps {
227
+ amount: number;
228
+ description?: string;
229
+ onClose?: () => void;
230
+ onPaymentReceived?: (data: any) => void;
231
+ }
232
+
233
+ const Qr: React.FC<ReceiveQRCodeScreenProps> = ({
234
+ amount = 5000,
235
+ description = 'Payment request',
236
+ onClose,
237
+ onPaymentReceived,
238
+ }) => {
239
+ const [timeRemaining, setTimeRemaining] = useState(900); // 15 minutes in seconds
240
+ const [qrData, setQrData] = useState('');
241
+ const qrRef = useRef<any>(null);
242
+
243
+ useEffect(() => {
244
+ // Generate QR code data (would be actual payment data in production)
245
+ const paymentData = {
246
+ amount,
247
+ description,
248
+ timestamp: Date.now(),
249
+ recipient: 'USER_ID_12345',
250
+ };
251
+ setQrData(JSON.stringify(paymentData));
252
+ }, [amount, description]);
253
+
254
+ useEffect(() => {
255
+ // Countdown timer
256
+ const timer = setInterval(() => {
257
+ setTimeRemaining((prev) => {
258
+ if (prev <= 0) {
259
+ clearInterval(timer);
260
+ return 0;
261
+ }
262
+ return prev - 1;
263
+ });
264
+ }, 1000);
265
+
266
+ return () => clearInterval(timer);
267
+ }, []);
268
+
269
+ const formatTime = (seconds: number): string => {
270
+ const mins = Math.floor(seconds / 60);
271
+ const secs = seconds % 60;
272
+ return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
273
+ };
274
+
275
+ const handleShare = async () => {
276
+ try {
277
+ if (!qrRef.current) return;
278
+
279
+ qrRef.current.toDataURL(async (data: string) => {
280
+ const shareOptions = {
281
+ title: 'Payment Request',
282
+ message: `Please pay ₦${amount.toLocaleString()} for ${description}.`,
283
+ url: `data:image/png;base64,${data}`, // 👈 QR image
284
+ type: 'image/png',
285
+ };
286
+
287
+ await Share.open(shareOptions);
288
+ });
289
+ } catch (error) {
290
+ console.error('Error sharing QR:', error);
291
+ }
292
+ };
293
+
294
+
295
+ const handleRefresh = () => {
296
+ setTimeRemaining(900);
297
+ const paymentData = {
298
+ amount,
299
+ description,
300
+ direct: true,
301
+ timestamp: Date.now(),
302
+ recipient: 'USER_ID_12345',
303
+ };
304
+ setQrData(JSON.stringify(paymentData));
305
+ };
306
+
307
+ const formatAmount = (value: number): string => {
308
+ return value.toLocaleString('en-NG', {
309
+ minimumFractionDigits: 2,
310
+ maximumFractionDigits: 2,
311
+ });
312
+ };
313
+
314
+ return (
315
+ <Container>
316
+ {/* Header */}
317
+ <Header>
318
+ <BackButton onPress={onClose}>
319
+ <Ionicons name="close" size={24} />
320
+ </BackButton>
321
+ <HeaderTitle>Receive via QR Code</HeaderTitle>
322
+ </Header>
323
+
324
+ {/* Content */}
325
+ <ScrollContainer showsVerticalScrollIndicator={false}>
326
+ <ContentContainer>
327
+
328
+ {/* QR Code */}
329
+ <QRContainer>
330
+ <QRCodePlaceholder>
331
+ {/* In production, replace with actual QR code library */}
332
+ {/* <QRCode value={qrData} size={240} /> */}
333
+ {qrData && (<QRCode
334
+ value={qrData}
335
+ size={240}
336
+ // logo={{uri: LOGO_DATA}}
337
+ logoSize={60}
338
+ logoBackgroundColor='transparent'
339
+ enableLinearGradient={true}
340
+ logoBorderRadius={30}
341
+ getRef={(c) => (qrRef.current = c)}
342
+ />)}
343
+ </QRCodePlaceholder>
344
+
345
+ <StatusContainer>
346
+ <StatusText>Waiting for payment of ₦{formatAmount(amount)}</StatusText>
347
+ <AnimatedDots />
348
+ </StatusContainer>
349
+ </QRContainer>
350
+
351
+ {/* Timer */}
352
+ <TimerContainer>
353
+ <TimerText>Valid for: {formatTime(timeRemaining)} mins</TimerText>
354
+ </TimerContainer>
355
+
356
+ {/* Info Box */}
357
+ <InfoBox>
358
+ <InfoText>
359
+ Ask the payer to scan this QR code with their camera or payment
360
+ app to complete the transaction
361
+ </InfoText>
362
+ </InfoBox>
363
+
364
+ {/* Action Buttons */}
365
+ <ButtonRow>
366
+ <OutlineButton onPress={handleShare}>
367
+ <OutlineButtonText>Share QR</OutlineButtonText>
368
+ </OutlineButton>
369
+ <PrimaryButton onPress={handleRefresh}>
370
+ <PrimaryButtonText>Refresh</PrimaryButtonText>
371
+ </PrimaryButton>
372
+ </ButtonRow>
373
+
374
+ <SecondaryButton onPress={onClose}>
375
+ <SecondaryButtonText>Cancel Request</SecondaryButtonText>
376
+ </SecondaryButton>
377
+ </ContentContainer>
378
+ </ScrollContainer>
379
+
380
+ {/* Footer */}
381
+ <Footer>
382
+ <FooterText>
383
+ The payment will be automatically credited to your account once the
384
+ payer scans and confirms
385
+ </FooterText>
386
+ </Footer>
387
+ </Container>
388
+ );
389
+ };
390
+
391
+ export default Qr;