react-native-fpay 0.4.20 → 0.4.21

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 (62) hide show
  1. package/lib/module/FountainPayProvider.js +50 -126
  2. package/lib/module/FountainPayProvider.js.map +1 -1
  3. package/lib/module/core/api/client.js +1 -1
  4. package/lib/module/core/api/index.js +16 -13
  5. package/lib/module/core/api/index.js.map +1 -1
  6. package/lib/module/core/types/index.js +1 -1
  7. package/lib/module/core/types/index.js.map +1 -1
  8. package/lib/module/engine/FPEngine.js +27 -17
  9. package/lib/module/engine/FPEngine.js.map +1 -1
  10. package/lib/module/store/FPStore.js +11 -4
  11. package/lib/module/store/FPStore.js.map +1 -1
  12. package/lib/module/ui/components/ConfirmScreen.js +2 -2
  13. package/lib/module/ui/components/ConfirmScreen.js.map +1 -1
  14. package/lib/module/ui/modals/FPCreatePin.js +234 -0
  15. package/lib/module/ui/modals/FPCreatePin.js.map +1 -0
  16. package/lib/module/ui/modals/FPShell.js +7 -3
  17. package/lib/module/ui/modals/FPShell.js.map +1 -1
  18. package/lib/module/ui/modals/FPValidateBvn.js +258 -0
  19. package/lib/module/ui/modals/FPValidateBvn.js.map +1 -0
  20. package/lib/module/ui/screens/ResultScreen.js +4 -17
  21. package/lib/module/ui/screens/ResultScreen.js.map +1 -1
  22. package/lib/module/ui/screens/SendScreen.js +24 -9
  23. package/lib/module/ui/screens/SendScreen.js.map +1 -1
  24. package/lib/module/ui/screens/sub/sendPayment/ProximitySubScreen.js +3 -3
  25. package/lib/module/ui/screens/sub/sendPayment/ProximitySubScreen.js.map +1 -1
  26. package/lib/module/ui/screens/sub/sendPayment/TransferSubScreen.js +8 -1
  27. package/lib/module/ui/screens/sub/sendPayment/TransferSubScreen.js.map +1 -1
  28. package/lib/typescript/src/FountainPayProvider.d.ts +3 -4
  29. package/lib/typescript/src/FountainPayProvider.d.ts.map +1 -1
  30. package/lib/typescript/src/core/api/index.d.ts +20 -21
  31. package/lib/typescript/src/core/api/index.d.ts.map +1 -1
  32. package/lib/typescript/src/core/types/index.d.ts +16 -6
  33. package/lib/typescript/src/core/types/index.d.ts.map +1 -1
  34. package/lib/typescript/src/engine/FPEngine.d.ts +3 -0
  35. package/lib/typescript/src/engine/FPEngine.d.ts.map +1 -1
  36. package/lib/typescript/src/store/FPStore.d.ts +8 -5
  37. package/lib/typescript/src/store/FPStore.d.ts.map +1 -1
  38. package/lib/typescript/src/ui/components/ConfirmScreen.d.ts +1 -2
  39. package/lib/typescript/src/ui/components/ConfirmScreen.d.ts.map +1 -1
  40. package/lib/typescript/src/ui/modals/FPCreatePin.d.ts +3 -0
  41. package/lib/typescript/src/ui/modals/FPCreatePin.d.ts.map +1 -0
  42. package/lib/typescript/src/ui/modals/FPShell.d.ts.map +1 -1
  43. package/lib/typescript/src/ui/modals/FPValidateBvn.d.ts +3 -0
  44. package/lib/typescript/src/ui/modals/FPValidateBvn.d.ts.map +1 -0
  45. package/lib/typescript/src/ui/screens/ResultScreen.d.ts.map +1 -1
  46. package/lib/typescript/src/ui/screens/SendScreen.d.ts.map +1 -1
  47. package/lib/typescript/src/ui/screens/sub/sendPayment/TransferSubScreen.d.ts.map +1 -1
  48. package/package.json +1 -1
  49. package/src/FountainPayProvider.tsx +59 -149
  50. package/src/core/api/client.ts +1 -1
  51. package/src/core/api/index.ts +54 -54
  52. package/src/core/types/index.ts +18 -5
  53. package/src/engine/FPEngine.ts +33 -20
  54. package/src/store/FPStore.ts +15 -8
  55. package/src/ui/components/ConfirmScreen.tsx +4 -3
  56. package/src/ui/modals/FPCreatePin.tsx +206 -0
  57. package/src/ui/modals/FPShell.tsx +16 -2
  58. package/src/ui/modals/FPValidateBvn.tsx +229 -0
  59. package/src/ui/screens/ResultScreen.tsx +6 -10
  60. package/src/ui/screens/SendScreen.tsx +60 -36
  61. package/src/ui/screens/sub/sendPayment/ProximitySubScreen.tsx +3 -3
  62. package/src/ui/screens/sub/sendPayment/TransferSubScreen.tsx +7 -1
@@ -25,6 +25,7 @@ import type {
25
25
  FPUserInfo,
26
26
  FPTransferRecipient,
27
27
  FPSendWalletPaymentRequest,
28
+ FPInternalTransferRecipient,
28
29
  } from '../../core/types';
29
30
  import styled from 'styled-components/native';
30
31
  import Ionicons from 'react-native-vector-icons/Ionicons';
