@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,661 @@
1
+ "use strict";
2
+
3
+ import { useState } from 'react';
4
+ import { Pressable, StyleSheet, Text, View } from 'react-native';
5
+ import { DirectBankTransferController, DirectCardController, DirectEwalletController, DirectOneBillController, DirectQrController, DirectRtpEwalletController, DirectRtpNowController, WALLET_TYPES, formatAmountWhole } from '../core/index.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, DeclinedScreen, ErrorBanner, ErrorScreen, Note, OrderSummary, PendingApproval, QrCode, RetryBlocked, Screen, Segmented, SelectField, SheetHeader, Spinner, TextField } from '../ui.js';
10
+ import { StepUpView } from '../webviews.js';
11
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
12
+ function amountLabel(details) {
13
+ return `${details.currency} ${formatAmountWhole(details.amount)}`;
14
+ }
15
+ function useFinish(onFinish) {
16
+ const ref = useLatest(onFinish);
17
+ return result => ref.current(result);
18
+ }
19
+ function Busy({
20
+ label
21
+ }) {
22
+ return /*#__PURE__*/_jsx(View, {
23
+ style: styles.busy,
24
+ accessibilityRole: "progressbar",
25
+ accessibilityLabel: label,
26
+ children: /*#__PURE__*/_jsx(Spinner, {
27
+ dark: true,
28
+ large: true,
29
+ label: label
30
+ })
31
+ });
32
+ }
33
+
34
+ // ── E-wallet ─────────────────────────────────────────────────────────────
35
+
36
+ export function EwalletCheckout(props) {
37
+ const client = useSwichPayClient();
38
+ const services = useFlowServices(props.services);
39
+ const finish = useFinish(props.onFinish);
40
+ const [c, s] = useController(() => new DirectEwalletController(client, {
41
+ details: props.details,
42
+ onFinish: finish,
43
+ services
44
+ }));
45
+ useDismissHandler(() => c.dismiss());
46
+ return /*#__PURE__*/_jsxs(View, {
47
+ style: styles.fill,
48
+ children: [/*#__PURE__*/_jsx(SheetHeader, {
49
+ title: "Pay with Wallet",
50
+ onClose: () => c.cancel()
51
+ }), /*#__PURE__*/_jsxs(Screen, {
52
+ children: [/*#__PURE__*/_jsx(OrderSummary, {
53
+ item: s.details.item,
54
+ amount: amountLabel(s.details)
55
+ }), s.submitting ? /*#__PURE__*/_jsx(PendingApproval, {
56
+ message: "Enter MPIN on flash message or open your ewallet application and approve the request from approval/payment request sections"
57
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
58
+ children: [/*#__PURE__*/_jsx(ErrorBanner, {
59
+ message: s.error
60
+ }), /*#__PURE__*/_jsx(Segmented, {
61
+ label: "Wallet",
62
+ value: s.walletType,
63
+ options: WALLET_TYPES.map(w => ({
64
+ value: w.type,
65
+ label: w.label
66
+ })),
67
+ onChange: t => c.selectWallet(t)
68
+ }), /*#__PURE__*/_jsx(TextField, {
69
+ label: "Account Number",
70
+ keyboardType: "phone-pad",
71
+ autoComplete: "tel",
72
+ placeholder: "Enter account number",
73
+ value: s.account,
74
+ error: s.errors.account,
75
+ onValueChange: v => c.setAccount(v)
76
+ }), s.usedUpFailure ? /*#__PURE__*/_jsx(RetryBlocked, {
77
+ onClose: () => c.closeWithFailure()
78
+ }) : /*#__PURE__*/_jsx(Button, {
79
+ onPress: () => void c.submit(),
80
+ children: s.payLabel
81
+ })]
82
+ })]
83
+ })]
84
+ });
85
+ }
86
+
87
+ // ── Bank transfer ────────────────────────────────────────────────────────
88
+
89
+ export function BankTransferCheckout(props) {
90
+ const client = useSwichPayClient();
91
+ const services = useFlowServices(props.services);
92
+ const finish = useFinish(props.onFinish);
93
+ const [c, s] = useController(() => new DirectBankTransferController(client, {
94
+ details: props.details,
95
+ onFinish: finish,
96
+ services
97
+ }), ctrl => void ctrl.start());
98
+ useDismissHandler(() => c.dismiss());
99
+ return /*#__PURE__*/_jsxs(View, {
100
+ style: styles.fill,
101
+ children: [/*#__PURE__*/_jsx(SheetHeader, {
102
+ title: "Pay with Bank Account",
103
+ onClose: () => c.cancel()
104
+ }), /*#__PURE__*/_jsxs(Screen, {
105
+ children: [/*#__PURE__*/_jsx(OrderSummary, {
106
+ item: s.details.item,
107
+ amount: amountLabel(s.details)
108
+ }), /*#__PURE__*/_jsx(ErrorBanner, {
109
+ message: s.error
110
+ }), s.otpChallenge ? /*#__PURE__*/_jsxs(_Fragment, {
111
+ children: [/*#__PURE__*/_jsx(TextField, {
112
+ label: "Enter OTP",
113
+ keyboardType: "number-pad",
114
+ autoComplete: "one-time-code",
115
+ textContentType: "oneTimeCode",
116
+ placeholder: "6-digit code",
117
+ maxLength: 6,
118
+ value: s.otp,
119
+ editable: !s.submitting,
120
+ error: s.errors.otp,
121
+ onValueChange: v => c.setOtp(v)
122
+ }), /*#__PURE__*/_jsx(View, {
123
+ style: styles.right,
124
+ children: /*#__PURE__*/_jsx(Button, {
125
+ variant: "ghost",
126
+ disabled: s.resendSecondsLeft !== 0 || s.submitting,
127
+ onPress: () => void c.resendOtp(),
128
+ children: s.resendSecondsLeft === 0 ? 'Resend OTP' : `Resend OTP in ${s.resendSecondsLeft}s`
129
+ })
130
+ }), /*#__PURE__*/_jsx(Button, {
131
+ loading: s.submitting,
132
+ onPress: () => void c.confirmOtp(),
133
+ children: "CONFIRM"
134
+ })]
135
+ }) : s.loadingBanks ? /*#__PURE__*/_jsx(Busy, {
136
+ label: "Loading banks"
137
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
138
+ children: [/*#__PURE__*/_jsx(SelectField, {
139
+ label: "Bank",
140
+ placeholder: "Choose your bank",
141
+ value: s.selectedBankCode,
142
+ options: s.banks.map(b => ({
143
+ value: b.code,
144
+ label: b.name
145
+ })),
146
+ disabled: s.submitting,
147
+ error: s.errors.bank,
148
+ onValueChange: v => c.selectBank(v)
149
+ }), /*#__PURE__*/_jsx(TextField, {
150
+ label: "Account Number",
151
+ keyboardType: "number-pad",
152
+ placeholder: "Enter account number",
153
+ value: s.account,
154
+ editable: !s.submitting,
155
+ error: s.errors.account,
156
+ onValueChange: v => c.setAccount(v)
157
+ }), s.usedUpFailure ? /*#__PURE__*/_jsx(RetryBlocked, {
158
+ onClose: () => c.closeWithFailure()
159
+ }) : /*#__PURE__*/_jsx(Button, {
160
+ loading: s.submitting,
161
+ onPress: () => void c.requestOtp(),
162
+ children: s.payLabel
163
+ })]
164
+ })]
165
+ })]
166
+ });
167
+ }
168
+
169
+ // ── Card ─────────────────────────────────────────────────────────────────
170
+
171
+ export function CardCheckout(props) {
172
+ const client = useSwichPayClient();
173
+ const services = useFlowServices(props.services);
174
+ const finish = useFinish(props.onFinish);
175
+ const [c, s] = useController(() => new DirectCardController(client, {
176
+ details: props.details,
177
+ onFinish: finish,
178
+ services,
179
+ allowSaveCard: props.allowSaveCard ?? true
180
+ }));
181
+ useDismissHandler(() => c.dismiss());
182
+ if (s.declinedResult) return /*#__PURE__*/_jsx(DeclinedScreen, {
183
+ retryable: s.declinedResult.retryable,
184
+ message: s.declinedResult.message,
185
+ onClose: () => c.closeDeclined()
186
+ });
187
+ if (s.errorMessage != null) return /*#__PURE__*/_jsx(ErrorScreen, {
188
+ onClose: () => c.closeError()
189
+ });
190
+ const header = /*#__PURE__*/_jsx(SheetHeader, {
191
+ title: "Pay with Card",
192
+ onClose: () => c.cancel(),
193
+ closeDisabled: s.busy
194
+ });
195
+ const summary = /*#__PURE__*/_jsx(OrderSummary, {
196
+ item: s.details.item,
197
+ amount: amountLabel(s.details)
198
+ });
199
+ if (s.verifyingCard) {
200
+ return /*#__PURE__*/_jsxs(View, {
201
+ style: styles.fill,
202
+ children: [header, /*#__PURE__*/_jsxs(Screen, {
203
+ children: [summary, /*#__PURE__*/_jsxs(View, {
204
+ style: styles.busy,
205
+ accessibilityRole: "progressbar",
206
+ accessibilityLabel: "Verifying your card",
207
+ children: [/*#__PURE__*/_jsx(Spinner, {
208
+ dark: true,
209
+ large: true,
210
+ label: "Verifying your card"
211
+ }), /*#__PURE__*/_jsx(Text, {
212
+ style: styles.busyText,
213
+ children: "Verifying your card..."
214
+ })]
215
+ })]
216
+ })]
217
+ });
218
+ }
219
+ if (s.stepUp) {
220
+ return /*#__PURE__*/_jsxs(View, {
221
+ style: styles.fill,
222
+ children: [header, /*#__PURE__*/_jsxs(Screen, {
223
+ children: [summary, /*#__PURE__*/_jsx(StepUpView, {
224
+ challenge: s.stepUp,
225
+ isCompletionUrl: c.isStepUpReturnUrl,
226
+ onComplete: d => void c.completeStepUp(d)
227
+ })]
228
+ })]
229
+ });
230
+ }
231
+ if (s.checkingStatus) {
232
+ return /*#__PURE__*/_jsxs(View, {
233
+ style: styles.fill,
234
+ children: [header, /*#__PURE__*/_jsxs(Screen, {
235
+ children: [summary, /*#__PURE__*/_jsx(PendingApproval, {
236
+ message: s.statusMessage ?? 'Checking payment status...'
237
+ })]
238
+ })]
239
+ });
240
+ }
241
+ return /*#__PURE__*/_jsxs(View, {
242
+ style: styles.fill,
243
+ children: [header, /*#__PURE__*/_jsxs(Screen, {
244
+ children: [summary, /*#__PURE__*/_jsx(TextField, {
245
+ label: "Card no.",
246
+ keyboardType: "number-pad",
247
+ autoComplete: "cc-number",
248
+ textContentType: "creditCardNumber",
249
+ placeholder: "Enter card no.",
250
+ value: s.number,
251
+ editable: !s.busy,
252
+ error: s.errors.number,
253
+ suffix: s.number ? /*#__PURE__*/_jsx(BrandBadge, {
254
+ brand: s.brand
255
+ }) : undefined,
256
+ onValueChange: v => c.setNumber(v)
257
+ }), /*#__PURE__*/_jsxs(View, {
258
+ style: styles.row,
259
+ children: [/*#__PURE__*/_jsx(View, {
260
+ style: styles.col,
261
+ children: /*#__PURE__*/_jsx(TextField, {
262
+ label: "Expiry date",
263
+ keyboardType: "number-pad",
264
+ autoComplete: "cc-exp",
265
+ placeholder: "MM/YY",
266
+ maxLength: 5,
267
+ value: s.expiry,
268
+ editable: !s.busy,
269
+ error: s.errors.expiry,
270
+ onValueChange: v => c.setExpiry(v)
271
+ })
272
+ }), /*#__PURE__*/_jsx(View, {
273
+ style: styles.col,
274
+ children: /*#__PURE__*/_jsx(TextField, {
275
+ label: "CVC No.",
276
+ keyboardType: "number-pad",
277
+ autoComplete: "cc-csc",
278
+ secureTextEntry: true,
279
+ placeholder: "CVC",
280
+ maxLength: 4,
281
+ value: s.cvv,
282
+ editable: !s.busy,
283
+ error: s.errors.cvv,
284
+ onValueChange: v => c.setCvv(v)
285
+ })
286
+ })]
287
+ }), s.allowSaveCard ? /*#__PURE__*/_jsx(Checkbox, {
288
+ label: "Save this card for future payments",
289
+ checked: s.saveCard,
290
+ disabled: s.busy,
291
+ onChange: v => c.setSaveCard(v)
292
+ }) : null, /*#__PURE__*/_jsx(Button, {
293
+ loading: s.submitting,
294
+ onPress: () => void c.submit(),
295
+ children: s.payLabel
296
+ })]
297
+ })]
298
+ });
299
+ }
300
+
301
+ // ── 1Bill ────────────────────────────────────────────────────────────────
302
+
303
+ export function OneBillCheckout(props) {
304
+ const client = useSwichPayClient();
305
+ const services = useFlowServices(props.services);
306
+ const finish = useFinish(props.onFinish);
307
+ const [c, s] = useController(() => new DirectOneBillController(client, {
308
+ details: props.details,
309
+ onFinish: finish,
310
+ services
311
+ }));
312
+ useDismissHandler(() => c.dismiss());
313
+ const [copied, setCopied] = useState(false);
314
+ return /*#__PURE__*/_jsxs(View, {
315
+ style: styles.fill,
316
+ children: [/*#__PURE__*/_jsx(SheetHeader, {
317
+ title: "Pay via 1Bill",
318
+ onClose: () => c.cancel()
319
+ }), /*#__PURE__*/_jsxs(Screen, {
320
+ children: [/*#__PURE__*/_jsx(OrderSummary, {
321
+ item: s.details.item,
322
+ amount: amountLabel(s.details)
323
+ }), /*#__PURE__*/_jsx(ErrorBanner, {
324
+ message: s.error
325
+ }), s.consumerNumber == null ? /*#__PURE__*/_jsxs(_Fragment, {
326
+ children: [/*#__PURE__*/_jsx(TextField, {
327
+ label: "Mobile Number",
328
+ keyboardType: "phone-pad",
329
+ autoComplete: "tel",
330
+ placeholder: "Enter mobile number",
331
+ value: s.mobile,
332
+ editable: !s.submitting,
333
+ error: s.errors.mobile,
334
+ onValueChange: v => c.setMobile(v)
335
+ }), s.usedUpFailure ? /*#__PURE__*/_jsx(RetryBlocked, {
336
+ onClose: () => c.closeWithFailure()
337
+ }) : /*#__PURE__*/_jsx(Button, {
338
+ loading: s.submitting,
339
+ onPress: () => void c.generate(),
340
+ children: "GENERATE CONSUMER NUMBER"
341
+ })]
342
+ }) : s.expired ? /*#__PURE__*/_jsxs(_Fragment, {
343
+ children: [/*#__PURE__*/_jsx(ErrorBanner, {
344
+ message: "This consumer number has expired."
345
+ }), /*#__PURE__*/_jsx(Button, {
346
+ onPress: () => c.cancel(),
347
+ children: "CLOSE"
348
+ })]
349
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
350
+ children: [/*#__PURE__*/_jsxs(View, {
351
+ style: styles.codeBox,
352
+ children: [/*#__PURE__*/_jsx(Text, {
353
+ style: styles.codeLabel,
354
+ children: "Consumer Number"
355
+ }), /*#__PURE__*/_jsxs(View, {
356
+ style: styles.codeRow,
357
+ children: [/*#__PURE__*/_jsx(Text, {
358
+ style: styles.codeValue,
359
+ selectable: true,
360
+ children: s.consumerNumber
361
+ }), /*#__PURE__*/_jsx(Pressable, {
362
+ accessibilityRole: "button",
363
+ accessibilityLabel: "Copy",
364
+ hitSlop: 8,
365
+ onPress: () => void c.copyConsumerNumber().then(setCopied),
366
+ style: styles.copy,
367
+ children: /*#__PURE__*/_jsx(Text, {
368
+ style: styles.copyText,
369
+ children: "\u29C9"
370
+ })
371
+ })]
372
+ }), /*#__PURE__*/_jsxs(Text, {
373
+ style: styles.codeLabel,
374
+ accessibilityLiveRegion: "polite",
375
+ children: ["Time left: ", s.timeLeftLabel, copied ? ' · Copied' : '']
376
+ })]
377
+ }), s.statusMessage ? /*#__PURE__*/_jsx(Note, {
378
+ children: s.statusMessage
379
+ }) : null, /*#__PURE__*/_jsx(Button, {
380
+ loading: s.checkingStatus,
381
+ onPress: () => void c.checkStatus(),
382
+ children: "CHECK STATUS"
383
+ })]
384
+ })]
385
+ })]
386
+ });
387
+ }
388
+
389
+ // ── QR ───────────────────────────────────────────────────────────────────
390
+
391
+ export function QrCheckout(props) {
392
+ const client = useSwichPayClient();
393
+ const services = useFlowServices(props.services);
394
+ const finish = useFinish(props.onFinish);
395
+ const [c, s] = useController(() => new DirectQrController(client, {
396
+ details: props.details,
397
+ onFinish: finish,
398
+ services
399
+ }), ctrl => void ctrl.start());
400
+ useDismissHandler(() => c.dismiss());
401
+ return /*#__PURE__*/_jsxs(View, {
402
+ style: styles.fill,
403
+ children: [/*#__PURE__*/_jsx(SheetHeader, {
404
+ title: "Pay with QR",
405
+ onClose: () => c.cancel()
406
+ }), /*#__PURE__*/_jsxs(Screen, {
407
+ children: [/*#__PURE__*/_jsx(OrderSummary, {
408
+ item: s.details.item,
409
+ amount: amountLabel(s.details)
410
+ }), /*#__PURE__*/_jsx(ErrorBanner, {
411
+ message: s.error
412
+ }), s.generating ? /*#__PURE__*/_jsx(Busy, {
413
+ label: "Generating QR code"
414
+ }) : s.qrPayload ? /*#__PURE__*/_jsxs(_Fragment, {
415
+ children: [/*#__PURE__*/_jsx(QrCode, {
416
+ value: s.qrPayload
417
+ }), /*#__PURE__*/_jsxs(View, {
418
+ style: styles.linkRow,
419
+ children: [/*#__PURE__*/_jsx(Button, {
420
+ variant: "ghost",
421
+ onPress: () => void c.download(),
422
+ children: "\u2913 Download"
423
+ }), /*#__PURE__*/_jsx(Button, {
424
+ variant: "ghost",
425
+ onPress: () => void c.share(),
426
+ children: "\u2934 Share"
427
+ })]
428
+ }), s.statusMessage ? /*#__PURE__*/_jsx(Note, {
429
+ children: s.statusMessage
430
+ }) : null, /*#__PURE__*/_jsx(Button, {
431
+ loading: s.checkingStatus,
432
+ onPress: () => void c.checkStatus(),
433
+ children: "I'VE COMPLETED THE PAYMENT"
434
+ })]
435
+ }) : null]
436
+ })]
437
+ });
438
+ }
439
+
440
+ // ── RTP Now ──────────────────────────────────────────────────────────────
441
+
442
+ export function RtpNowCheckout(props) {
443
+ const client = useSwichPayClient();
444
+ const services = useFlowServices(props.services);
445
+ const finish = useFinish(props.onFinish);
446
+ const [c, s] = useController(() => new DirectRtpNowController(client, {
447
+ details: props.details,
448
+ onFinish: finish,
449
+ services
450
+ }), ctrl => void ctrl.start());
451
+ useDismissHandler(() => c.dismiss());
452
+ return /*#__PURE__*/_jsxs(View, {
453
+ style: styles.fill,
454
+ children: [/*#__PURE__*/_jsx(SheetHeader, {
455
+ title: "RTP Now",
456
+ onClose: () => c.cancel()
457
+ }), /*#__PURE__*/_jsxs(Screen, {
458
+ children: [/*#__PURE__*/_jsx(OrderSummary, {
459
+ item: s.details.item,
460
+ amount: amountLabel(s.details)
461
+ }), /*#__PURE__*/_jsx(ErrorBanner, {
462
+ message: s.error
463
+ }), s.loadingBanks ? /*#__PURE__*/_jsx(Busy, {
464
+ label: "Loading banks"
465
+ }) : s.submitting ? /*#__PURE__*/_jsx(PendingApproval, {
466
+ message: "Please approve the payment request on your banking application..."
467
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
468
+ children: [/*#__PURE__*/_jsx(Segmented, {
469
+ label: "Receive the request by",
470
+ value: s.mode,
471
+ options: [{
472
+ value: 'raastMobile',
473
+ label: 'Mobile'
474
+ }, {
475
+ value: 'raastIban',
476
+ label: 'IBAN'
477
+ }, {
478
+ value: 'bank',
479
+ label: 'Bank'
480
+ }],
481
+ onChange: m => c.setMode(m)
482
+ }), s.mode === 'raastMobile' ? /*#__PURE__*/_jsx(TextField, {
483
+ label: "Mobile Number",
484
+ keyboardType: "phone-pad",
485
+ placeholder: "Enter mobile number",
486
+ value: s.mobile,
487
+ error: s.errors.mobile,
488
+ onValueChange: v => c.setField('mobile', v)
489
+ }) : s.mode === 'raastIban' ? /*#__PURE__*/_jsx(TextField, {
490
+ label: "IBAN",
491
+ autoCapitalize: "characters",
492
+ autoCorrect: false,
493
+ placeholder: "Enter IBAN",
494
+ value: s.iban,
495
+ error: s.errors.iban,
496
+ onValueChange: v => c.setField('iban', v)
497
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
498
+ children: [/*#__PURE__*/_jsx(SelectField, {
499
+ label: "Bank",
500
+ placeholder: "Select bank",
501
+ value: s.selectedBankCode,
502
+ options: s.banks.map(b => ({
503
+ value: b.code,
504
+ label: b.name
505
+ })),
506
+ onValueChange: v => c.selectBank(v)
507
+ }), /*#__PURE__*/_jsx(TextField, {
508
+ label: "Account Number",
509
+ keyboardType: "number-pad",
510
+ placeholder: "Enter account number",
511
+ value: s.bankAccount,
512
+ error: s.errors.bankAccount,
513
+ onValueChange: v => c.setField('bankAccount', v)
514
+ })]
515
+ }), s.usedUpFailure ? /*#__PURE__*/_jsx(RetryBlocked, {
516
+ onClose: () => c.closeWithFailure()
517
+ }) : /*#__PURE__*/_jsx(Button, {
518
+ onPress: () => void c.submit(),
519
+ children: s.payLabel
520
+ })]
521
+ })]
522
+ })]
523
+ });
524
+ }
525
+
526
+ // ── RTP E-wallet ─────────────────────────────────────────────────────────
527
+
528
+ export function RtpEwalletCheckout(props) {
529
+ const client = useSwichPayClient();
530
+ const services = useFlowServices(props.services);
531
+ const finish = useFinish(props.onFinish);
532
+ const [c, s] = useController(() => new DirectRtpEwalletController(client, {
533
+ details: props.details,
534
+ onFinish: finish,
535
+ services
536
+ }), ctrl => void ctrl.start());
537
+ useDismissHandler(() => c.dismiss());
538
+ return /*#__PURE__*/_jsxs(View, {
539
+ style: styles.fill,
540
+ children: [/*#__PURE__*/_jsx(SheetHeader, {
541
+ title: "RTP E-Wallet",
542
+ onClose: () => c.cancel()
543
+ }), /*#__PURE__*/_jsxs(Screen, {
544
+ children: [/*#__PURE__*/_jsx(OrderSummary, {
545
+ item: s.details.item,
546
+ amount: amountLabel(s.details)
547
+ }), /*#__PURE__*/_jsx(ErrorBanner, {
548
+ message: s.error
549
+ }), s.loadingBanks ? /*#__PURE__*/_jsx(Busy, {
550
+ label: "Loading banks"
551
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
552
+ children: [/*#__PURE__*/_jsx(Segmented, {
553
+ label: "Pay with",
554
+ value: s.mode,
555
+ disabled: s.submitting,
556
+ options: [{
557
+ value: 'phone',
558
+ label: 'Phone'
559
+ }, {
560
+ value: 'iban',
561
+ label: 'IBAN'
562
+ }],
563
+ onChange: m => c.setMode(m)
564
+ }), /*#__PURE__*/_jsx(SelectField, {
565
+ label: "Bank",
566
+ placeholder: "Select bank",
567
+ value: s.selectedBankCode,
568
+ disabled: s.submitting,
569
+ options: s.banks.map(b => ({
570
+ value: b.code,
571
+ label: b.name
572
+ })),
573
+ onValueChange: v => c.selectBank(v)
574
+ }), /*#__PURE__*/_jsx(TextField, {
575
+ label: s.mode === 'phone' ? 'Mobile Number' : 'IBAN',
576
+ keyboardType: s.mode === 'phone' ? 'phone-pad' : 'default',
577
+ autoCapitalize: s.mode === 'phone' ? 'none' : 'characters',
578
+ placeholder: s.mode === 'phone' ? 'Enter mobile number' : 'Enter IBAN',
579
+ value: s.input,
580
+ editable: !s.submitting,
581
+ error: s.errors.input,
582
+ onValueChange: v => c.setInput(v)
583
+ }), s.usedUpFailure ? /*#__PURE__*/_jsx(RetryBlocked, {
584
+ onClose: () => c.closeWithFailure()
585
+ }) : /*#__PURE__*/_jsx(Button, {
586
+ loading: s.submitting,
587
+ onPress: () => void c.submit(),
588
+ children: s.payLabel
589
+ }), s.submitting ? /*#__PURE__*/_jsx(Note, {
590
+ children: s.mode === 'phone' ? '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.'
591
+ }) : null]
592
+ })]
593
+ })]
594
+ });
595
+ }
596
+ const styles = StyleSheet.create({
597
+ fill: {
598
+ flexGrow: 1,
599
+ flexShrink: 1,
600
+ backgroundColor: colors.surface
601
+ },
602
+ busy: {
603
+ alignItems: 'center',
604
+ justifyContent: 'center',
605
+ gap: space.md,
606
+ paddingVertical: space.xl
607
+ },
608
+ busyText: {
609
+ color: colors.muted,
610
+ fontSize: font.md
611
+ },
612
+ right: {
613
+ alignItems: 'flex-end'
614
+ },
615
+ row: {
616
+ flexDirection: 'row',
617
+ gap: space.md
618
+ },
619
+ col: {
620
+ flex: 1
621
+ },
622
+ linkRow: {
623
+ flexDirection: 'row',
624
+ justifyContent: 'center',
625
+ gap: space.sm
626
+ },
627
+ codeBox: {
628
+ padding: space.lg,
629
+ borderRadius: radius.md,
630
+ backgroundColor: colors.surfaceAlt,
631
+ gap: space.sm,
632
+ alignItems: 'center'
633
+ },
634
+ codeLabel: {
635
+ fontSize: font.sm + 1,
636
+ color: colors.muted
637
+ },
638
+ codeRow: {
639
+ flexDirection: 'row',
640
+ alignItems: 'center',
641
+ gap: space.md
642
+ },
643
+ codeValue: {
644
+ fontSize: font.xl + 2,
645
+ fontWeight: '700',
646
+ color: colors.text,
647
+ letterSpacing: 1
648
+ },
649
+ copy: {
650
+ width: 36,
651
+ height: 36,
652
+ borderRadius: 18,
653
+ alignItems: 'center',
654
+ justifyContent: 'center',
655
+ backgroundColor: colors.surface
656
+ },
657
+ copyText: {
658
+ fontSize: font.lg,
659
+ color: colors.blue
660
+ }
661
+ });