@swichpay/react-native 0.0.0-stage → 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 (277) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/LICENSE +21 -0
  3. package/README.md +82 -2
  4. package/docs/checkouts.md +98 -0
  5. package/docs/getting-started.md +140 -0
  6. package/docs/going-live.md +45 -0
  7. package/docs/own-screen.md +81 -0
  8. package/docs/results-and-errors.md +75 -0
  9. package/docs/server.md +163 -0
  10. package/docs/troubleshooting.md +57 -0
  11. package/lib/commonjs/HostedCheckout.js +115 -0
  12. package/lib/commonjs/checkout-webview.js +85 -0
  13. package/lib/commonjs/checkouts/PaymentSheet.js +1317 -0
  14. package/lib/commonjs/checkouts/direct.js +671 -0
  15. package/lib/commonjs/context.js +64 -0
  16. package/lib/commonjs/core/api/direct-payment-api.js +425 -0
  17. package/lib/commonjs/core/api/discount-api.js +19 -0
  18. package/lib/commonjs/core/api/gateway-api.js +366 -0
  19. package/lib/commonjs/core/api/payments-api.js +79 -0
  20. package/lib/commonjs/core/api/repositories.js +5 -0
  21. package/lib/commonjs/core/assets/images.js +12 -0
  22. package/lib/commonjs/core/assets/method-logos.js +19 -0
  23. package/lib/commonjs/core/assets/pwa-images.js +13 -0
  24. package/lib/commonjs/core/browser/clipboard.js +30 -0
  25. package/lib/commonjs/core/browser/dom.js +71 -0
  26. package/lib/commonjs/core/browser/hosted-checkout.js +107 -0
  27. package/lib/commonjs/core/browser/index.js +119 -0
  28. package/lib/commonjs/core/browser/qr.js +109 -0
  29. package/lib/commonjs/core/browser/three-ds.js +151 -0
  30. package/lib/commonjs/core/client.js +344 -0
  31. package/lib/commonjs/core/config.js +132 -0
  32. package/lib/commonjs/core/environment.js +34 -0
  33. package/lib/commonjs/core/errors.js +138 -0
  34. package/lib/commonjs/core/events.js +57 -0
  35. package/lib/commonjs/core/flows/controller.js +106 -0
  36. package/lib/commonjs/core/flows/countdown.js +41 -0
  37. package/lib/commonjs/core/flows/direct-bank-transfer.js +236 -0
  38. package/lib/commonjs/core/flows/direct-card.js +354 -0
  39. package/lib/commonjs/core/flows/direct-ewallet.js +124 -0
  40. package/lib/commonjs/core/flows/direct-one-bill.js +172 -0
  41. package/lib/commonjs/core/flows/direct-qr.js +109 -0
  42. package/lib/commonjs/core/flows/direct-rtp.js +302 -0
  43. package/lib/commonjs/core/flows/discount-lookup.js +80 -0
  44. package/lib/commonjs/core/flows/headless.js +94 -0
  45. package/lib/commonjs/core/flows/payment-sheet.js +1321 -0
  46. package/lib/commonjs/core/flows/services.js +31 -0
  47. package/lib/commonjs/core/flows/shared.js +90 -0
  48. package/lib/commonjs/core/http/api-client.js +208 -0
  49. package/lib/commonjs/core/http/endpoints.js +61 -0
  50. package/lib/commonjs/core/http/token-manager.js +46 -0
  51. package/lib/commonjs/core/http/transport.js +134 -0
  52. package/lib/commonjs/core/index.js +688 -0
  53. package/lib/commonjs/core/models/category.js +113 -0
  54. package/lib/commonjs/core/models/discount.js +51 -0
  55. package/lib/commonjs/core/models/payment.js +95 -0
  56. package/lib/commonjs/core/models/session.js +131 -0
  57. package/lib/commonjs/core/server/index.js +64 -0
  58. package/lib/commonjs/core/server/node.js +60 -0
  59. package/lib/commonjs/core/server/proxy.js +194 -0
  60. package/lib/commonjs/core/server/verify.js +122 -0
  61. package/lib/commonjs/core/swichpay.js +72 -0
  62. package/lib/commonjs/core/utils/crypto.js +78 -0
  63. package/lib/commonjs/core/utils/formatters.js +68 -0
  64. package/lib/commonjs/core/utils/json.js +110 -0
  65. package/lib/commonjs/core/utils/log.js +75 -0
  66. package/lib/commonjs/core/utils/runtime.js +34 -0
  67. package/lib/commonjs/core/utils/validators.js +59 -0
  68. package/lib/commonjs/hooks.js +77 -0
  69. package/lib/commonjs/index.js +203 -0
  70. package/lib/commonjs/package.json +1 -0
  71. package/lib/commonjs/polyfills.js +3 -0
  72. package/lib/commonjs/presenter.js +61 -0
  73. package/lib/commonjs/provider.js +192 -0
  74. package/lib/commonjs/swichpay.js +192 -0
  75. package/lib/commonjs/theme.js +54 -0
  76. package/lib/commonjs/ui.js +1142 -0
  77. package/lib/commonjs/webviews.js +279 -0
  78. package/lib/module/HostedCheckout.js +111 -0
  79. package/lib/module/checkout-webview.js +83 -0
  80. package/lib/module/checkouts/PaymentSheet.js +1313 -0
  81. package/lib/module/checkouts/direct.js +661 -0
  82. package/lib/module/context.js +58 -0
  83. package/lib/module/core/api/direct-payment-api.js +413 -0
  84. package/lib/module/core/api/discount-api.js +14 -0
  85. package/lib/module/core/api/gateway-api.js +358 -0
  86. package/lib/module/core/api/payments-api.js +73 -0
  87. package/lib/module/core/api/repositories.js +3 -0
  88. package/lib/module/core/assets/images.js +8 -0
  89. package/lib/module/core/assets/method-logos.js +15 -0
  90. package/lib/module/core/assets/pwa-images.js +9 -0
  91. package/lib/module/core/browser/clipboard.js +27 -0
  92. package/lib/module/core/browser/dom.js +63 -0
  93. package/lib/module/core/browser/hosted-checkout.js +102 -0
  94. package/lib/module/core/browser/index.js +12 -0
  95. package/lib/module/core/browser/qr.js +100 -0
  96. package/lib/module/core/browser/three-ds.js +145 -0
  97. package/lib/module/core/client.js +338 -0
  98. package/lib/module/core/config.js +128 -0
  99. package/lib/module/core/environment.js +29 -0
  100. package/lib/module/core/errors.js +125 -0
  101. package/lib/module/core/events.js +51 -0
  102. package/lib/module/core/flows/controller.js +101 -0
  103. package/lib/module/core/flows/countdown.js +36 -0
  104. package/lib/module/core/flows/direct-bank-transfer.js +231 -0
  105. package/lib/module/core/flows/direct-card.js +349 -0
  106. package/lib/module/core/flows/direct-ewallet.js +119 -0
  107. package/lib/module/core/flows/direct-one-bill.js +167 -0
  108. package/lib/module/core/flows/direct-qr.js +104 -0
  109. package/lib/module/core/flows/direct-rtp.js +297 -0
  110. package/lib/module/core/flows/discount-lookup.js +75 -0
  111. package/lib/module/core/flows/headless.js +90 -0
  112. package/lib/module/core/flows/payment-sheet.js +1315 -0
  113. package/lib/module/core/flows/services.js +27 -0
  114. package/lib/module/core/flows/shared.js +78 -0
  115. package/lib/module/core/http/api-client.js +203 -0
  116. package/lib/module/core/http/endpoints.js +57 -0
  117. package/lib/module/core/http/token-manager.js +41 -0
  118. package/lib/module/core/http/transport.js +126 -0
  119. package/lib/module/core/index.js +52 -0
  120. package/lib/module/core/models/category.js +104 -0
  121. package/lib/module/core/models/discount.js +46 -0
  122. package/lib/module/core/models/payment.js +89 -0
  123. package/lib/module/core/models/session.js +120 -0
  124. package/lib/module/core/server/index.js +11 -0
  125. package/lib/module/core/server/node.js +56 -0
  126. package/lib/module/core/server/proxy.js +191 -0
  127. package/lib/module/core/server/verify.js +115 -0
  128. package/lib/module/core/swichpay.js +68 -0
  129. package/lib/module/core/utils/crypto.js +72 -0
  130. package/lib/module/core/utils/formatters.js +56 -0
  131. package/lib/module/core/utils/json.js +94 -0
  132. package/lib/module/core/utils/log.js +67 -0
  133. package/lib/module/core/utils/runtime.js +28 -0
  134. package/lib/module/core/utils/validators.js +54 -0
  135. package/lib/module/hooks.js +72 -0
  136. package/lib/module/index.js +36 -0
  137. package/lib/module/polyfills.js +4 -0
  138. package/lib/module/presenter.js +58 -0
  139. package/lib/module/provider.js +188 -0
  140. package/lib/module/swichpay.js +187 -0
  141. package/lib/module/theme.js +50 -0
  142. package/lib/module/ui.js +1116 -0
  143. package/lib/module/webviews.js +272 -0
  144. package/lib/typescript/commonjs/HostedCheckout.d.ts +17 -0
  145. package/lib/typescript/commonjs/checkout-webview.d.ts +14 -0
  146. package/lib/typescript/commonjs/checkouts/PaymentSheet.d.ts +14 -0
  147. package/lib/typescript/commonjs/checkouts/direct.d.ts +18 -0
  148. package/lib/typescript/commonjs/context.d.ts +20 -0
  149. package/lib/typescript/commonjs/core/api/direct-payment-api.d.ts +103 -0
  150. package/lib/typescript/commonjs/core/api/discount-api.d.ts +10 -0
  151. package/lib/typescript/commonjs/core/api/gateway-api.d.ts +150 -0
  152. package/lib/typescript/commonjs/core/api/payments-api.d.ts +22 -0
  153. package/lib/typescript/commonjs/core/api/repositories.d.ts +86 -0
  154. package/lib/typescript/commonjs/core/assets/images.d.ts +5 -0
  155. package/lib/typescript/commonjs/core/assets/method-logos.d.ts +12 -0
  156. package/lib/typescript/commonjs/core/assets/pwa-images.d.ts +7 -0
  157. package/lib/typescript/commonjs/core/browser/clipboard.d.ts +3 -0
  158. package/lib/typescript/commonjs/core/browser/dom.d.ts +11 -0
  159. package/lib/typescript/commonjs/core/browser/hosted-checkout.d.ts +27 -0
  160. package/lib/typescript/commonjs/core/browser/index.d.ts +11 -0
  161. package/lib/typescript/commonjs/core/browser/qr.d.ts +18 -0
  162. package/lib/typescript/commonjs/core/browser/three-ds.d.ts +45 -0
  163. package/lib/typescript/commonjs/core/client.d.ts +181 -0
  164. package/lib/typescript/commonjs/core/config.d.ts +86 -0
  165. package/lib/typescript/commonjs/core/environment.d.ts +22 -0
  166. package/lib/typescript/commonjs/core/errors.d.ts +78 -0
  167. package/lib/typescript/commonjs/core/events.d.ts +19 -0
  168. package/lib/typescript/commonjs/core/flows/controller.d.ts +41 -0
  169. package/lib/typescript/commonjs/core/flows/countdown.d.ts +15 -0
  170. package/lib/typescript/commonjs/core/flows/direct-bank-transfer.d.ts +49 -0
  171. package/lib/typescript/commonjs/core/flows/direct-card.d.ts +94 -0
  172. package/lib/typescript/commonjs/core/flows/direct-ewallet.d.ts +39 -0
  173. package/lib/typescript/commonjs/core/flows/direct-one-bill.d.ts +38 -0
  174. package/lib/typescript/commonjs/core/flows/direct-qr.d.ts +25 -0
  175. package/lib/typescript/commonjs/core/flows/direct-rtp.d.ts +72 -0
  176. package/lib/typescript/commonjs/core/flows/discount-lookup.d.ts +37 -0
  177. package/lib/typescript/commonjs/core/flows/headless.d.ts +38 -0
  178. package/lib/typescript/commonjs/core/flows/payment-sheet.d.ts +263 -0
  179. package/lib/typescript/commonjs/core/flows/services.d.ts +22 -0
  180. package/lib/typescript/commonjs/core/flows/shared.d.ts +40 -0
  181. package/lib/typescript/commonjs/core/http/api-client.d.ts +37 -0
  182. package/lib/typescript/commonjs/core/http/endpoints.d.ts +39 -0
  183. package/lib/typescript/commonjs/core/http/token-manager.d.ts +19 -0
  184. package/lib/typescript/commonjs/core/http/transport.d.ts +37 -0
  185. package/lib/typescript/commonjs/core/index.d.ts +42 -0
  186. package/lib/typescript/commonjs/core/models/category.d.ts +35 -0
  187. package/lib/typescript/commonjs/core/models/discount.d.ts +41 -0
  188. package/lib/typescript/commonjs/core/models/payment.d.ts +104 -0
  189. package/lib/typescript/commonjs/core/models/session.d.ts +87 -0
  190. package/lib/typescript/commonjs/core/server/index.d.ts +10 -0
  191. package/lib/typescript/commonjs/core/server/node.d.ts +19 -0
  192. package/lib/typescript/commonjs/core/server/proxy.d.ts +30 -0
  193. package/lib/typescript/commonjs/core/server/verify.d.ts +61 -0
  194. package/lib/typescript/commonjs/core/swichpay.d.ts +40 -0
  195. package/lib/typescript/commonjs/core/utils/crypto.d.ts +19 -0
  196. package/lib/typescript/commonjs/core/utils/formatters.d.ts +19 -0
  197. package/lib/typescript/commonjs/core/utils/json.d.ts +27 -0
  198. package/lib/typescript/commonjs/core/utils/log.d.ts +15 -0
  199. package/lib/typescript/commonjs/core/utils/runtime.d.ts +12 -0
  200. package/lib/typescript/commonjs/core/utils/validators.d.ts +23 -0
  201. package/lib/typescript/commonjs/hooks.d.ts +21 -0
  202. package/lib/typescript/commonjs/index.d.ts +26 -0
  203. package/lib/typescript/commonjs/package.json +1 -0
  204. package/lib/typescript/commonjs/polyfills.d.ts +2 -0
  205. package/lib/typescript/commonjs/presenter.d.ts +25 -0
  206. package/lib/typescript/commonjs/provider.d.ts +22 -0
  207. package/lib/typescript/commonjs/swichpay.d.ts +125 -0
  208. package/lib/typescript/commonjs/theme.d.ts +52 -0
  209. package/lib/typescript/commonjs/ui.d.ts +583 -0
  210. package/lib/typescript/commonjs/webviews.d.ts +40 -0
  211. package/lib/typescript/module/HostedCheckout.d.ts +17 -0
  212. package/lib/typescript/module/checkout-webview.d.ts +14 -0
  213. package/lib/typescript/module/checkouts/PaymentSheet.d.ts +14 -0
  214. package/lib/typescript/module/checkouts/direct.d.ts +18 -0
  215. package/lib/typescript/module/context.d.ts +20 -0
  216. package/lib/typescript/module/core/api/direct-payment-api.d.ts +103 -0
  217. package/lib/typescript/module/core/api/discount-api.d.ts +10 -0
  218. package/lib/typescript/module/core/api/gateway-api.d.ts +150 -0
  219. package/lib/typescript/module/core/api/payments-api.d.ts +22 -0
  220. package/lib/typescript/module/core/api/repositories.d.ts +86 -0
  221. package/lib/typescript/module/core/assets/images.d.ts +5 -0
  222. package/lib/typescript/module/core/assets/method-logos.d.ts +12 -0
  223. package/lib/typescript/module/core/assets/pwa-images.d.ts +7 -0
  224. package/lib/typescript/module/core/browser/clipboard.d.ts +3 -0
  225. package/lib/typescript/module/core/browser/dom.d.ts +11 -0
  226. package/lib/typescript/module/core/browser/hosted-checkout.d.ts +27 -0
  227. package/lib/typescript/module/core/browser/index.d.ts +11 -0
  228. package/lib/typescript/module/core/browser/qr.d.ts +18 -0
  229. package/lib/typescript/module/core/browser/three-ds.d.ts +45 -0
  230. package/lib/typescript/module/core/client.d.ts +181 -0
  231. package/lib/typescript/module/core/config.d.ts +86 -0
  232. package/lib/typescript/module/core/environment.d.ts +22 -0
  233. package/lib/typescript/module/core/errors.d.ts +78 -0
  234. package/lib/typescript/module/core/events.d.ts +19 -0
  235. package/lib/typescript/module/core/flows/controller.d.ts +41 -0
  236. package/lib/typescript/module/core/flows/countdown.d.ts +15 -0
  237. package/lib/typescript/module/core/flows/direct-bank-transfer.d.ts +49 -0
  238. package/lib/typescript/module/core/flows/direct-card.d.ts +94 -0
  239. package/lib/typescript/module/core/flows/direct-ewallet.d.ts +39 -0
  240. package/lib/typescript/module/core/flows/direct-one-bill.d.ts +38 -0
  241. package/lib/typescript/module/core/flows/direct-qr.d.ts +25 -0
  242. package/lib/typescript/module/core/flows/direct-rtp.d.ts +72 -0
  243. package/lib/typescript/module/core/flows/discount-lookup.d.ts +37 -0
  244. package/lib/typescript/module/core/flows/headless.d.ts +38 -0
  245. package/lib/typescript/module/core/flows/payment-sheet.d.ts +263 -0
  246. package/lib/typescript/module/core/flows/services.d.ts +22 -0
  247. package/lib/typescript/module/core/flows/shared.d.ts +40 -0
  248. package/lib/typescript/module/core/http/api-client.d.ts +37 -0
  249. package/lib/typescript/module/core/http/endpoints.d.ts +39 -0
  250. package/lib/typescript/module/core/http/token-manager.d.ts +19 -0
  251. package/lib/typescript/module/core/http/transport.d.ts +37 -0
  252. package/lib/typescript/module/core/index.d.ts +42 -0
  253. package/lib/typescript/module/core/models/category.d.ts +35 -0
  254. package/lib/typescript/module/core/models/discount.d.ts +41 -0
  255. package/lib/typescript/module/core/models/payment.d.ts +104 -0
  256. package/lib/typescript/module/core/models/session.d.ts +87 -0
  257. package/lib/typescript/module/core/server/index.d.ts +10 -0
  258. package/lib/typescript/module/core/server/node.d.ts +19 -0
  259. package/lib/typescript/module/core/server/proxy.d.ts +30 -0
  260. package/lib/typescript/module/core/server/verify.d.ts +61 -0
  261. package/lib/typescript/module/core/swichpay.d.ts +40 -0
  262. package/lib/typescript/module/core/utils/crypto.d.ts +19 -0
  263. package/lib/typescript/module/core/utils/formatters.d.ts +19 -0
  264. package/lib/typescript/module/core/utils/json.d.ts +27 -0
  265. package/lib/typescript/module/core/utils/log.d.ts +15 -0
  266. package/lib/typescript/module/core/utils/runtime.d.ts +12 -0
  267. package/lib/typescript/module/core/utils/validators.d.ts +23 -0
  268. package/lib/typescript/module/hooks.d.ts +21 -0
  269. package/lib/typescript/module/index.d.ts +26 -0
  270. package/lib/typescript/module/polyfills.d.ts +2 -0
  271. package/lib/typescript/module/presenter.d.ts +25 -0
  272. package/lib/typescript/module/provider.d.ts +22 -0
  273. package/lib/typescript/module/swichpay.d.ts +125 -0
  274. package/lib/typescript/module/theme.d.ts +52 -0
  275. package/lib/typescript/module/ui.d.ts +583 -0
  276. package/lib/typescript/module/webviews.d.ts +40 -0
  277. package/package.json +129 -4
