@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,263 @@
1
+ import type { SwichPayClient } from '../client.js';
2
+ import { PaymentCategory } from '../models/category.js';
3
+ import type { PaymentResult, ResolvedPaymentDetails } from '../models/payment.js';
4
+ import type { PaymentBank, PaymentChannel, PaymentSessionDetails, SavedCard, SavedWallet } from '../models/session.js';
5
+ import { type CardBrand } from '../utils/validators.js';
6
+ import { FlowController } from './controller.js';
7
+ import { type DiscountState } from './discount-lookup.js';
8
+ import { type StepUpChallenge } from './direct-card.js';
9
+ import { type CheckoutControllerOptions, type FieldErrors } from './shared.js';
10
+ /** 10 tries x 3 s is a 30 s ceiling for `CheckCardPaymentStatus`. */
11
+ export declare const SHEET_STATUS_MAX_ATTEMPTS = 10;
12
+ export declare const SHEET_STATUS_COOLDOWN_MS = 3000;
13
+ export declare const SUCCESS_SCREEN_MS = 1400;
14
+ export declare const TOAST_MS = 3000;
15
+ export type SheetPhase = 'loading' | 'startupError' | 'ready' | 'success' | 'expired' | 'declined';
16
+ export type RtpNowMethod = 'raast' | 'bankAccount';
17
+ /** Categories the sheet has a real form for; the rest show "isn't available yet". */
18
+ export declare const SHEET_SUPPORTED_CATEGORIES: ReadonlySet<PaymentCategory>;
19
+ export interface SheetCardState {
20
+ number: string;
21
+ expiry: string;
22
+ cvv: string;
23
+ saveCard: boolean;
24
+ brand: CardBrand;
25
+ selectedSavedCardId: number | null;
26
+ discount: DiscountState;
27
+ verifyingCard: boolean;
28
+ stepUp: StepUpChallenge | null;
29
+ checkingStatus: boolean;
30
+ statusMessage: string | null;
31
+ errors: FieldErrors<'number' | 'expiry' | 'cvv'>;
32
+ payLabel: string;
33
+ }
34
+ export interface SheetEwalletState {
35
+ /** Index into `session.channels` - channels can share a code, so identity matters. */
36
+ selectedChannelIndex: number | null;
37
+ selectedSavedWalletId: number | null;
38
+ account: string;
39
+ discount: DiscountState;
40
+ errors: FieldErrors<'account'>;
41
+ payLabel: string;
42
+ }
43
+ export interface SheetRtpEwalletState {
44
+ selectedBankName: string | null;
45
+ phoneMode: boolean;
46
+ input: string;
47
+ errors: FieldErrors<'input'>;
48
+ }
49
+ export interface SheetBankState {
50
+ selectedBankName: string | null;
51
+ cnic: string;
52
+ mobile: string;
53
+ account: string;
54
+ otp: string;
55
+ otpRequired: boolean;
56
+ errors: FieldErrors<'bank' | 'cnic' | 'mobile' | 'account' | 'otp'>;
57
+ }
58
+ export interface SheetOneBillState {
59
+ mobile: string;
60
+ consumerNumber: string | null;
61
+ errors: FieldErrors<'mobile'>;
62
+ }
63
+ export interface SheetQrState {
64
+ qrString: string | null;
65
+ loading: boolean;
66
+ error: string | null;
67
+ }
68
+ export interface SheetRtpNowState {
69
+ method: RtpNowMethod;
70
+ mobile: string;
71
+ iban: string;
72
+ selectedBankName: string | null;
73
+ account: string;
74
+ continueEnabled: boolean;
75
+ }
76
+ export interface OrderInfoRow {
77
+ label: string;
78
+ value: string;
79
+ }
80
+ export interface CategoryTile {
81
+ category: PaymentCategory;
82
+ label: string;
83
+ /** Logo URLs from `mobileappinit`; empty → show a fallback icon (RTP Now uses the bundled asset). */
84
+ logoUrls: string[];
85
+ supported: boolean;
86
+ }
87
+ export interface PaymentSheetState {
88
+ phase: SheetPhase;
89
+ /** User-facing startup failure ("Unable to start checkout"). */
90
+ startupError: string | null;
91
+ details: ResolvedPaymentDetails;
92
+ session: PaymentSessionDetails | null;
93
+ logos: Record<string, string>;
94
+ tiles: CategoryTile[];
95
+ expandedCategory: PaymentCategory | null;
96
+ orderInfoExpanded: boolean;
97
+ orderInfo: OrderInfoRow[];
98
+ amountLabel: string;
99
+ secondsLeft: number;
100
+ timeLeftLabel: string;
101
+ timeIsLow: boolean;
102
+ remainingAttempts: number;
103
+ submitting: boolean;
104
+ /** Any request or 3-D Secure step in flight - category switching is blocked. */
105
+ locked: boolean;
106
+ formError: string | null;
107
+ toast: string | null;
108
+ exitConfirmOpen: boolean;
109
+ declinedResult: PaymentResult | null;
110
+ payLabel: string;
111
+ banks: {
112
+ bankAccount: PaymentBank[];
113
+ rtpEwallet: PaymentBank[];
114
+ rtpNow: PaymentBank[];
115
+ };
116
+ card: SheetCardState;
117
+ ewallet: SheetEwalletState;
118
+ rtpEwallet: SheetRtpEwalletState;
119
+ bank: SheetBankState;
120
+ oneBill: SheetOneBillState;
121
+ qr: SheetQrState;
122
+ rtpNow: SheetRtpNowState;
123
+ /** Set once a submit was attempted per form - errors show from then on. */
124
+ submitted: Partial<Record<'card' | 'ewallet' | 'rtpEwallet' | 'bank' | 'bankOtp' | 'oneBill', boolean>>;
125
+ }
126
+ export interface PaymentSheetControllerOptions extends CheckoutControllerOptions {
127
+ /** Restricts which of the session's categories are displayed. */
128
+ categories?: readonly PaymentCategory[] | null;
129
+ timing?: Partial<{
130
+ ddcTimeoutMs: number;
131
+ statusMaxAttempts: number;
132
+ statusCooldownMs: number;
133
+ successScreenMs: number;
134
+ toastMs: number;
135
+ }>;
136
+ }
137
+ /** `widget.banks` scoped to a channel hint and deduped by name; unfiltered when nothing matches. */
138
+ export declare function banksFor(banks: readonly PaymentBank[], channelHint: string): PaymentBank[];
139
+ /**
140
+ * The built-in payment sheet:
141
+ * creates a session, then drives every category's form, the countdown, attempts, discounts,
142
+ * 3-D Secure and the exit confirmation. Resolves `null` on dismissal or startup failure.
143
+ */
144
+ export declare class PaymentSheetController extends FlowController<PaymentSheetState> {
145
+ private readonly client;
146
+ private readonly services;
147
+ private readonly timing;
148
+ private readonly categoriesFilter;
149
+ private readonly ewalletDiscount;
150
+ private readonly cardDiscount;
151
+ private sessionCreatedAt;
152
+ private countdown;
153
+ private toastTimer;
154
+ private cardVendorTransactionId;
155
+ private cardOrderId;
156
+ private started;
157
+ constructor(client: SwichPayClient, options: PaymentSheetControllerOptions);
158
+ private static initialState;
159
+ protected derive(s: PaymentSheetState): PaymentSheetState;
160
+ static validateCard(s: PaymentSheetState): SheetCardState['errors'];
161
+ static validateEwallet(s: PaymentSheetState): SheetEwalletState['errors'];
162
+ static validateRtpEwallet(s: PaymentSheetState): SheetRtpEwalletState['errors'];
163
+ static validateBank(s: PaymentSheetState): SheetBankState['errors'];
164
+ static validateBankOtp(s: PaymentSheetState): SheetBankState['errors'];
165
+ static validateOneBill(s: PaymentSheetState): SheetOneBillState['errors'];
166
+ /** Creates the session and loads logos in parallel; call once after creating the controller. */
167
+ start(): Promise<void>;
168
+ private computeSecondsLeft;
169
+ private tick;
170
+ protected onDispose(): void;
171
+ private get session();
172
+ private categoryId;
173
+ showToast(message: string): void;
174
+ private showFormError;
175
+ private attemptsExhausted;
176
+ private updateRemainingAttempts;
177
+ toggleOrderInfo(): void;
178
+ /** Blocked while anything is in flight, so two methods never race on shared state. */
179
+ toggleCategory(category: PaymentCategory): void;
180
+ /** The "X" / Escape / backdrop: asks "Exit checkout?" while the session is live. */
181
+ requestClose(): void;
182
+ /** Backdrop / Escape - same as the close button. */
183
+ dismiss(): void;
184
+ /** "Yes, Exit" cancels the session (best effort) and resolves `null`; "No, Continue" stays. */
185
+ confirmExit(exit: boolean): void;
186
+ /** "Return to Merchant" on the expired screen. */
187
+ returnToMerchant(): void;
188
+ /** "Close" on the declined screen. */
189
+ closeDeclined(): void;
190
+ /** "OK" on the startup error. */
191
+ dismissStartupError(): void;
192
+ /** The tile of a category without a form: "<label> isn't available yet." */
193
+ submitUnsupported(category: PaymentCategory): void;
194
+ private finishSubmit;
195
+ /** Runs a submit with the shared `submitting` / error handling of every submit method. */
196
+ private runSubmit;
197
+ private canSubmit;
198
+ private patchCard;
199
+ setCardNumber(value: string): void;
200
+ setCardExpiry(value: string): void;
201
+ setCardCvv(value: string): void;
202
+ setSaveCard(saveCard: boolean): void;
203
+ /** Tapping a saved card selects it (prefilling masked values); tapping it again clears it. */
204
+ selectSavedCard(id: number): void;
205
+ clearSavedCard(): void;
206
+ savedCardLabel(card: SavedCard): string;
207
+ /** Discounts never run for a saved card, and only once number, expiry and CVC are all valid. */
208
+ private onCardChanged;
209
+ isThreeDsReturnUrl: (url: URL) => boolean;
210
+ submitCard(): Promise<void>;
211
+ private attemptCardSubmit;
212
+ /**
213
+ * The challenge finished (message, readable return URL, or the manual button): poll
214
+ * `checkCardPaymentStatus` until success, a terminal failure, or the attempt cap.
215
+ */
216
+ completeThreeDs(eventData?: string): Promise<void>;
217
+ private patchEwallet;
218
+ get selectedChannel(): PaymentChannel | null;
219
+ setEwalletAccount(value: string): void;
220
+ selectChannel(index: number): void;
221
+ /** Prefills the msisdn (read-only, may be masked) and the matching channel. */
222
+ selectSavedWallet(id: number): void;
223
+ savedWalletLabel(wallet: SavedWallet): string;
224
+ /** The channel a saved wallet belongs to, for its name/logo. */
225
+ channelForSavedWallet(wallet: SavedWallet): PaymentChannel | null;
226
+ private onEwalletChanged;
227
+ submitEwallet(): Promise<void>;
228
+ private patchRtpEwallet;
229
+ selectRtpEwalletBank(name: string | null): void;
230
+ setRtpEwalletPhoneMode(phoneMode: boolean): void;
231
+ setRtpEwalletInput(value: string): void;
232
+ submitRtpEwallet(): Promise<void>;
233
+ private patchBank;
234
+ selectBank(name: string | null): void;
235
+ setBankField(field: 'cnic' | 'mobile' | 'account' | 'otp', value: string): void;
236
+ private selectedBank;
237
+ submitBankAccount(): Promise<void>;
238
+ verifyBankOtp(): Promise<void>;
239
+ setOneBillMobile(value: string): void;
240
+ submitOneBill(): Promise<void>;
241
+ /** "Verify Payment" - a "consumer number found" message means it's still pending. */
242
+ verifyOneBill(): Promise<void>;
243
+ copyConsumerNumber(): Promise<void>;
244
+ private patchQr;
245
+ /** "Generate QR Code" / "Try Again". */
246
+ loadQr(category: PaymentCategory): Promise<void>;
247
+ /** "I've Paid — Verify". */
248
+ verifyQr(category: PaymentCategory): Promise<void>;
249
+ downloadQr(): Promise<void>;
250
+ shareQr(): Promise<void>;
251
+ private patchRtpNow;
252
+ setRtpNowMethod(method: RtpNowMethod): void;
253
+ setRtpNowField(field: 'mobile' | 'iban' | 'account', value: string): void;
254
+ selectRtpNowBank(name: string | null): void;
255
+ /** Sends only the fields of the selected receive method. */
256
+ submitRtpNow(): Promise<void>;
257
+ }
258
+ /**
259
+ * Fills `payload.{cardNumber,cvc,year,month}` with masked placeholders where the backend left them
260
+ * null for a saved card - PaymentEnrollment 400s on an incomplete payload.
261
+ */
262
+ export declare function maskedPaymentSetup(paymentSetup: Record<string, unknown>, savedCard: SavedCard): Record<string, unknown>;
263
+ //# sourceMappingURL=payment-sheet.d.ts.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Side effects the checkout controllers need. The defaults use browser APIs, touched only when
3
+ * called (never at import), so controllers are SSR-safe. Tests pass fakes.
4
+ */
5
+ export interface FlowServices {
6
+ /** POSTs `formFields` to `url` in a hidden iframe; `true` on `profile.complete`, `false` on timeout. */
7
+ runDeviceDataCollection(input: {
8
+ url: string;
9
+ formFields: Record<string, string>;
10
+ timeoutMs: number;
11
+ }): Promise<boolean>;
12
+ copyText(text: string): Promise<void>;
13
+ downloadQr(payload: string): Promise<void>;
14
+ /** `'downloaded'` when the Web Share API can't share files and a download was used instead. */
15
+ shareQr(payload: string): Promise<'shared' | 'downloaded'>;
16
+ uuid(): string;
17
+ sleep(ms: number): Promise<void>;
18
+ now(): number;
19
+ }
20
+ export declare const defaultFlowServices: FlowServices;
21
+ export declare function resolveServices(overrides?: Partial<FlowServices>): FlowServices;
22
+ //# sourceMappingURL=services.d.ts.map
@@ -0,0 +1,40 @@
1
+ import type { PaymentDetails, PaymentResult, ResolvedPaymentDetails } from '../models/payment.js';
2
+ import type { FlowServices } from './services.js';
3
+ export type FieldErrors<K extends string> = Partial<Record<K, string>>;
4
+ export interface FormMeta<K extends string> {
5
+ /** Fields the user has edited - their errors show immediately. */
6
+ touched: Partial<Record<K, boolean>>;
7
+ /** Set by a submit attempt - every error shows. */
8
+ submitted: boolean;
9
+ }
10
+ export declare function visibleErrors<K extends string>(all: FieldErrors<K>, meta: FormMeta<K>): FieldErrors<K>;
11
+ export declare function hasErrors(errors: Record<string, string | undefined>): boolean;
12
+ /** Common options for every checkout controller. */
13
+ export interface CheckoutControllerOptions {
14
+ details: PaymentDetails;
15
+ onFinish?: (result: PaymentResult | null) => void;
16
+ services?: Partial<FlowServices>;
17
+ }
18
+ export declare function resolveDetails(details: PaymentDetails): ResolvedPaymentDetails;
19
+ /** The direct sheets' pay button: `MAKE PAYMENT PKR 1000` (amount rounded to a whole number). */
20
+ export declare function directPayLabel(details: Pick<PaymentDetails, 'currency' | 'amount'>): string;
21
+ /**
22
+ * Redirect-based 3-D Secure challenges (no `postMessage`) finish by navigating back to SwichPay /
23
+ * JazzCash, to Meezan's `/3ds2/challenge/` page, or to the merchant's redirect URLs.
24
+ */
25
+ export declare function isThreeDsReturnUrl(url: URL, details: Pick<PaymentDetails, 'successRedirectUrl' | 'failedRedirectUrl'>): boolean;
26
+ export declare const PENDING_APPROVAL_TITLE = "Payment Initiated";
27
+ export declare const RETRY_BLOCKED_MESSAGE = "To try again, close this and start a new payment.";
28
+ export declare const SUPPORT_PHONE = "+92 319 1234567";
29
+ /** Visual style of the built-in checkouts: `default` (payment sheet) or `classic` (SwichPay payment page). */
30
+ export type CheckoutLook = 'default' | 'classic';
31
+ /** `dd-MM-yyyy`, as the PWA payment page shows dates. */
32
+ export declare function formatDateDMY(isoDate: string | null | undefined, now?: Date): string;
33
+ /** The six fields of the PWA page header, in its order (Swich.CardPayment HostedCheckOut.cshtml). */
34
+ export declare function pwaHeaderCells(details: Pick<PaymentDetails, 'merchantName' | 'consumerName' | 'date' | 'orderNumber' | 'currency' | 'amount' | 'description' | 'item'>): {
35
+ label: string;
36
+ value: string;
37
+ }[];
38
+ /** The PWA's pay button text: `Make Payment PKR 10`. */
39
+ export declare function pwaPayLabel(currency: string, amount: number): string;
40
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1,37 @@
1
+ import type { AccessToken, SwichPayConfig } from '../config.js';
2
+ import type { JsonMap } from '../utils/json.js';
3
+ /** OAuth2 `client_credentials` exchange. */
4
+ export declare function fetchClientCredentialsToken(input: {
5
+ fetch: typeof fetch;
6
+ authHost: string;
7
+ clientId: string;
8
+ clientSecret: string;
9
+ timeoutMs?: number;
10
+ log?: (message: string) => void;
11
+ }): Promise<AccessToken>;
12
+ /**
13
+ * Thin wrapper around the SwichPay hosts: picks the host and headers per
14
+ * call, authenticates per the configured auth mode, and replays once with a fresh token on 401.
15
+ */
16
+ export declare class ApiClient {
17
+ private readonly config;
18
+ private readonly tokens;
19
+ constructor(config: SwichPayConfig);
20
+ private static createTokenManager;
21
+ /** `Authorization: Bearer` when a token source exists, `x-public-key` otherwise, nothing via a proxy. */
22
+ private authHeaders;
23
+ private gatewayHeaders;
24
+ private requireHost;
25
+ private request;
26
+ /** Checkout host. `extraHeaders` carries the per-endpoint public-key header. */
27
+ post(path: string, body: JsonMap, extraHeaders?: Record<string, string>): Promise<JsonMap>;
28
+ /** Gateway host GET. */
29
+ get(path: string, query?: Record<string, string>): Promise<JsonMap>;
30
+ /** Gateway host POST. */
31
+ postToGateway(path: string, body: JsonMap): Promise<JsonMap>;
32
+ /** Payment API host (direct card flow). */
33
+ postToPaymentApi(path: string, body: JsonMap): Promise<JsonMap>;
34
+ /** Discount host; short timeout since it runs while the user types. */
35
+ postToDiscount(path: string, body: JsonMap): Promise<JsonMap>;
36
+ }
37
+ //# sourceMappingURL=api-client.d.ts.map
@@ -0,0 +1,39 @@
1
+ /** Every SwichPay API endpoint path the SDK calls. */
2
+ export declare const Endpoints: {
3
+ /** Validates the client id / referrer pair. */
4
+ readonly init: "/init";
5
+ /** `SwichPay.pay` card payment. */
6
+ readonly iframePayment: "/iframe/Payment";
7
+ readonly token: "/connect/token";
8
+ readonly mobileAppInit: "/gateway/paymentsession/mobileappinit";
9
+ readonly createPaymentSession: "/gateway/paymentsession/initiate";
10
+ readonly processPayment: "/gateway/PaymentSession/ProcessPayment";
11
+ readonly paymentEnrollment: "/gateway/PaymentSession/PaymentEnrollment";
12
+ readonly checkCardPaymentStatus: "/gateway/PaymentSession/CheckCardPaymentStatus";
13
+ readonly inquirePaymentSession: "/gateway/paymentsession/inquire";
14
+ readonly getPaymentSession: "/gateway/paymentsession/get";
15
+ readonly cancelPaymentSession: "/gateway/paymentsession/cancel";
16
+ readonly directEwallet: "/gateway/payin/purchase/ewallet";
17
+ readonly directBankOtp: "/gateway/payin/bank/otp";
18
+ readonly directBankConfirm: "/gateway/payin/bank/transfer";
19
+ readonly directBankList: "/gateway/payin/get/banks";
20
+ readonly directRtpNowBanks: "/gateway/payin/rtp/now/get/banks";
21
+ readonly directRtpEwalletBanks: "/gateway/payin/get/walletbanks";
22
+ /** RTP Now *and* RTP E-wallet (same path, different body). */
23
+ readonly directRtpPurchase: "/gateway/payin/v2.0/purchase/rtp/now";
24
+ readonly directQrGenerate: "/gateway/payin/purchase/qr/dynamic";
25
+ readonly directQrInquire: "/gateway/payin/purchase/qr/dynamic/inquire";
26
+ readonly directBiller: "/gateway/payin/purchase/biller";
27
+ readonly directBillerInquire: "/gateway/payin/inquire";
28
+ readonly directCardPayment: "/api/Payment/PaymentV3";
29
+ /** Not `/api/Payment/TokenizedPaymentV3` (404s - verified against SwichPay's swagger). */
30
+ readonly directCardTokenizedPayment: "/api/Payment/v3/CompleteTokenPayment";
31
+ readonly directCardInquire: "/api/Payment/InquireV3";
32
+ readonly getDiscount: "/api/Discount/GetDiscount";
33
+ };
34
+ export type ServiceName = 'checkout' | 'gateway' | 'auth' | 'paymentApi' | 'discount';
35
+ /** Which endpoints live on which host - also the server proxy's allowlist. */
36
+ export declare const SERVICE_ENDPOINTS: Readonly<Record<ServiceName, readonly string[]>>;
37
+ /** URL path segment used by `proxyUrl` for each service. */
38
+ export declare const PROXY_SEGMENTS: Readonly<Record<ServiceName, string>>;
39
+ //# sourceMappingURL=endpoints.d.ts.map
@@ -0,0 +1,19 @@
1
+ import type { AccessToken } from '../config.js';
2
+ /** Refresh this long before the real expiry, so a request never starts on a dying token. */
3
+ export declare const TOKEN_EXPIRY_BUFFER_MS = 60000;
4
+ /**
5
+ * Caches a bearer token until shortly before it expires and shares one in-flight fetch between
6
+ * concurrent callers. Used by the client and the proxy.
7
+ */
8
+ export declare class TokenManager {
9
+ private readonly fetchToken;
10
+ private readonly now;
11
+ private cached;
12
+ private expiresAt;
13
+ private inFlight;
14
+ constructor(fetchToken: () => Promise<AccessToken>, now?: () => number);
15
+ getToken(): Promise<string>;
16
+ /** Drops the cached token (a 401 means the server no longer accepts it). */
17
+ invalidate(): void;
18
+ }
19
+ //# sourceMappingURL=token-manager.d.ts.map
@@ -0,0 +1,37 @@
1
+ import { SwichPayApiException } from '../errors.js';
2
+ import { type SwichPayLogger } from '../utils/log.js';
3
+ import { type JsonMap } from '../utils/json.js';
4
+ export type HttpMethod = 'GET' | 'POST';
5
+ export interface HttpRequest {
6
+ method: HttpMethod;
7
+ url: string;
8
+ query?: Record<string, string>;
9
+ headers?: Record<string, string>;
10
+ /** JSON body. */
11
+ json?: JsonMap;
12
+ /** `application/x-www-form-urlencoded` body. */
13
+ form?: Record<string, string>;
14
+ timeoutMs: number;
15
+ /** Sent as fetch's `referrer` in browsers when same-origin (browsers forbid the header). */
16
+ referrer?: string;
17
+ }
18
+ export interface HttpResponse {
19
+ status: number;
20
+ json: JsonMap;
21
+ }
22
+ /** GET retries after the first attempt, on connection errors / 5xx only. */
23
+ export declare const MAX_GET_RETRIES = 2;
24
+ export declare function buildUrl(url: string, query?: Record<string, string>): string;
25
+ /**
26
+ * Picks the error message: `message`, then ASP.NET
27
+ * `errors` (field-level detail), then `title`, then a generic default.
28
+ */
29
+ export declare function apiErrorMessage(json: JsonMap): string;
30
+ export declare function apiExceptionFrom(status: number, json: JsonMap): SwichPayApiException;
31
+ /**
32
+ * Sends one HTTP request: bounded GET-only retry on
33
+ * connection errors and 5xx, every non-2xx mapped to `SwichPayApiException`, every transport
34
+ * failure mapped to `SwichPayNetworkException`, and lenient JSON parsing.
35
+ */
36
+ export declare function sendRequest(fetchImpl: typeof fetch, request: HttpRequest, log: SwichPayLogger): Promise<HttpResponse>;
37
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1,42 @@
1
+ /**
2
+ * SwichPay SDK core: API client, models, validation and payment flows.
3
+ */
4
+ export declare const SDK_VERSION = "1.0.0";
5
+ export { SwichPay } from './swichpay.js';
6
+ export { SwichPayClient, validateCard, type SwichPayClientDependencies } from './client.js';
7
+ export { type Subscription } from './events.js';
8
+ export { Environment, ENVIRONMENT_HOSTS, type SwichPayHosts } from './environment.js';
9
+ export { DEFAULT_TIMEOUTS, resolveConfig, type AccessToken, type AuthMode, type ChecksumInput, type SwichPayConfig, type SwichPayOptions, type SwichPayTimeouts, } from './config.js';
10
+ export { SwichPayApiException, SwichPayException, SwichPayNetworkException, SwichPayNotInitializedException, SwichPayValidationException, attemptUsedTransactionId, isSwichPayException, swichpayUserError, swichpayUserMessage, type SwichPayApiExceptionInit, type SwichPayErrorKind, } from './errors.js';
11
+ export { ALL_PAYMENT_CATEGORIES, PaymentCategory, isPaymentCategory, paymentCategoryCode, paymentCategoryFromApiValue, paymentCategoryLabel, paymentCategoryLogoNames, } from './models/category.js';
12
+ export { cancelledResult, createPaymentResult, failedResult, resolvePaymentDetails, type CardDetails, type PaymentDetails, type PaymentResult, type ResolvedPaymentDetails, } from './models/payment.js';
13
+ export { maskedSavedCard, maskedSavedWallet, parsePaymentSessionDetails, parsePaymentSessionInquiryResult, type DirectBank, type MobileAppInitResult, type PaymentBank, type PaymentChannel, type PaymentSessionDetails, type PaymentSessionInquiryResult, type SavedCard, type SavedWallet, } from './models/session.js';
14
+ export { discountRequestToJson, isDiscountUsableFor, parseDiscountResult, type DiscountRequest, type DiscountResult, } from './models/discount.js';
15
+ export { ApiClient, fetchClientCredentialsToken } from './http/api-client.js';
16
+ export { Endpoints, SERVICE_ENDPOINTS, type ServiceName } from './http/endpoints.js';
17
+ export { TokenManager } from './http/token-manager.js';
18
+ export { GatewayApi, parseCardStatusResult, parseGatewayResult, processPaymentBody } from './api/gateway-api.js';
19
+ export type { ProcessBankAccountPaymentInput, ProcessBillerPaymentInput, ProcessCardPaymentInput, ProcessEwalletPaymentInput, ProcessQrPaymentInput, ProcessRtpNowPaymentInput, SubmitPaymentEnrollmentInput, } from './api/gateway-api.js';
20
+ export { DirectPaymentApi, extractVendorMessage, parseDirectCardResult, parseDirectCardStatus, parseDirectPaymentResponse, parseRtpResponse, parseTokenizedPaymentResult, } from './api/direct-payment-api.js';
21
+ export { PaymentsApi, parseCheckoutPaymentResult } from './api/payments-api.js';
22
+ export { DiscountApi } from './api/discount-api.js';
23
+ export type { DirectPaymentRepository, DiscountRepository, GatewayRepository, PaymentsRepository } from './api/repositories.js';
24
+ export { AccountValidators, CardValidators, parseExpiry, type CardBrand } from './utils/validators.js';
25
+ export { dartDoubleString, digitsOnly, formatAmount, formatAmountWhole, formatCardNumber, formatCountdown, formatExpiry, maskForDisplay, todayIsoDate, } from './utils/formatters.js';
26
+ export { decodeJwtClaim, generateTransactionCheckSum, generateUuidV4 } from './utils/crypto.js';
27
+ export { redactForLog, SENSITIVE_DATA_KEYS, type SwichPayLogger } from './utils/log.js';
28
+ export { isBrowser } from './utils/runtime.js';
29
+ export { FlowController, type FinishHandler, type Listener } from './flows/controller.js';
30
+ export { CountdownController, type CountdownState } from './flows/countdown.js';
31
+ export { DiscountLookup, DISCOUNT_DEBOUNCE_MS, type DiscountState } from './flows/discount-lookup.js';
32
+ export { defaultFlowServices, resolveServices, type FlowServices } from './flows/services.js';
33
+ export { directPayLabel, formatDateDMY, isThreeDsReturnUrl, pwaHeaderCells, pwaPayLabel, type CheckoutLook, PENDING_APPROVAL_TITLE, RETRY_BLOCKED_MESSAGE, SUPPORT_PHONE, type CheckoutControllerOptions, type FieldErrors, } from './flows/shared.js';
34
+ export { DirectEwalletController, WALLET_TYPES, type DirectEwalletState, type WalletType } from './flows/direct-ewallet.js';
35
+ export { runHeadlessCardPayment, runHeadlessWalletPayment, type HeadlessCardInput, type StepUpPresenter, type WalletName } from './flows/headless.js';
36
+ export { DirectRtpEwalletController, DirectRtpNowController, type DirectRtpEwalletState, type DirectRtpNowState, type RtpEwalletMode, type RtpNowMode, } from './flows/direct-rtp.js';
37
+ export { DirectBankTransferController, OTP_RESEND_SECONDS, type DirectBankTransferState } from './flows/direct-bank-transfer.js';
38
+ export { DirectOneBillController, type DirectOneBillState } from './flows/direct-one-bill.js';
39
+ export { DirectQrController, type DirectQrState } from './flows/direct-qr.js';
40
+ export { DirectCardController, DDC_TIMEOUT_MS, DIRECT_CARD_MAX_POLLS, DIRECT_CARD_POLL_INTERVAL_MS, type DirectCardControllerOptions, type DirectCardState, type StepUpChallenge, } from './flows/direct-card.js';
41
+ export { PaymentSheetController, SHEET_STATUS_COOLDOWN_MS, SHEET_STATUS_MAX_ATTEMPTS, SHEET_SUPPORTED_CATEGORIES, banksFor, maskedPaymentSetup, type CategoryTile, type OrderInfoRow, type PaymentSheetControllerOptions, type PaymentSheetState, type RtpNowMethod, type SheetPhase, } from './flows/payment-sheet.js';
42
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,35 @@
1
+ /** A payment method category. Values are the Dart enum names. */
2
+ export declare const PaymentCategory: {
3
+ /** Local-only - opens the hosted checkout page full-screen. */
4
+ readonly paymentSession: "paymentSession";
5
+ /** Local-only - opens the hosted checkout page in a sheet. */
6
+ readonly paymentSessionSheet: "paymentSessionSheet";
7
+ /** Local-only - opens the SDK's direct card checkout. */
8
+ readonly sdkCheckout: "sdkCheckout";
9
+ readonly ewallet: "ewallet";
10
+ readonly biller: "biller";
11
+ readonly bankAccount: "bankAccount";
12
+ readonly visaMasterCardPayment: "visaMasterCardPayment";
13
+ readonly unionPayCardPayment: "unionPayCardPayment";
14
+ readonly dqrcPayment: "dqrcPayment";
15
+ readonly sqrcPayment: "sqrcPayment";
16
+ readonly rtpNowPayment: "rtpNowPayment";
17
+ readonly rtpLaterPayment: "rtpLaterPayment";
18
+ readonly tokenization: "tokenization";
19
+ readonly rtpEwalletPayment: "rtpEwalletPayment";
20
+ readonly bnpl: "bnpl";
21
+ /** An unrecognized category id, kept instead of dropped. */
22
+ readonly unknown: "unknown";
23
+ };
24
+ export type PaymentCategory = (typeof PaymentCategory)[keyof typeof PaymentCategory];
25
+ export declare const ALL_PAYMENT_CATEGORIES: readonly PaymentCategory[];
26
+ /** Parses a raw category id from the API, falling back to `unknown`. Exact match. */
27
+ export declare function paymentCategoryFromApiValue(value: unknown): PaymentCategory;
28
+ /** The raw category id the API uses; empty for local-only categories. */
29
+ export declare function paymentCategoryCode(category: PaymentCategory): string;
30
+ /** Human-readable label for a button. */
31
+ export declare function paymentCategoryLabel(category: PaymentCategory): string;
32
+ /** `logos[].name` values that belong to this category. */
33
+ export declare function paymentCategoryLogoNames(category: PaymentCategory): readonly string[];
34
+ export declare function isPaymentCategory(value: unknown): value is PaymentCategory;
35
+ //# sourceMappingURL=category.d.ts.map
@@ -0,0 +1,41 @@
1
+ import { type JsonMap } from '../utils/json.js';
2
+ /** Request body for `POST /api/Discount/GetDiscount`. */
3
+ export interface DiscountRequest {
4
+ amount: number;
5
+ referenceValue: string;
6
+ merchantId: number;
7
+ customerTransactionId: string;
8
+ msisdn: string;
9
+ /** A category name (e.g. `"Ewallet"`, `"CardBins"`), not a numeric id. Default `"Ewallet"`. */
10
+ categoryId?: string;
11
+ /** Default `""`. */
12
+ ipAddress?: string;
13
+ /** Default now. */
14
+ txnDate?: Date;
15
+ /** Default `amount`. */
16
+ discountableAmount?: number;
17
+ }
18
+ /** Wire body - note the API's own spelling `refrenceValue`. */
19
+ export declare function discountRequestToJson(request: DiscountRequest): JsonMap;
20
+ /** Response from `POST /api/Discount/GetDiscount`. */
21
+ export interface DiscountResult {
22
+ applied: boolean;
23
+ transactionAmount: number;
24
+ discountAmount: number;
25
+ finalAmount: number;
26
+ campaignMasterId: number | null;
27
+ campaignDetailId: number | null;
28
+ merchantId: number | null;
29
+ customerTransactionId: string | null;
30
+ ruleType: string | null;
31
+ /** Coerced to a string - the wire type varies. */
32
+ categoryId: string | null;
33
+ appliedOn: string | null;
34
+ }
35
+ export declare function parseDiscountResult(json: JsonMap): DiscountResult;
36
+ /**
37
+ * Whether `result` is safe to apply against `requestedAmount` - guards against a stale or
38
+ * malformed response producing a zero, negative or amount-increasing total.
39
+ */
40
+ export declare function isDiscountUsableFor(result: DiscountResult, requestedAmount: number): boolean;
41
+ //# sourceMappingURL=discount.d.ts.map