@@ -339,51 +340,74 @@ const SendScreen = ({
339
340
  };
340
341
 
341
342
  const handleProcessingTransaction = async (temptId: string) => {
342
- console.log('Got in here for processing');
343
343
  try {
344
- setLoading(true);
345
- setShowConfirmationModal(false);
346
- let response: any = null;
347
- switch (transactionPayload?.channel) {
348
- case 'transfer':
349
- case 'bluetooth':
350
- case 'proximity':
351
- if ('isBank' in transactionPayload && transactionPayload.isBank) {
352
- response = (await transferAPI.sendToBank(
353
- transactionPayload as FPSendPaymentRequest,
354
- temptId
355
- )) || null;
356
- } else {
357
- response = (await transferAPI.sendToWallet(
358
- transactionPayload as FPSendWalletPaymentRequest,
359
- temptId
360
- )) || null;
361
- }
362
- break;
363
- case 'nqr':
364
- response = await nqrAPI.pay(
344
+ setLoading(true);
345
+ setShowConfirmationModal(false);
346
+ let response: any = null;
347
+
348
+ const recipient = transactionPayload?.recipient as any;
349
+
350
+ switch (transactionPayload?.channel) {
351
+ case 'transfer':
352
+ case 'bluetooth':
353
+ case 'proximity': {
354
+ // Internal transfer — recipient has id + type (AGENT/TERMINAL)
355
+ if (recipient?.id && recipient?.type && ['AGENT', 'TERMINAL'].includes(recipient.type)) {
356
+ response = await transferAPI.sendToWallet(
365
357
  {
366
358
  ...transactionPayload,
367
- sender: user ?? undefined,
368
- narration: `Send ${formatted} to ${transactionPayload.recipient.accountName}`,
359
+ recipient: {
360
+ agent_id: recipient.id,
361
+ type: recipient.type,
362
+ },
369
363
  },
370
364
  temptId
371
365
  );
372
- break;
373
- case 'nfc':
374
- response = await nfcAPI.pay(
375
- {
376
- ...transactionPayload,
377
- sender: user ?? undefined,
378
- narration: `Send ${formatted} to ${transactionPayload.recipient.accountName}`,
379
- },
366
+ }
367
+ // Bank transfer — recipient has accountNumber + bankCode
368
+ else if (recipient?.bankCode) {
369
+ response = await transferAPI.sendToBank(
370
+ transactionPayload as FPSendPaymentRequest,
371
+ temptId
372
+ );
373
+ }
374
+ // Wallet transfer — recipient has accountNumber + userId/agentId
375
+ else {
376
+ response = await transferAPI.sendToWallet(
377
+ transactionPayload as FPSendWalletPaymentRequest,
380
378
  temptId
381
379
  );
382
- break;
383
- default:
384
- onError?.({ message: 'Invalid channel' } as FPError);
385
- break;
380
+ }
381
+ break;
386
382
  }
383
+
384
+ case 'nqr':
385
+ response = await nqrAPI.pay(
386
+ {
387
+ ...transactionPayload,
388
+ sender: user ?? undefined,
389
+ narration: `Send ${formatted} to ${recipient?.accountName ?? ''}`,
390
+ },
391
+ temptId
392
+ );
393
+ break;
394
+
395
+ case 'nfc':
396
+ response = await nfcAPI.pay(
397
+ {
398
+ ...transactionPayload,
399
+ sender: user ?? undefined,
400
+ narration: `Send ${formatted} to ${recipient?.accountName ?? ''}`,
401
+ },
402
+ temptId
403
+ );
404
+ break;
405
+
406
+ default:
407
+ onError?.({ message: 'Invalid channel' } as FPError);
408
+ return;
409
+ }
410
+
387
411
 
388
412
  if (!response?.status) {
389
413
  // Show failed result screen
@@ -266,14 +266,14 @@ export function ProximitySubScreen({
266
266
  sender_type: 'USER',
267
267
  recipient: {
268
268
  accountNumber: selected.accountNumber || '',
269
- type: selected.userType === 'VIRTUAL_ACCOUNT_USER' ? 'USER' : 'AGENT',
269
+ type: selected.userType === 'AGENT' ? 'USER' : 'AGENT',
270
270
  accountName: selected.displayName || '',
271
271
  agentId:
272
- selected.userType === 'VIRTUAL_ACCOUNT_USER'
272
+ selected.userType === 'AGENT'
273
273
  ? undefined
274
274
  : selected.userId,
275
275
  userId:
276
- selected.userType === 'VIRTUAL_ACCOUNT_USER'
276
+ selected.userType === 'AGENT'
277
277
  ? selected.userId
278
278
  : undefined,
279
279
  },
@@ -186,6 +186,7 @@ export function TransferSubScreen({
186
186
  const [isVerifying, setIsVerifying] = useState<boolean>(false);
187
187
 
188
188
  const [showBankList, setShowBankList] = useState<boolean>(false);
189
+ const user = getFPStore().user
189
190
 
190
191
  const [banks, setBanks] = useState<any>(getFPStore().banks);
191
192
  const [filteredBanks, setFilteredBanks] = useState<any>([]);
@@ -218,6 +219,8 @@ export function TransferSubScreen({
218
219
  if (!accountDetail) return;
219
220
 
220
221
  try {
222
+
223
+
221
224
  const base = {
222
225
  recipient: accountDetail,
223
226
  amount: Number(amount), // keep as number — host app converts if needed
@@ -228,10 +231,13 @@ export function TransferSubScreen({
228
231
  };
229
232
 
230
233
  if (!isBank) {
234
+ const recipient = {...base.recipient, id: base.recipient.ownerId};
235
+ delete recipient.ownerId;
231
236
  onProcessTransaction?.({
232
237
  ...base,
233
238
  sender_id: getFPStore().psspId ?? '',
234
- sender_type: 'USER' as const,
239
+ sender_type: user?.type,
240
+ recipient,
235
241
  });
236
242
  } else if (isBank && bank) {
237
243
  onProcessTransaction?.({