@@ -0,0 +1,1313 @@
1
+ "use strict";
2
+
3
+ import { Image, Pressable, StyleSheet, Text, View } from 'react-native';
4
+ import { CardValidators, PaymentCategory, PaymentSheetController, maskedSavedCard, maskedSavedWallet, paymentCategoryLabel } from '../core/index.js';
5
+ import { LOGO_BANK_TRANSFER, LOGO_EASYPAISA, LOGO_JAZZCASH, LOGO_MASTERCARD, LOGO_ONE_BILL, LOGO_PAYPAK, LOGO_PCI_DSS, LOGO_QR, LOGO_RTP, LOGO_SWICH, LOGO_VISA } from '../core/assets/method-logos.js';
6
+ import { useDismissHandler, useFlowServices, useSwichPayClient } from '../context.js';
7
+ import { useController, useLatest } from '../hooks.js';
8
+ import { colors, font, radius, space } from '../theme.js';
9
+ import { BrandBadge, Button, Checkbox, ConfirmDialog, ErrorBanner, Note, QrCode, Radio, Screen, SelectField, Spinner, StatusScreen, SuccessView, TextField, Toast } from '../ui.js';
10
+ import { StepUpView } from '../webviews.js';
11
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
12
+ /** Soft page background behind the white cards (Swich payment page style). */
13
+ const PAGE_BG = '#f4f6fb';
14
+ /** The built-in payment sheet. */
15
+ export function PaymentSheet(props) {
16
+ const client = useSwichPayClient();
17
+ const services = useFlowServices(props.services);
18
+ const onFinish = useLatest(props.onFinish);
19
+ const [c, s] = useController(() => new PaymentSheetController(client, {
20
+ details: props.details,
21
+ categories: props.categories ?? null,
22
+ onFinish: r => onFinish.current(r),
23
+ services,
24
+ timing: props.timing
25
+ }), ctrl => void ctrl.start());
26
+ useDismissHandler(() => c.dismiss());
27
+ if (s.phase === 'loading') {
28
+ return /*#__PURE__*/_jsxs(View, {
29
+ style: styles.center,
30
+ accessibilityRole: "progressbar",
31
+ children: [/*#__PURE__*/_jsx(Spinner, {
32
+ dark: true,
33
+ large: true,
34
+ label: "Starting checkout"
35
+ }), /*#__PURE__*/_jsx(Text, {
36
+ style: styles.muted,
37
+ children: "Starting secure checkout..."
38
+ })]
39
+ });
40
+ }
41
+ if (s.phase === 'startupError') {
42
+ return /*#__PURE__*/_jsx(View, {
43
+ style: styles.fill,
44
+ children: /*#__PURE__*/_jsx(ConfirmDialog, {
45
+ icon: "!",
46
+ title: "Unable to start checkout",
47
+ text: s.startupError ?? '',
48
+ confirmLabel: "OK",
49
+ onConfirm: () => c.dismissStartupError()
50
+ })
51
+ });
52
+ }
53
+ if (s.phase === 'success') return /*#__PURE__*/_jsx(SuccessView, {});
54
+ if (s.phase === 'expired') {
55
+ return /*#__PURE__*/_jsx(StatusScreen, {
56
+ icon: "\u23F1",
57
+ title: "Session Expired",
58
+ text: "Your payment session has expired. Please initiate a new payment request.",
59
+ buttonLabel: "Return to Merchant",
60
+ onButton: () => c.returnToMerchant()
61
+ });
62
+ }
63
+ if (s.phase === 'declined') {
64
+ return /*#__PURE__*/_jsx(StatusScreen, {
65
+ title: "Payment declined",
66
+ text: "Your payment was declined.",
67
+ note: "Please contact support.",
68
+ buttonLabel: "Close",
69
+ onButton: () => c.closeDeclined()
70
+ });
71
+ }
72
+ const detailRows = s.orderInfo.filter(r => r.label !== 'Amount:');
73
+ return /*#__PURE__*/_jsxs(View, {
74
+ style: styles.fill,
75
+ children: [/*#__PURE__*/_jsxs(Screen, {
76
+ style: styles.page,
77
+ children: [/*#__PURE__*/_jsxs(View, {
78
+ style: styles.headerRow,
79
+ children: [/*#__PURE__*/_jsx(Image, {
80
+ source: {
81
+ uri: LOGO_SWICH
82
+ },
83
+ style: styles.logo,
84
+ resizeMode: "contain",
85
+ accessibilityLabel: "Swich"
86
+ }), /*#__PURE__*/_jsx(Pressable, {
87
+ accessibilityRole: "button",
88
+ accessibilityLabel: "Close checkout",
89
+ hitSlop: 12,
90
+ onPress: () => c.requestClose(),
91
+ style: styles.closeBtn,
92
+ children: /*#__PURE__*/_jsx(Text, {
93
+ style: styles.closeText,
94
+ children: "\xD7"
95
+ })
96
+ })]
97
+ }), /*#__PURE__*/_jsxs(View, {
98
+ style: styles.card,
99
+ children: [/*#__PURE__*/_jsx(View, {
100
+ style: styles.secureRow,
101
+ children: /*#__PURE__*/_jsx(Text, {
102
+ style: styles.secure,
103
+ children: "\uD83D\uDD12 Secure checkout"
104
+ })
105
+ }), /*#__PURE__*/_jsx(Text, {
106
+ style: styles.amountLabel,
107
+ children: "Amount to pay"
108
+ }), /*#__PURE__*/_jsx(Text, {
109
+ style: styles.amount,
110
+ accessibilityRole: "text",
111
+ children: s.amountLabel
112
+ }), /*#__PURE__*/_jsxs(Text, {
113
+ style: styles.merchant,
114
+ numberOfLines: 1,
115
+ children: [s.details.merchantName, " \xB7 ", s.details.item]
116
+ }), /*#__PURE__*/_jsxs(View, {
117
+ style: styles.chips,
118
+ children: [/*#__PURE__*/_jsx(View, {
119
+ style: [styles.chip, s.timeIsLow && styles.chipUrgent],
120
+ accessibilityRole: "timer",
121
+ children: /*#__PURE__*/_jsxs(Text, {
122
+ style: [styles.chipText, s.timeIsLow && {
123
+ color: colors.danger
124
+ }],
125
+ children: ["\u23F1 Time left: ", s.timeLeftLabel]
126
+ })
127
+ }), /*#__PURE__*/_jsx(View, {
128
+ style: styles.chip,
129
+ children: /*#__PURE__*/_jsxs(Text, {
130
+ style: styles.chipText,
131
+ children: [s.remainingAttempts, " attempt", s.remainingAttempts === 1 ? '' : 's', " left"]
132
+ })
133
+ })]
134
+ }), /*#__PURE__*/_jsxs(Pressable, {
135
+ accessibilityRole: "button",
136
+ accessibilityLabel: s.orderInfoExpanded ? 'Hide order details' : 'Show order details',
137
+ accessibilityState: {
138
+ expanded: s.orderInfoExpanded
139
+ },
140
+ onPress: () => c.toggleOrderInfo(),
141
+ style: styles.orderHead,
142
+ children: [/*#__PURE__*/_jsx(Text, {
143
+ style: styles.orderTitle,
144
+ children: "Order Details"
145
+ }), /*#__PURE__*/_jsx(Text, {
146
+ style: styles.orderToggle,
147
+ children: s.orderInfoExpanded ? 'Hide ▴' : 'Show ▾'
148
+ })]
149
+ }), s.orderInfoExpanded ? detailRows.map(row => /*#__PURE__*/_jsxs(View, {
150
+ style: styles.row,
151
+ children: [/*#__PURE__*/_jsx(Text, {
152
+ style: styles.rowLabel,
153
+ children: row.label.replace(/:$/, '')
154
+ }), /*#__PURE__*/_jsx(Text, {
155
+ style: styles.rowValue,
156
+ numberOfLines: 1,
157
+ children: row.value
158
+ })]
159
+ }, row.label)) : null]
160
+ }), /*#__PURE__*/_jsx(Text, {
161
+ style: styles.sectionTitle,
162
+ accessibilityRole: "header",
163
+ children: "Choose Payment Method"
164
+ }), s.tiles.map(tile => {
165
+ const expanded = s.expandedCategory === tile.category;
166
+ const look = methodLook(tile);
167
+ return /*#__PURE__*/_jsxs(View, {
168
+ style: [styles.tile, expanded && styles.tileOn],
169
+ children: [/*#__PURE__*/_jsxs(Pressable, {
170
+ accessibilityRole: "button",
171
+ accessibilityLabel: tile.label,
172
+ accessibilityState: {
173
+ expanded,
174
+ disabled: s.locked
175
+ },
176
+ onPress: () => c.toggleCategory(tile.category),
177
+ style: ({
178
+ pressed
179
+ }) => [styles.tileHead, pressed && {
180
+ backgroundColor: colors.surfaceAlt
181
+ }],
182
+ children: [/*#__PURE__*/_jsx(View, {
183
+ style: styles.tileIcon,
184
+ children: look.icon ? /*#__PURE__*/_jsx(Image, {
185
+ source: {
186
+ uri: look.icon
187
+ },
188
+ style: styles.tileIconImg,
189
+ resizeMode: "contain"
190
+ }) : /*#__PURE__*/_jsx(Text, {
191
+ style: {
192
+ fontSize: 18
193
+ },
194
+ children: "\uD83D\uDCB3"
195
+ })
196
+ }), /*#__PURE__*/_jsxs(View, {
197
+ style: styles.tileText,
198
+ children: [/*#__PURE__*/_jsx(Text, {
199
+ style: styles.tileLabel,
200
+ children: tile.label
201
+ }), look.subtitle ? /*#__PURE__*/_jsx(Text, {
202
+ style: styles.tileSub,
203
+ children: look.subtitle
204
+ }) : null]
205
+ }), expanded ? /*#__PURE__*/_jsx(Text, {
206
+ style: styles.tileChevron,
207
+ children: "\u2715"
208
+ }) : look.logos.length > 1 ? /*#__PURE__*/_jsx(View, {
209
+ style: styles.logos,
210
+ children: look.logos.map(uri => /*#__PURE__*/_jsx(Image, {
211
+ source: {
212
+ uri
213
+ },
214
+ style: styles.tileLogo,
215
+ resizeMode: "contain"
216
+ }, uri.slice(-24)))
217
+ }) : /*#__PURE__*/_jsx(Text, {
218
+ style: styles.tileChevron,
219
+ children: "\u203A"
220
+ })]
221
+ }), expanded ? /*#__PURE__*/_jsxs(View, {
222
+ style: styles.tileBody,
223
+ children: [/*#__PURE__*/_jsx(ErrorBanner, {
224
+ message: s.formError
225
+ }), /*#__PURE__*/_jsx(CategoryForm, {
226
+ c: c,
227
+ s: s,
228
+ category: tile.category
229
+ })]
230
+ }) : null]
231
+ }, tile.category);
232
+ }), /*#__PURE__*/_jsxs(View, {
233
+ style: styles.footer,
234
+ children: [/*#__PURE__*/_jsx(Image, {
235
+ source: {
236
+ uri: LOGO_PCI_DSS
237
+ },
238
+ style: styles.pci,
239
+ resizeMode: "contain",
240
+ accessibilityLabel: "PCI DSS compliant"
241
+ }), /*#__PURE__*/_jsx(Text, {
242
+ style: styles.footerText,
243
+ children: "Payments are encrypted and secured by Swich."
244
+ })]
245
+ })]
246
+ }), /*#__PURE__*/_jsx(Toast, {
247
+ message: s.toast
248
+ }), s.exitConfirmOpen ? /*#__PURE__*/_jsx(ConfirmDialog, {
249
+ title: "Exit checkout?",
250
+ text: "Are you sure you want to exit? Your payment session will be cancelled.",
251
+ cancelLabel: "No, Continue",
252
+ confirmLabel: "Yes, Exit",
253
+ onCancel: () => c.confirmExit(false),
254
+ onConfirm: () => c.confirmExit(true)
255
+ }) : null]
256
+ });
257
+ }
258
+
259
+ /**
260
+ * Icon, brand logos and a one-line description per method. Logos are bundled (from Swich's own
261
+ * payment page) because the `mobileappinit` logo URLs can be unavailable; unknown categories
262
+ * fall back to those URLs.
263
+ */
264
+ function methodLook(tile) {
265
+ switch (tile.category) {
266
+ case PaymentCategory.ewallet:
267
+ return {
268
+ icon: LOGO_JAZZCASH,
269
+ logos: [LOGO_EASYPAISA, LOGO_JAZZCASH],
270
+ subtitle: 'EasyPaisa or JazzCash account'
271
+ };
272
+ case PaymentCategory.rtpEwalletPayment:
273
+ return {
274
+ icon: LOGO_EASYPAISA,
275
+ logos: [LOGO_EASYPAISA, LOGO_JAZZCASH],
276
+ subtitle: 'Payment request to your wallet'
277
+ };
278
+ case PaymentCategory.visaMasterCardPayment:
279
+ return {
280
+ icon: LOGO_VISA,
281
+ logos: [LOGO_VISA, LOGO_MASTERCARD, LOGO_PAYPAK],
282
+ subtitle: 'Visa, Mastercard or PayPak'
283
+ };
284
+ case PaymentCategory.biller:
285
+ return {
286
+ icon: LOGO_ONE_BILL,
287
+ logos: [],
288
+ subtitle: 'Pay with a consumer number at any bank or app'
289
+ };
290
+ case PaymentCategory.bankAccount:
291
+ return {
292
+ icon: LOGO_BANK_TRANSFER,
293
+ logos: [],
294
+ subtitle: 'Pay from your bank account with OTP'
295
+ };
296
+ case PaymentCategory.dqrcPayment:
297
+ return {
298
+ icon: LOGO_QR,
299
+ logos: [],
300
+ subtitle: 'Scan a one-time RAAST QR with your bank app'
301
+ };
302
+ case PaymentCategory.sqrcPayment:
303
+ return {
304
+ icon: LOGO_QR,
305
+ logos: [],
306
+ subtitle: 'Scan the merchant RAAST QR'
307
+ };
308
+ case PaymentCategory.rtpNowPayment:
309
+ return {
310
+ icon: LOGO_RTP,
311
+ logos: [],
312
+ subtitle: 'Instant payment request to your bank'
313
+ };
314
+ default:
315
+ return {
316
+ icon: tile.logoUrls[0] ?? null,
317
+ logos: tile.logoUrls,
318
+ subtitle: ''
319
+ };
320
+ }
321
+ }
322
+ function CategoryForm(props) {
323
+ const {
324
+ c,
325
+ s,
326
+ category
327
+ } = props;
328
+ switch (category) {
329
+ case PaymentCategory.visaMasterCardPayment:
330
+ return /*#__PURE__*/_jsx(CardForm, {
331
+ c: c,
332
+ s: s
333
+ });
334
+ case PaymentCategory.ewallet:
335
+ return /*#__PURE__*/_jsx(EwalletForm, {
336
+ c: c,
337
+ s: s
338
+ });
339
+ case PaymentCategory.rtpEwalletPayment:
340
+ return /*#__PURE__*/_jsx(RtpEwalletForm, {
341
+ c: c,
342
+ s: s
343
+ });
344
+ case PaymentCategory.biller:
345
+ return /*#__PURE__*/_jsx(OneBillForm, {
346
+ c: c,
347
+ s: s
348
+ });
349
+ case PaymentCategory.bankAccount:
350
+ return /*#__PURE__*/_jsx(BankForm, {
351
+ c: c,
352
+ s: s
353
+ });
354
+ case PaymentCategory.dqrcPayment:
355
+ case PaymentCategory.sqrcPayment:
356
+ return /*#__PURE__*/_jsx(QrForm, {
357
+ c: c,
358
+ s: s,
359
+ category: category
360
+ });
361
+ case PaymentCategory.rtpNowPayment:
362
+ return /*#__PURE__*/_jsx(RtpNowForm, {
363
+ c: c,
364
+ s: s
365
+ });
366
+ default:
367
+ return /*#__PURE__*/_jsxs(View, {
368
+ style: styles.form,
369
+ children: [/*#__PURE__*/_jsxs(Note, {
370
+ children: [paymentCategoryLabel(category), " isn't available in this demo yet."]
371
+ }), /*#__PURE__*/_jsx(Button, {
372
+ onPress: () => c.submitUnsupported(category),
373
+ children: s.payLabel
374
+ })]
375
+ });
376
+ }
377
+ }
378
+ function SavedRow(props) {
379
+ return /*#__PURE__*/_jsxs(Pressable, {
380
+ accessibilityRole: "button",
381
+ accessibilityState: {
382
+ selected: props.selected,
383
+ disabled: !!props.disabled
384
+ },
385
+ disabled: props.disabled,
386
+ onPress: props.onPress,
387
+ style: [styles.saved, props.selected && {
388
+ borderColor: colors.blue
389
+ }],
390
+ children: [props.logo ? /*#__PURE__*/_jsx(Image, {
391
+ source: {
392
+ uri: props.logo
393
+ },
394
+ style: styles.tileLogo,
395
+ resizeMode: "contain"
396
+ }) : /*#__PURE__*/_jsx(Text, {
397
+ children: "\uD83D\uDCB3"
398
+ }), /*#__PURE__*/_jsxs(View, {
399
+ style: {
400
+ flex: 1
401
+ },
402
+ children: [/*#__PURE__*/_jsx(Text, {
403
+ style: styles.savedLabel,
404
+ children: props.label
405
+ }), props.sub ? /*#__PURE__*/_jsx(Text, {
406
+ style: styles.savedSub,
407
+ children: props.sub
408
+ }) : null]
409
+ }), /*#__PURE__*/_jsx(Text, {
410
+ children: props.marker
411
+ })]
412
+ });
413
+ }
414
+ function Or(props) {
415
+ return /*#__PURE__*/_jsx(Text, {
416
+ style: styles.or,
417
+ children: props.label
418
+ });
419
+ }
420
+ function CardForm({
421
+ c,
422
+ s
423
+ }) {
424
+ const card = s.card;
425
+ if (card.verifyingCard) {
426
+ return /*#__PURE__*/_jsxs(View, {
427
+ style: styles.center,
428
+ accessibilityRole: "progressbar",
429
+ children: [/*#__PURE__*/_jsx(Spinner, {
430
+ dark: true,
431
+ large: true,
432
+ label: "Verifying your card"
433
+ }), /*#__PURE__*/_jsx(Text, {
434
+ style: styles.muted,
435
+ children: "Verifying your card..."
436
+ })]
437
+ });
438
+ }
439
+ if (card.stepUp) {
440
+ return /*#__PURE__*/_jsx(StepUpView, {
441
+ challenge: card.stepUp,
442
+ isCompletionUrl: c.isThreeDsReturnUrl,
443
+ onComplete: data => void c.completeThreeDs(data)
444
+ });
445
+ }
446
+ const saved = s.session?.savedCards ?? [];
447
+ const savedSelected = card.selectedSavedCardId != null;
448
+ const fieldsDisabled = savedSelected || card.checkingStatus;
449
+ return /*#__PURE__*/_jsxs(View, {
450
+ style: styles.form,
451
+ children: [saved.length > 0 ? /*#__PURE__*/_jsxs(_Fragment, {
452
+ children: [/*#__PURE__*/_jsx(Text, {
453
+ style: styles.subTitle,
454
+ children: "Saved Cards"
455
+ }), saved.map(sc => {
456
+ const brand = CardValidators.detectBrand(sc.cardNumber);
457
+ const logo = brand === 'visa' ? s.logos.Visa : brand === 'mastercard' ? s.logos.Mastercard : undefined;
458
+ const selected = card.selectedSavedCardId === sc.id;
459
+ return /*#__PURE__*/_jsx(SavedRow, {
460
+ label: maskedSavedCard(sc),
461
+ sub: sc.expiryDate ? `Exp ${sc.expiryDate}` : null,
462
+ logo: logo,
463
+ selected: selected,
464
+ disabled: s.submitting,
465
+ marker: selected ? '×' : '○',
466
+ onPress: () => c.selectSavedCard(sc.id)
467
+ }, sc.id);
468
+ }), /*#__PURE__*/_jsx(Or, {
469
+ label: "OR USE NEW CARD"
470
+ }), savedSelected ? /*#__PURE__*/_jsx(Button, {
471
+ variant: "ghost",
472
+ onPress: () => c.clearSavedCard(),
473
+ children: "Use a new card"
474
+ }) : null]
475
+ }) : null, /*#__PURE__*/_jsx(TextField, {
476
+ label: "Card no.",
477
+ keyboardType: "number-pad",
478
+ autoComplete: "cc-number",
479
+ placeholder: "Enter card no.",
480
+ maxLength: 19,
481
+ value: card.number,
482
+ editable: !fieldsDisabled,
483
+ error: card.errors.number,
484
+ suffix: card.number ? /*#__PURE__*/_jsx(BrandBadge, {
485
+ brand: card.brand,
486
+ logos: s.logos
487
+ }) : undefined,
488
+ onValueChange: v => c.setCardNumber(v)
489
+ }), /*#__PURE__*/_jsxs(View, {
490
+ style: styles.grid2,
491
+ children: [/*#__PURE__*/_jsx(View, {
492
+ style: {
493
+ flex: 1
494
+ },
495
+ children: /*#__PURE__*/_jsx(TextField, {
496
+ label: "Expiry date",
497
+ keyboardType: "number-pad",
498
+ autoComplete: "cc-exp",
499
+ placeholder: "MM/YY",
500
+ maxLength: 5,
501
+ value: card.expiry,
502
+ editable: !fieldsDisabled,
503
+ error: card.errors.expiry,
504
+ onValueChange: v => c.setCardExpiry(v)
505
+ })
506
+ }), /*#__PURE__*/_jsx(View, {
507
+ style: {
508
+ flex: 1
509
+ },
510
+ children: /*#__PURE__*/_jsx(TextField, {
511
+ label: "CVC No.",
512
+ keyboardType: "number-pad",
513
+ autoComplete: "cc-csc",
514
+ secureTextEntry: true,
515
+ placeholder: "Enter CVC no.",
516
+ maxLength: 4,
517
+ value: card.cvv,
518
+ editable: !fieldsDisabled,
519
+ error: card.errors.cvv,
520
+ onValueChange: v => c.setCardCvv(v)
521
+ })
522
+ })]
523
+ }), !savedSelected ? /*#__PURE__*/_jsx(Checkbox, {
524
+ label: "Save this card for future payments",
525
+ checked: card.saveCard,
526
+ onChange: v => c.setSaveCard(v)
527
+ }) : null, !savedSelected ? /*#__PURE__*/_jsx(DiscountBlock, {
528
+ s: s,
529
+ which: "card"
530
+ }) : null, /*#__PURE__*/_jsx(Button, {
531
+ loading: s.submitting || card.checkingStatus,
532
+ onPress: () => void c.submitCard(),
533
+ children: card.payLabel
534
+ }), card.checkingStatus ? /*#__PURE__*/_jsx(Note, {
535
+ children: card.statusMessage ?? 'Checking payment status...'
536
+ }) : null]
537
+ });
538
+ }
539
+ function DiscountBlock({
540
+ s,
541
+ which
542
+ }) {
543
+ const discount = which === 'card' ? s.card.discount : s.ewallet.discount;
544
+ const d = s.details;
545
+ if (discount.loading) {
546
+ return /*#__PURE__*/_jsxs(View, {
547
+ style: styles.discountLoading,
548
+ accessibilityRole: "progressbar",
549
+ children: [/*#__PURE__*/_jsx(Spinner, {
550
+ dark: true,
551
+ label: "Checking for a discount"
552
+ }), /*#__PURE__*/_jsx(Text, {
553
+ style: styles.muted,
554
+ children: "Checking for a discount..."
555
+ })]
556
+ });
557
+ }
558
+ if (!discount.result) return null;
559
+ return /*#__PURE__*/_jsxs(View, {
560
+ style: styles.discount,
561
+ children: [/*#__PURE__*/_jsxs(View, {
562
+ style: styles.row,
563
+ children: [/*#__PURE__*/_jsx(Text, {
564
+ style: styles.rowLabel,
565
+ children: "Amount"
566
+ }), /*#__PURE__*/_jsxs(Text, {
567
+ style: styles.rowValue,
568
+ children: [d.currency, " ", d.amount]
569
+ })]
570
+ }), /*#__PURE__*/_jsxs(View, {
571
+ style: styles.row,
572
+ children: [/*#__PURE__*/_jsx(Text, {
573
+ style: styles.rowLabel,
574
+ children: "Discount"
575
+ }), /*#__PURE__*/_jsxs(Text, {
576
+ style: styles.rowValue,
577
+ children: ["-", d.currency, " ", discount.result.discountAmount]
578
+ })]
579
+ }), /*#__PURE__*/_jsx(View, {
580
+ style: styles.divider
581
+ }), /*#__PURE__*/_jsxs(View, {
582
+ style: styles.row,
583
+ children: [/*#__PURE__*/_jsx(Text, {
584
+ style: styles.rowLabel,
585
+ children: "Total Payable"
586
+ }), /*#__PURE__*/_jsxs(Text, {
587
+ style: styles.rowValue,
588
+ children: [d.currency, " ", discount.result.finalAmount]
589
+ })]
590
+ })]
591
+ });
592
+ }
593
+ function EwalletForm({
594
+ c,
595
+ s
596
+ }) {
597
+ const session = s.session;
598
+ const w = s.ewallet;
599
+ return /*#__PURE__*/_jsxs(View, {
600
+ style: styles.form,
601
+ children: [session.savedWallets.length > 0 ? /*#__PURE__*/_jsxs(_Fragment, {
602
+ children: [/*#__PURE__*/_jsx(Text, {
603
+ style: styles.subTitle,
604
+ children: "Saved Ewallets"
605
+ }), session.savedWallets.map(wallet => {
606
+ const channel = c.channelForSavedWallet(wallet);
607
+ const selected = w.selectedSavedWalletId === wallet.id;
608
+ return /*#__PURE__*/_jsx(SavedRow, {
609
+ label: maskedSavedWallet(wallet),
610
+ logo: channel ? s.logos[channel.channelName] : undefined,
611
+ selected: selected,
612
+ disabled: s.submitting,
613
+ marker: selected ? '●' : '○',
614
+ onPress: () => c.selectSavedWallet(wallet.id)
615
+ }, wallet.id);
616
+ }), /*#__PURE__*/_jsx(Or, {
617
+ label: "OR USE NEW ACCOUNT"
618
+ })]
619
+ }) : null, /*#__PURE__*/_jsx(View, {
620
+ style: styles.radios,
621
+ accessibilityRole: "radiogroup",
622
+ accessibilityLabel: "Wallet provider",
623
+ children: session.channels.map((channel, index) => /*#__PURE__*/_jsx(Radio, {
624
+ label: channel.channelName,
625
+ logoUrl: s.logos[channel.channelName],
626
+ checked: w.selectedSavedWalletId == null && w.selectedChannelIndex === index,
627
+ disabled: s.submitting,
628
+ onSelect: () => c.selectChannel(index)
629
+ }, `${channel.channelId}-${index}`))
630
+ }), /*#__PURE__*/_jsx(TextField, {
631
+ label: "Account Number",
632
+ keyboardType: "phone-pad",
633
+ autoComplete: "tel",
634
+ placeholder: "Enter account number",
635
+ maxLength: 11,
636
+ value: w.account,
637
+ editable: w.selectedSavedWalletId == null,
638
+ error: w.errors.account,
639
+ onValueChange: v => c.setEwalletAccount(v)
640
+ }), /*#__PURE__*/_jsx(DiscountBlock, {
641
+ s: s,
642
+ which: "ewallet"
643
+ }), /*#__PURE__*/_jsx(Button, {
644
+ loading: s.submitting,
645
+ onPress: () => void c.submitEwallet(),
646
+ children: w.payLabel
647
+ }), s.submitting ? /*#__PURE__*/_jsx(Note, {
648
+ children: "Please approve the payment request from your wallet app"
649
+ }) : null]
650
+ });
651
+ }
652
+ function RtpEwalletForm({
653
+ c,
654
+ s
655
+ }) {
656
+ const r = s.rtpEwallet;
657
+ return /*#__PURE__*/_jsxs(View, {
658
+ style: styles.form,
659
+ children: [/*#__PURE__*/_jsx(SelectField, {
660
+ label: "Bank",
661
+ placeholder: "Select Bank",
662
+ value: r.selectedBankName,
663
+ disabled: s.submitting,
664
+ options: s.banks.rtpEwallet.map(b => ({
665
+ value: b.bankName,
666
+ label: b.bankName
667
+ })),
668
+ onValueChange: v => c.selectRtpEwalletBank(v)
669
+ }), /*#__PURE__*/_jsxs(View, {
670
+ style: styles.radios,
671
+ accessibilityRole: "radiogroup",
672
+ accessibilityLabel: "Pay with",
673
+ children: [/*#__PURE__*/_jsx(Radio, {
674
+ label: "Phone",
675
+ checked: r.phoneMode,
676
+ disabled: s.submitting,
677
+ onSelect: () => c.setRtpEwalletPhoneMode(true)
678
+ }), /*#__PURE__*/_jsx(Radio, {
679
+ label: "IBAN",
680
+ checked: !r.phoneMode,
681
+ disabled: s.submitting,
682
+ onSelect: () => c.setRtpEwalletPhoneMode(false)
683
+ })]
684
+ }), /*#__PURE__*/_jsx(TextField, {
685
+ label: r.phoneMode ? 'Mobile Number' : 'IBAN',
686
+ keyboardType: r.phoneMode ? 'phone-pad' : 'default',
687
+ autoCapitalize: r.phoneMode ? 'none' : 'characters',
688
+ placeholder: r.phoneMode ? 'Enter mobile number' : 'Enter IBAN (e.g. PK00XXXX...)',
689
+ value: r.input,
690
+ error: r.errors.input,
691
+ onValueChange: v => c.setRtpEwalletInput(v)
692
+ }), /*#__PURE__*/_jsx(Button, {
693
+ loading: s.submitting,
694
+ onPress: () => void c.submitRtpEwallet(),
695
+ children: s.payLabel
696
+ }), s.submitting ? /*#__PURE__*/_jsx(Note, {
697
+ children: r.phoneMode ? 'Please approve this payment in your banking app. This can take a few minutes.' : 'Please approve this payment with your bank. This can take a few minutes.'
698
+ }) : null]
699
+ });
700
+ }
701
+ function OneBillForm({
702
+ c,
703
+ s
704
+ }) {
705
+ const o = s.oneBill;
706
+ if (o.consumerNumber) {
707
+ return /*#__PURE__*/_jsxs(View, {
708
+ style: styles.form,
709
+ children: [/*#__PURE__*/_jsxs(View, {
710
+ style: styles.codeBox,
711
+ children: [/*#__PURE__*/_jsx(Text, {
712
+ style: styles.codeLabel,
713
+ children: "Consumer Number"
714
+ }), /*#__PURE__*/_jsxs(View, {
715
+ style: styles.codeRow,
716
+ children: [/*#__PURE__*/_jsx(Text, {
717
+ style: styles.codeValue,
718
+ selectable: true,
719
+ children: o.consumerNumber
720
+ }), /*#__PURE__*/_jsx(Pressable, {
721
+ accessibilityRole: "button",
722
+ accessibilityLabel: "Copy",
723
+ hitSlop: 10,
724
+ onPress: () => void c.copyConsumerNumber(),
725
+ children: /*#__PURE__*/_jsx(Text, {
726
+ style: styles.copy,
727
+ children: "\u29C9"
728
+ })
729
+ })]
730
+ })]
731
+ }), /*#__PURE__*/_jsx(Button, {
732
+ loading: s.submitting,
733
+ onPress: () => void c.verifyOneBill(),
734
+ children: "\u2713 Verify Payment"
735
+ })]
736
+ });
737
+ }
738
+ return /*#__PURE__*/_jsxs(View, {
739
+ style: styles.form,
740
+ children: [/*#__PURE__*/_jsx(TextField, {
741
+ label: "Mobile Number",
742
+ keyboardType: "phone-pad",
743
+ autoComplete: "tel",
744
+ placeholder: "Enter mobile number",
745
+ value: o.mobile,
746
+ error: o.errors.mobile,
747
+ onValueChange: v => c.setOneBillMobile(v)
748
+ }), /*#__PURE__*/_jsx(Button, {
749
+ loading: s.submitting,
750
+ onPress: () => void c.submitOneBill(),
751
+ children: "GENERATE CONSUMER NUMBER"
752
+ })]
753
+ });
754
+ }
755
+ function BankForm({
756
+ c,
757
+ s
758
+ }) {
759
+ const b = s.bank;
760
+ if (b.otpRequired) {
761
+ return /*#__PURE__*/_jsxs(View, {
762
+ style: styles.form,
763
+ children: [/*#__PURE__*/_jsxs(Note, {
764
+ children: ["Enter the OTP sent to ", b.mobile]
765
+ }), /*#__PURE__*/_jsx(TextField, {
766
+ label: "OTP",
767
+ keyboardType: "number-pad",
768
+ autoComplete: "one-time-code",
769
+ placeholder: "Enter OTP",
770
+ value: b.otp,
771
+ error: b.errors.otp,
772
+ onValueChange: v => c.setBankField('otp', v)
773
+ }), /*#__PURE__*/_jsx(Button, {
774
+ loading: s.submitting,
775
+ onPress: () => void c.verifyBankOtp(),
776
+ children: s.payLabel
777
+ })]
778
+ });
779
+ }
780
+ return /*#__PURE__*/_jsxs(View, {
781
+ style: styles.form,
782
+ children: [/*#__PURE__*/_jsx(SelectField, {
783
+ label: "Select Bank",
784
+ placeholder: "Choose your bank",
785
+ value: b.selectedBankName,
786
+ error: b.errors.bank,
787
+ options: s.banks.bankAccount.map(bank => ({
788
+ value: bank.bankName,
789
+ label: bank.bankName
790
+ })),
791
+ onValueChange: v => c.selectBank(v)
792
+ }), /*#__PURE__*/_jsx(TextField, {
793
+ label: "CNIC",
794
+ keyboardType: "number-pad",
795
+ placeholder: "Enter CNIC (13 digits)",
796
+ maxLength: 13,
797
+ value: b.cnic,
798
+ error: b.errors.cnic,
799
+ onValueChange: v => c.setBankField('cnic', v)
800
+ }), /*#__PURE__*/_jsx(TextField, {
801
+ label: "Mobile Number",
802
+ keyboardType: "phone-pad",
803
+ autoComplete: "tel",
804
+ placeholder: "Enter mobile number",
805
+ value: b.mobile,
806
+ error: b.errors.mobile,
807
+ onValueChange: v => c.setBankField('mobile', v)
808
+ }), /*#__PURE__*/_jsx(TextField, {
809
+ label: "Account Number",
810
+ keyboardType: "number-pad",
811
+ placeholder: "Enter account number",
812
+ value: b.account,
813
+ error: b.errors.account,
814
+ onValueChange: v => c.setBankField('account', v)
815
+ }), /*#__PURE__*/_jsx(Button, {
816
+ loading: s.submitting,
817
+ onPress: () => void c.submitBankAccount(),
818
+ children: s.payLabel
819
+ })]
820
+ });
821
+ }
822
+ function QrForm({
823
+ c,
824
+ s,
825
+ category
826
+ }) {
827
+ const q = s.qr;
828
+ const d = s.details;
829
+ if (!q.qrString) {
830
+ return /*#__PURE__*/_jsxs(View, {
831
+ style: [styles.form, {
832
+ alignItems: 'stretch'
833
+ }],
834
+ children: [/*#__PURE__*/_jsx(Text, {
835
+ style: styles.qrTitle,
836
+ children: "Payment through RAAST QR"
837
+ }), /*#__PURE__*/_jsx(Text, {
838
+ style: [styles.muted, {
839
+ textAlign: 'center'
840
+ }, q.error ? {
841
+ color: colors.danger
842
+ } : null],
843
+ children: q.error ?? 'Click below to generate your QR code.'
844
+ }), /*#__PURE__*/_jsx(Button, {
845
+ loading: q.loading,
846
+ onPress: () => void c.loadQr(category),
847
+ children: q.error ? 'Try Again' : 'Generate QR Code'
848
+ })]
849
+ });
850
+ }
851
+ return /*#__PURE__*/_jsxs(View, {
852
+ style: styles.form,
853
+ children: [/*#__PURE__*/_jsx(Text, {
854
+ style: styles.qrTitle,
855
+ children: "Payment through RAAST QR"
856
+ }), /*#__PURE__*/_jsx(QrCode, {
857
+ value: q.qrString
858
+ }), /*#__PURE__*/_jsxs(View, {
859
+ style: styles.grid2,
860
+ children: [/*#__PURE__*/_jsx(Button, {
861
+ variant: "ghost",
862
+ style: {
863
+ flex: 1
864
+ },
865
+ onPress: () => void c.downloadQr(),
866
+ children: "\u2913 Download"
867
+ }), /*#__PURE__*/_jsx(Button, {
868
+ variant: "ghost",
869
+ style: {
870
+ flex: 1
871
+ },
872
+ onPress: () => void c.shareQr(),
873
+ children: "\u2934 Share"
874
+ })]
875
+ }), /*#__PURE__*/_jsx(Text, {
876
+ style: [styles.muted, {
877
+ textAlign: 'center'
878
+ }],
879
+ children: "QR expires with your session. Refresh if it stops working."
880
+ }), /*#__PURE__*/_jsxs(Text, {
881
+ style: styles.qrTitle,
882
+ children: ["Amount: ", d.currency, " ", d.amount]
883
+ }), /*#__PURE__*/_jsx(Button, {
884
+ loading: s.submitting,
885
+ disabled: q.loading,
886
+ onPress: () => void c.verifyQr(category),
887
+ children: "\u2713 I've Paid \u2014 Verify"
888
+ })]
889
+ });
890
+ }
891
+ function RtpNowForm({
892
+ c,
893
+ s
894
+ }) {
895
+ const r = s.rtpNow;
896
+ return /*#__PURE__*/_jsxs(View, {
897
+ style: styles.form,
898
+ children: [/*#__PURE__*/_jsx(Text, {
899
+ style: styles.qrTitle,
900
+ children: "RTP (Request to Pay)"
901
+ }), /*#__PURE__*/_jsx(Text, {
902
+ style: [styles.muted, {
903
+ textAlign: 'center'
904
+ }],
905
+ children: "Select how you want to receive the Request to Pay."
906
+ }), /*#__PURE__*/_jsxs(View, {
907
+ style: [styles.option, r.method === 'raast' && styles.optionOn],
908
+ children: [/*#__PURE__*/_jsx(Radio, {
909
+ label: "RAAST",
910
+ checked: r.method === 'raast',
911
+ onSelect: () => c.setRtpNowMethod('raast')
912
+ }), r.method === 'raast' ? /*#__PURE__*/_jsxs(View, {
913
+ style: styles.optionBody,
914
+ children: [/*#__PURE__*/_jsx(TextField, {
915
+ accessibilityLabel: "Mobile Number",
916
+ placeholder: "Mobile Number",
917
+ required: false,
918
+ keyboardType: "phone-pad",
919
+ value: r.mobile,
920
+ onValueChange: v => c.setRtpNowField('mobile', v)
921
+ }), /*#__PURE__*/_jsx(Text, {
922
+ style: [styles.muted, {
923
+ textAlign: 'center',
924
+ fontWeight: '600'
925
+ }],
926
+ children: "OR"
927
+ }), /*#__PURE__*/_jsx(TextField, {
928
+ accessibilityLabel: "IBAN",
929
+ placeholder: "IBAN",
930
+ required: false,
931
+ autoCapitalize: "characters",
932
+ value: r.iban,
933
+ onValueChange: v => c.setRtpNowField('iban', v)
934
+ }), /*#__PURE__*/_jsx(Text, {
935
+ style: styles.muted,
936
+ children: "Enter either a Mobile Number or an IBAN."
937
+ })]
938
+ }) : null]
939
+ }), /*#__PURE__*/_jsxs(View, {
940
+ style: [styles.option, r.method === 'bankAccount' && styles.optionOn],
941
+ children: [/*#__PURE__*/_jsx(Radio, {
942
+ label: "Bank Account",
943
+ checked: r.method === 'bankAccount',
944
+ onSelect: () => c.setRtpNowMethod('bankAccount')
945
+ }), r.method === 'bankAccount' ? /*#__PURE__*/_jsxs(View, {
946
+ style: styles.optionBody,
947
+ children: [/*#__PURE__*/_jsx(SelectField, {
948
+ label: "Bank",
949
+ placeholder: "Select Bank",
950
+ value: r.selectedBankName,
951
+ options: s.banks.rtpNow.map(b => ({
952
+ value: b.bankName,
953
+ label: b.bankName
954
+ })),
955
+ onValueChange: v => c.selectRtpNowBank(v)
956
+ }), /*#__PURE__*/_jsx(TextField, {
957
+ accessibilityLabel: "Account Number",
958
+ placeholder: "Account Number",
959
+ required: false,
960
+ keyboardType: "number-pad",
961
+ value: r.account,
962
+ onValueChange: v => c.setRtpNowField('account', v)
963
+ })]
964
+ }) : null]
965
+ }), /*#__PURE__*/_jsx(Button, {
966
+ loading: s.submitting,
967
+ disabled: !r.continueEnabled,
968
+ onPress: () => void c.submitRtpNow(),
969
+ children: "Continue"
970
+ }), s.submitting ? /*#__PURE__*/_jsx(Note, {
971
+ children: "Please approve the payment request from your bank/wallet app"
972
+ }) : null]
973
+ });
974
+ }
975
+ const styles = StyleSheet.create({
976
+ fill: {
977
+ flexGrow: 1,
978
+ flexShrink: 1,
979
+ backgroundColor: PAGE_BG
980
+ },
981
+ page: {
982
+ backgroundColor: PAGE_BG,
983
+ gap: space.md
984
+ },
985
+ center: {
986
+ flexGrow: 1,
987
+ flexShrink: 1,
988
+ minHeight: 240,
989
+ alignItems: 'center',
990
+ justifyContent: 'center',
991
+ gap: space.md,
992
+ padding: space.xl,
993
+ backgroundColor: PAGE_BG
994
+ },
995
+ muted: {
996
+ color: colors.muted,
997
+ fontSize: font.sm + 1
998
+ },
999
+ headerRow: {
1000
+ flexDirection: 'row',
1001
+ alignItems: 'center',
1002
+ justifyContent: 'space-between',
1003
+ paddingTop: space.xs
1004
+ },
1005
+ logo: {
1006
+ width: 112,
1007
+ height: 36
1008
+ },
1009
+ closeBtn: {
1010
+ width: 36,
1011
+ height: 36,
1012
+ borderRadius: 18,
1013
+ alignItems: 'center',
1014
+ justifyContent: 'center',
1015
+ backgroundColor: colors.surface,
1016
+ borderWidth: 1,
1017
+ borderColor: colors.border
1018
+ },
1019
+ closeText: {
1020
+ fontSize: 22,
1021
+ lineHeight: 24,
1022
+ color: colors.muted
1023
+ },
1024
+ card: {
1025
+ backgroundColor: colors.surface,
1026
+ borderRadius: radius.lg,
1027
+ padding: space.lg,
1028
+ gap: 6,
1029
+ shadowColor: '#0f172a',
1030
+ shadowOpacity: 0.06,
1031
+ shadowRadius: 10,
1032
+ shadowOffset: {
1033
+ width: 0,
1034
+ height: 2
1035
+ },
1036
+ elevation: 2
1037
+ },
1038
+ secureRow: {
1039
+ flexDirection: 'row'
1040
+ },
1041
+ secure: {
1042
+ fontSize: font.sm,
1043
+ fontWeight: '600',
1044
+ color: colors.success,
1045
+ backgroundColor: colors.successBg,
1046
+ paddingHorizontal: space.md,
1047
+ paddingVertical: 4,
1048
+ borderRadius: radius.pill,
1049
+ overflow: 'hidden'
1050
+ },
1051
+ amountLabel: {
1052
+ marginTop: space.sm,
1053
+ fontSize: font.sm + 1,
1054
+ color: colors.muted
1055
+ },
1056
+ amount: {
1057
+ fontSize: 32,
1058
+ fontWeight: '800',
1059
+ color: colors.text,
1060
+ letterSpacing: -0.5
1061
+ },
1062
+ merchant: {
1063
+ fontSize: font.md,
1064
+ color: colors.muted
1065
+ },
1066
+ chips: {
1067
+ flexDirection: 'row',
1068
+ flexWrap: 'wrap',
1069
+ gap: space.sm,
1070
+ marginTop: space.sm
1071
+ },
1072
+ chip: {
1073
+ paddingHorizontal: space.md,
1074
+ paddingVertical: 5,
1075
+ borderRadius: radius.pill,
1076
+ backgroundColor: colors.surfaceAlt
1077
+ },
1078
+ chipUrgent: {
1079
+ backgroundColor: colors.dangerBg
1080
+ },
1081
+ chipText: {
1082
+ fontSize: font.sm,
1083
+ fontWeight: '600',
1084
+ color: colors.muted
1085
+ },
1086
+ orderHead: {
1087
+ flexDirection: 'row',
1088
+ alignItems: 'center',
1089
+ justifyContent: 'space-between',
1090
+ marginTop: space.md,
1091
+ paddingTop: space.md,
1092
+ borderTopWidth: StyleSheet.hairlineWidth,
1093
+ borderTopColor: colors.border
1094
+ },
1095
+ orderTitle: {
1096
+ fontSize: font.md,
1097
+ fontWeight: '700',
1098
+ color: colors.text
1099
+ },
1100
+ orderToggle: {
1101
+ fontSize: font.sm + 1,
1102
+ fontWeight: '600',
1103
+ color: colors.blue
1104
+ },
1105
+ row: {
1106
+ flexDirection: 'row',
1107
+ justifyContent: 'space-between',
1108
+ gap: space.md,
1109
+ paddingVertical: 2
1110
+ },
1111
+ rowLabel: {
1112
+ color: colors.muted,
1113
+ fontSize: font.sm + 1
1114
+ },
1115
+ rowValue: {
1116
+ color: colors.text,
1117
+ fontSize: font.sm + 1,
1118
+ fontWeight: '600',
1119
+ flexShrink: 1,
1120
+ textAlign: 'right'
1121
+ },
1122
+ sectionTitle: {
1123
+ fontSize: font.lg,
1124
+ fontWeight: '700',
1125
+ color: colors.text,
1126
+ marginTop: space.sm
1127
+ },
1128
+ tile: {
1129
+ borderWidth: 1,
1130
+ borderColor: '#e5e9f2',
1131
+ borderRadius: radius.lg,
1132
+ overflow: 'hidden',
1133
+ backgroundColor: colors.surface
1134
+ },
1135
+ tileOn: {
1136
+ borderColor: colors.blue,
1137
+ borderWidth: 1.5
1138
+ },
1139
+ tileHead: {
1140
+ flexDirection: 'row',
1141
+ alignItems: 'center',
1142
+ gap: space.md,
1143
+ paddingHorizontal: space.lg,
1144
+ paddingVertical: 14,
1145
+ minHeight: 68
1146
+ },
1147
+ tileIcon: {
1148
+ width: 44,
1149
+ height: 44,
1150
+ borderRadius: 12,
1151
+ backgroundColor: '#f3f6fc',
1152
+ alignItems: 'center',
1153
+ justifyContent: 'center',
1154
+ overflow: 'hidden'
1155
+ },
1156
+ tileIconImg: {
1157
+ width: 34,
1158
+ height: 34
1159
+ },
1160
+ tileText: {
1161
+ flex: 1,
1162
+ gap: 2
1163
+ },
1164
+ tileLabel: {
1165
+ fontSize: font.md + 1,
1166
+ fontWeight: '700',
1167
+ color: colors.text
1168
+ },
1169
+ tileSub: {
1170
+ fontSize: font.sm,
1171
+ color: colors.faint
1172
+ },
1173
+ tileChevron: {
1174
+ fontSize: 22,
1175
+ color: colors.faint,
1176
+ paddingHorizontal: 4
1177
+ },
1178
+ tileBody: {
1179
+ paddingHorizontal: space.lg,
1180
+ paddingBottom: space.lg,
1181
+ paddingTop: space.xs,
1182
+ gap: space.md,
1183
+ borderTopWidth: StyleSheet.hairlineWidth,
1184
+ borderTopColor: '#e5e9f2'
1185
+ },
1186
+ logos: {
1187
+ flexDirection: 'row',
1188
+ gap: 4,
1189
+ alignItems: 'center'
1190
+ },
1191
+ tileLogo: {
1192
+ width: 30,
1193
+ height: 20
1194
+ },
1195
+ footer: {
1196
+ alignItems: 'center',
1197
+ gap: 6,
1198
+ marginTop: space.lg,
1199
+ marginBottom: space.lg
1200
+ },
1201
+ pci: {
1202
+ width: 64,
1203
+ height: 36
1204
+ },
1205
+ footerText: {
1206
+ fontSize: font.sm,
1207
+ color: colors.faint,
1208
+ textAlign: 'center'
1209
+ },
1210
+ form: {
1211
+ gap: space.md
1212
+ },
1213
+ subTitle: {
1214
+ fontWeight: '700',
1215
+ color: colors.text,
1216
+ fontSize: font.md
1217
+ },
1218
+ saved: {
1219
+ flexDirection: 'row',
1220
+ alignItems: 'center',
1221
+ gap: space.md,
1222
+ padding: space.md,
1223
+ borderWidth: 1,
1224
+ borderColor: colors.border,
1225
+ borderRadius: radius.md
1226
+ },
1227
+ savedLabel: {
1228
+ fontSize: font.md,
1229
+ color: colors.text,
1230
+ fontWeight: '600'
1231
+ },
1232
+ savedSub: {
1233
+ fontSize: font.sm,
1234
+ color: colors.faint
1235
+ },
1236
+ or: {
1237
+ textAlign: 'center',
1238
+ color: colors.faint,
1239
+ fontSize: font.sm,
1240
+ fontWeight: '600',
1241
+ letterSpacing: 0.5
1242
+ },
1243
+ grid2: {
1244
+ flexDirection: 'row',
1245
+ gap: space.md
1246
+ },
1247
+ radios: {
1248
+ gap: space.sm
1249
+ },
1250
+ discountLoading: {
1251
+ flexDirection: 'row',
1252
+ alignItems: 'center',
1253
+ gap: space.sm
1254
+ },
1255
+ discount: {
1256
+ gap: space.sm,
1257
+ padding: space.md,
1258
+ borderRadius: radius.md,
1259
+ backgroundColor: colors.successBg,
1260
+ borderWidth: 1,
1261
+ borderColor: colors.successBorder
1262
+ },
1263
+ divider: {
1264
+ height: StyleSheet.hairlineWidth,
1265
+ backgroundColor: colors.successBorder
1266
+ },
1267
+ codeBox: {
1268
+ padding: space.md,
1269
+ borderRadius: radius.md,
1270
+ backgroundColor: colors.surfaceAlt,
1271
+ gap: 4
1272
+ },
1273
+ codeLabel: {
1274
+ fontSize: font.sm,
1275
+ color: colors.muted
1276
+ },
1277
+ codeRow: {
1278
+ flexDirection: 'row',
1279
+ alignItems: 'center',
1280
+ justifyContent: 'space-between'
1281
+ },
1282
+ codeValue: {
1283
+ fontSize: font.xl,
1284
+ fontWeight: '700',
1285
+ color: colors.text,
1286
+ letterSpacing: 1
1287
+ },
1288
+ copy: {
1289
+ fontSize: font.xl,
1290
+ color: colors.blue
1291
+ },
1292
+ qrTitle: {
1293
+ fontWeight: '700',
1294
+ fontSize: font.lg,
1295
+ color: colors.text,
1296
+ textAlign: 'center'
1297
+ },
1298
+ option: {
1299
+ borderWidth: 1,
1300
+ borderColor: colors.border,
1301
+ borderRadius: radius.md,
1302
+ padding: space.sm,
1303
+ gap: space.sm
1304
+ },
1305
+ optionOn: {
1306
+ borderColor: colors.blue
1307
+ },
1308
+ optionBody: {
1309
+ gap: space.sm,
1310
+ paddingHorizontal: space.sm,
1311
+ paddingBottom: space.sm
1312
+ }
1313
+ });