@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,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
@@ -0,0 +1,104 @@
1
+ /** Order, customer and redirect details for a single payment attempt. */
2
+ export interface PaymentDetails {
3
+ orderNumber: string;
4
+ customerTransactionId: string;
5
+ billReferenceNo: string;
6
+ /** Display-only; shown in the order summary, not sent to the checkout API. */
7
+ merchantName: string;
8
+ consumerName: string;
9
+ amount: number;
10
+ currency: string;
11
+ email: string;
12
+ msisdn: string;
13
+ cnic: string;
14
+ item: string;
15
+ successRedirectUrl: string;
16
+ failedRedirectUrl: string;
17
+ /** Defaults to `item`. */
18
+ description?: string | null;
19
+ /** `yyyy-MM-dd`. Defaults to today. */
20
+ date?: string | null;
21
+ successRedirectParam?: string | null;
22
+ /** Default 0. */
23
+ discountAmount?: number;
24
+ /** Default false. */
25
+ isRecurringPayment?: boolean;
26
+ /** Payment attempts allowed on a created session, 1-10. Default 10. */
27
+ attempts?: number;
28
+ /** Minutes a created session stays valid, 1-30. Default 10. */
29
+ expiryMinutes?: number;
30
+ /** Reuses an existing customer record from a previous session. */
31
+ merchantCustomerToken?: string | null;
32
+ /** Auto-capture on success instead of authorize-only. Default false. */
33
+ doCapture?: boolean;
34
+ }
35
+ /** `PaymentDetails` with every default applied. */
36
+ export interface ResolvedPaymentDetails extends PaymentDetails {
37
+ description: string | null;
38
+ date: string | null;
39
+ successRedirectParam: string | null;
40
+ discountAmount: number;
41
+ isRecurringPayment: boolean;
42
+ attempts: number;
43
+ expiryMinutes: number;
44
+ merchantCustomerToken: string | null;
45
+ doCapture: boolean;
46
+ }
47
+ /**
48
+ * Applies the defaults and checks the required fields at runtime
49
+ * (`required` named parameters), so plain-JavaScript callers get the same contract.
50
+ */
51
+ export declare function resolvePaymentDetails(details: PaymentDetails): ResolvedPaymentDetails;
52
+ /** Raw card details - never logged or persisted. */
53
+ export interface CardDetails {
54
+ number: string;
55
+ expMonth: number;
56
+ expYear: number;
57
+ cvv: string;
58
+ }
59
+ /** Outcome of a payment attempt. */
60
+ export interface PaymentResult {
61
+ isSuccess: boolean;
62
+ /** Raw status, e.g. `"success"`, `"failed"`, `"pending"`, `"otp_required"`, `"cancelled"`, `"error"`. */
63
+ status: string;
64
+ code: string | null;
65
+ message: string | null;
66
+ timestamp: string | null;
67
+ /** SwichPay's order identifier. */
68
+ orderId: string | null;
69
+ /** Where to send the user if `isRedirectionRequired` (e.g. 3-D Secure). */
70
+ redirectUrl: string | null;
71
+ isRedirectionRequired: boolean;
72
+ merchantRedirectionUrl: string | null;
73
+ /** Payment attempts left on the session after this attempt, when the API returned one. */
74
+ remainingAttempts: number | null;
75
+ /** Biller (1Bill) consumer number. */
76
+ consumerNumber: string | null;
77
+ /** 3-D Secure form fields (e.g. `JWT`) to POST to `ddcCollectionUrl` / `stepUpUrl`. */
78
+ redirectFormFields: Record<string, string> | null;
79
+ postUrl: string | null;
80
+ /** Card 3-D Secure - raw `nextAction.continuation`, relayed into `PaymentEnrollment`. */
81
+ continuation: Record<string, unknown> | null;
82
+ /** Card 3-D Secure device-data-collection URL. */
83
+ ddcCollectionUrl: string | null;
84
+ vendorTransactionId: string | null;
85
+ /** Card 3-D Secure OTP step-up URL. */
86
+ stepUpUrl: string | null;
87
+ /** QR (RAAST) payload to render. */
88
+ qrString: string | null;
89
+ otpRequired: boolean;
90
+ /** Direct bank transfer OTP response's `transactionId`, echoed back on confirm. */
91
+ bankTransactionId: string | null;
92
+ transactionReferenceNo: string | null;
93
+ /** Wire spelling. */
94
+ retreivalReferenceNo: string | null;
95
+ /** Direct card only - the decline can be retried with a different card. */
96
+ retryable: boolean;
97
+ }
98
+ /** Builds a `PaymentResult` with every optional field defaulted. */
99
+ export declare function createPaymentResult(init: Pick<PaymentResult, 'isSuccess' | 'status'> & Partial<PaymentResult>): PaymentResult;
100
+ /** The result a checkout resolves with when the user closes it. */
101
+ export declare function cancelledResult(): PaymentResult;
102
+ /** The failure a direct checkout hands back once its transaction id is used up. */
103
+ export declare function failedResult(message: string | null | undefined): PaymentResult;
104
+ //# sourceMappingURL=payment.d.ts.map
@@ -0,0 +1,87 @@
1
+ import { type JsonMap } from '../utils/json.js';
2
+ import { type PaymentCategory } from './category.js';
3
+ /** A wallet channel (e.g. EasyPaisa, JazzCash) enabled for a payment session. */
4
+ export interface PaymentChannel {
5
+ channelId: number;
6
+ channelName: string;
7
+ channelCode: string;
8
+ }
9
+ /** A bank enabled for a payment session, scoped per `channelCode` - the same `bankId` can repeat. */
10
+ export interface PaymentBank {
11
+ bankId: number;
12
+ bankName: string;
13
+ bankCode: string;
14
+ /** Alternate bank code (`swich_BankCode`). */
15
+ swichBankCode: string;
16
+ channelId: number;
17
+ channelCode: string;
18
+ }
19
+ /** A wallet account the customer previously saved. `channel` is a `channelId` as a string. */
20
+ export interface SavedWallet {
21
+ id: number;
22
+ msisdn: string;
23
+ channel: string;
24
+ customerToken: string;
25
+ }
26
+ /** A card previously saved via `doCardOnFile: true`. `id` is sent as `savedCardId`. */
27
+ export interface SavedCard {
28
+ id: number;
29
+ cardNumber: string;
30
+ cardHolderName: string;
31
+ expiryDate: string;
32
+ customerToken: string;
33
+ channel: string;
34
+ }
35
+ /**
36
+ * Details of a payment session (`paymentsession/get`'s `data`). Never carries the response's
37
+ * `clientSecret`.
38
+ */
39
+ export interface PaymentSessionDetails {
40
+ paymentSessionGuid: string;
41
+ categories: PaymentCategory[];
42
+ /** Numeric id per category, sent as `categoryId` on every `ProcessPayment` call. */
43
+ categoryIds: Partial<Record<PaymentCategory, number>>;
44
+ expiryMinutes: number;
45
+ remainingAttempts: number;
46
+ channels: PaymentChannel[];
47
+ banks: PaymentBank[];
48
+ savedWallets: SavedWallet[];
49
+ savedCards: SavedCard[];
50
+ clientId: string | null;
51
+ }
52
+ /** Result of `GET /gateway/paymentsession/inquire`. */
53
+ export interface PaymentSessionInquiryResult {
54
+ transactionId: number;
55
+ orderId: string | null;
56
+ paymentSessionGuid: string | null;
57
+ status: string | null;
58
+ code: string | null;
59
+ message: string | null;
60
+ timestamp: string | null;
61
+ amount: number;
62
+ /** `code == "0000"` or `status` is "success" (case-insensitive). */
63
+ isSuccess: boolean;
64
+ }
65
+ /** A bank from a direct (session-less) flow's bank-list endpoint. */
66
+ export interface DirectBank {
67
+ name: string;
68
+ code: string;
69
+ bankProviderCode: string | null;
70
+ }
71
+ /** `mobileappinit`: enabled categories plus logo URLs keyed by logo name. */
72
+ export interface MobileAppInitResult {
73
+ categories: PaymentCategory[];
74
+ logos: Record<string, string>;
75
+ }
76
+ export declare function maskedSavedWallet(wallet: SavedWallet): string;
77
+ export declare function maskedSavedCard(card: SavedCard): string;
78
+ export declare function parsePaymentChannel(json: JsonMap): PaymentChannel;
79
+ export declare function parsePaymentBank(json: JsonMap): PaymentBank;
80
+ export declare function parseSavedWallet(json: JsonMap): SavedWallet;
81
+ /** The id arrives under `savedCardId`, the PAN under `pan`; `id`/`cardNumber` are fallbacks. */
82
+ export declare function parseSavedCard(json: JsonMap): SavedCard;
83
+ /** Parses the `data` object of a `paymentsession/get` response. */
84
+ export declare function parsePaymentSessionDetails(json: JsonMap): PaymentSessionDetails;
85
+ export declare function parsePaymentSessionInquiryResult(json: JsonMap): PaymentSessionInquiryResult;
86
+ export declare function parseDirectBank(json: JsonMap): DirectBank;
87
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * `@swichpay/core/server` - runs on your server (Node 18+, Nitro, edge runtimes with fetch).
3
+ * Never import it into browser code: it handles `clientSecret` and `secretHashKey`.
4
+ */
5
+ export { createSwichPayProxy, type SwichPayProxyHandler, type SwichPayProxyOptions } from './proxy.js';
6
+ export { createNodeProxyMiddleware, type NodeLikeRequest, type NodeLikeResponse } from './node.js';
7
+ export { fetchClientCredentialsToken } from '../http/api-client.js';
8
+ export { generateTransactionCheckSum } from '../utils/crypto.js';
9
+ export { classifyInquiry, createCheckoutSessionCreator, createPaymentVerifier, evaluateInquiry, lazyServerClient, type CheckoutSession, type CreateCheckoutSessionInput, type ServerClientSource, type VerificationStatus, type VerifyPaymentInput, type VerifyPaymentResult, } from './verify.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,19 @@
1
+ import type { SwichPayProxyHandler } from './proxy.js';
2
+ /** The parts of Node's `IncomingMessage` the adapter uses (no `node:http` import needed). */
3
+ export interface NodeLikeRequest extends AsyncIterable<Uint8Array | string> {
4
+ method?: string;
5
+ url?: string;
6
+ headers: Record<string, string | string[] | undefined>;
7
+ }
8
+ /** The parts of Node's `ServerResponse` the adapter uses. */
9
+ export interface NodeLikeResponse {
10
+ statusCode: number;
11
+ setHeader(name: string, value: string): unknown;
12
+ end(chunk?: string): unknown;
13
+ }
14
+ /**
15
+ * Adapts a proxy to Node/Express/Connect (`(req, res, next)`), mounted at `basePath`.
16
+ * Requests outside `basePath` go to `next()` when given, else 404.
17
+ */
18
+ export declare function createNodeProxyMiddleware(proxy: SwichPayProxyHandler, basePath: string): (req: NodeLikeRequest, res: NodeLikeResponse, next?: (error?: unknown) => void) => Promise<void>;
19
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1,30 @@
1
+ import { type ChecksumInput, type SwichPayOptions } from '../config.js';
2
+ export interface SwichPayProxyOptions extends Pick<SwichPayOptions, 'clientId' | 'clientSecret' | 'secretHashKey' | 'referrer' | 'merchantId' | 'appId' | 'environment' | 'hosts' | 'baseUrlOverride' | 'fetch' | 'logger' | 'timeouts'> {
3
+ /**
4
+ * Required. Runs before every forwarded call - check your own user session/CSRF here and return
5
+ * a `Response` (e.g. 401) to reject the request. Without it anyone who finds the proxy URL can
6
+ * call SwichPay with your credentials.
7
+ */
8
+ authorize?: (request: Request) => void | Response | Promise<void | Response>;
9
+ /**
10
+ * Required when `secretHashKey` is set. Called before a direct card payment is signed: return
11
+ * `true` only if `amount`/`currency` match the order `customerTransactionId` in *your*
12
+ * database. The checksum proves you approved the amount - without this check the proxy would
13
+ * sign whatever amount the app sends (e.g. PKR 1 for a PKR 15,000 order).
14
+ */
15
+ verifyAmount?: (payment: ChecksumInput, request: Request) => boolean | Promise<boolean>;
16
+ /** Skips the `authorize` requirement. Local testing only - never in production. */
17
+ dangerouslyAllowUnauthenticated?: boolean;
18
+ /** Signs card payments without `verifyAmount`. Local testing only - never in production. */
19
+ dangerouslySignAnyAmount?: boolean;
20
+ }
21
+ /** `(request, path)` → response. `path` is what follows the proxy's mount point, e.g. `/gateway/gateway/paymentsession/get`. */
22
+ export type SwichPayProxyHandler = (request: Request, path: string) => Promise<Response>;
23
+ /**
24
+ * A server-side proxy for the web SDK's `proxyUrl` mode. It forwards only SwichPay's own
25
+ * endpoint paths to the configured environment and adds what a browser can't safely send: the
26
+ * OAuth bearer token (from `clientSecret`), the `Referer`/`referrer` headers and, for direct card
27
+ * payments, the `recievedCheckSum` signed with `secretHashKey`.
28
+ */
29
+ export declare function createSwichPayProxy(options: SwichPayProxyOptions): SwichPayProxyHandler;
30
+ //# sourceMappingURL=proxy.d.ts.map
@@ -0,0 +1,61 @@
1
+ import { SwichPayClient } from '../client.js';
2
+ import type { SwichPayOptions } from '../config.js';
3
+ import type { PaymentCategory } from '../models/category.js';
4
+ import type { PaymentDetails } from '../models/payment.js';
5
+ import type { PaymentSessionInquiryResult } from '../models/session.js';
6
+ /** What to do with the order: fulfil (`success`), cancel (`failed`) or wait and re-check (`pending`). */
7
+ export type VerificationStatus = 'success' | 'failed' | 'pending';
8
+ export interface VerifyPaymentInput {
9
+ /** The payment session GUID the checkout was created with. */
10
+ paymentSessionGuid: string;
11
+ /** Your order total. A different amount from SwichPay fails verification. */
12
+ expectedAmount?: number;
13
+ /** Your order id. A different order id from SwichPay fails verification. */
14
+ expectedOrderId?: string;
15
+ }
16
+ export interface VerifyPaymentResult {
17
+ status: VerificationStatus;
18
+ /** `true` only when `status` is `success` and every expectation matched. */
19
+ verified: boolean;
20
+ /** Why it is not verified, or `null`. */
21
+ reason: null | 'declined' | 'not_final' | 'amount_mismatch' | 'order_mismatch';
22
+ /** SwichPay's raw answer from `GET /gateway/paymentsession/inquire`. */
23
+ inquiry: PaymentSessionInquiryResult;
24
+ }
25
+ /**
26
+ * Maps an inquiry to an order decision. Conservative on purpose: unknown statuses are `pending`,
27
+ * so an order is never fulfilled without a confirmed success and never cancelled without a
28
+ * confirmed failure.
29
+ */
30
+ export declare function classifyInquiry(inquiry: PaymentSessionInquiryResult): VerificationStatus;
31
+ export declare function evaluateInquiry(inquiry: PaymentSessionInquiryResult, input: Omit<VerifyPaymentInput, 'paymentSessionGuid'>): VerifyPaymentResult;
32
+ /** Options for a server-side client, or a function that returns them (read lazily, on first use). */
33
+ export type ServerClientSource = SwichPayOptions | (() => SwichPayOptions);
34
+ /** A lazily created, server-side `SwichPayClient` authenticated with `clientSecret`. */
35
+ export declare function lazyServerClient(source: ServerClientSource, purpose: string): () => SwichPayClient;
36
+ /**
37
+ * Server-side transaction verification with SwichPay's existing inquire API. Call it where the
38
+ * customer returns (`successRedirectUrl` / `failedRedirectUrl`) and fulfil the order only when
39
+ * `verified` is `true`. Never trust the redirect alone: anyone can open that URL.
40
+ *
41
+ * Network and authentication errors are thrown (as `SwichPayException`s), not reported as
42
+ * `failed`, so a SwichPay outage never cancels a paid order.
43
+ */
44
+ export declare function createPaymentVerifier(source: ServerClientSource): (input: VerifyPaymentInput) => Promise<VerifyPaymentResult>;
45
+ export interface CheckoutSession {
46
+ /** SwichPay's hosted checkout page. Redirect the customer here. */
47
+ url: string;
48
+ /** Store this with your order: verification needs it. */
49
+ paymentSessionGuid: string;
50
+ }
51
+ export interface CreateCheckoutSessionInput {
52
+ details: PaymentDetails;
53
+ categories?: readonly PaymentCategory[];
54
+ }
55
+ /**
56
+ * Creates a payment session server-side with SwichPay's existing
57
+ * `POST /gateway/paymentsession/initiate` and returns the hosted checkout URL plus the session
58
+ * GUID. Save the GUID with the order, then redirect the customer to `url`.
59
+ */
60
+ export declare function createCheckoutSessionCreator(source: ServerClientSource): (input: CreateCheckoutSessionInput) => Promise<CheckoutSession>;
61
+ //# sourceMappingURL=verify.d.ts.map
@@ -0,0 +1,40 @@
1
+ import { SwichPayClient, type SwichPayClientDependencies } from './client.js';
2
+ import type { SwichPayOptions } from './config.js';
3
+ import type { Subscription } from './events.js';
4
+ import type { PaymentCategory } from './models/category.js';
5
+ import type { CardDetails, PaymentDetails, PaymentResult } from './models/payment.js';
6
+ import type { PaymentSessionInquiryResult } from './models/session.js';
7
+ /**
8
+ * Static facade. UI methods (`presentPaymentSheet`, ...)
9
+ * live in `@swichpay/react` and `@swichpay/nuxt`, which need a framework to render.
10
+ */
11
+ export declare const SwichPay: {
12
+ /**
13
+ * Call once, as early as possible. Calling again replaces (and disposes) the previous client.
14
+ * Returns the client for direct access to every method.
15
+ */
16
+ initialize(options: SwichPayOptions, deps?: SwichPayClientDependencies): SwichPayClient;
17
+ /** Makes an existing client the live one (used by `<SwichPayProvider options>`). */
18
+ attach(client: SwichPayClient): void;
19
+ /** Clears the live client if it is `client` (without disposing it). */
20
+ detach(client: SwichPayClient): void;
21
+ /** The live client; throws `SwichPayNotInitializedException` before `initialize`. */
22
+ readonly client: SwichPayClient;
23
+ readonly isInitialized: boolean;
24
+ /** Submits a card payment directly against your own form. */
25
+ pay(input: {
26
+ details: PaymentDetails;
27
+ card: CardDetails;
28
+ }): Promise<PaymentResult>;
29
+ /** Listens for every payment result. Returns an unsubscribe function (also `.cancel()`). */
30
+ onResult(callback: (result: PaymentResult) => void): Subscription;
31
+ /** Payment method categories enabled for this merchant. */
32
+ availableCategories(): Promise<PaymentCategory[]>;
33
+ /** Queries a session's current status. */
34
+ inquirePaymentSession(input: {
35
+ paymentSessionGuid: string;
36
+ }): Promise<PaymentSessionInquiryResult>;
37
+ /** Disposes the live client; the facade is uninitialized afterwards. */
38
+ dispose(): void;
39
+ };
40
+ //# sourceMappingURL=swichpay.d.ts.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Same as every SwichPay SDK's `generateTransactionCheckSum`: base64 of
3
+ * HMAC-SHA256(secretHashKey, "Currency~Amount~CustomerTransactionId"), amount fixed to 2 decimals.
4
+ */
5
+ export declare function generateTransactionCheckSum(input: {
6
+ currency: string;
7
+ amount: number;
8
+ customerTransactionId: string;
9
+ secretHashKey: string;
10
+ }): Promise<string>;
11
+ /**
12
+ * Random UUID v4 (RTP Now's `rtpId`). These are unique references, not
13
+ * secrets: without `crypto.getRandomValues` (Expo Go has no native crypto module) it falls back
14
+ * to `Math.random`. Install `react-native-get-random-values` for crypto-quality ids.
15
+ */
16
+ export declare function generateUuidV4(): string;
17
+ /** Decodes a string `claim` from a JWT's payload without verifying its signature. */
18
+ export declare function decodeJwtClaim(jwt: string, claim: string): string | null;
19
+ //# sourceMappingURL=crypto.d.ts.map
@@ -0,0 +1,19 @@
1
+ /** Card number in 4-digit groups (`4242 4242 4242 4242`), capped at 19 digits. */
2
+ export declare function formatCardNumber(input: string): string;
3
+ /** Expiry as `MM/YY` while typing. */
4
+ export declare function formatExpiry(input: string): string;
5
+ /** Strips non-digits and optionally caps the length. */
6
+ export declare function digitsOnly(input: string, maxLength?: number): string;
7
+ /** Display amount like Dart's `num.toString()` for the payment sheet (`1000`, `10.5`). */
8
+ export declare function formatAmount(amount: number): string;
9
+ /** Dart's `toStringAsFixed(0)`, used by the direct sheets' pay buttons. */
10
+ export declare function formatAmountWhole(amount: number): string;
11
+ /** Dart's `num.toDouble().toString()` - `1000` becomes `"1000.0"` (RTP E-wallet wire format). */
12
+ export declare function dartDoubleString(amount: number): string;
13
+ /** Today as `yyyy-MM-dd` in local time. */
14
+ export declare function todayIsoDate(now?: Date): string;
15
+ /** `mm:ss` for countdowns. */
16
+ export declare function formatCountdown(totalSeconds: number): string;
17
+ /** `"<first 4 digits>***<last 4 digits>"`, regardless of whether already masked. */
18
+ export declare function maskForDisplay(value: string): string;
19
+ //# sourceMappingURL=formatters.d.ts.map
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Defensive JSON helpers. The SwichPay backend mixes types for nominally-typed fields (numeric
3
+ * codes, `data: false` where an object is documented), so every read coerces instead of casting -
4
+ * same policy as every SwichPay SDK.
5
+ */
6
+ export type JsonMap = Record<string, unknown>;
7
+ export declare function isJsonMap(value: unknown): value is JsonMap;
8
+ /** `value` as a JSON object, or `null` when it's anything else. */
9
+ export declare function mapOrNull(value: unknown): JsonMap | null;
10
+ /** Parses a response body leniently: empty or non-object JSON becomes `{}`. */
11
+ export declare function parseJsonObject(text: string): JsonMap;
12
+ /** Any non-null value as a string (Dart `value.toString()` for primitives). */
13
+ export declare function str(value: unknown): string | null;
14
+ /** A string only when the value is a non-blank string. */
15
+ export declare function nonBlankString(value: unknown): string | null;
16
+ /** `code` may arrive as a raw JSON number instead of a `"0000"`-style string. */
17
+ export declare function normalizedCode(code: unknown): string | null;
18
+ export declare function intOrNull(value: unknown): number | null;
19
+ export declare function numOr(value: unknown, fallback: number): number;
20
+ export declare function stringOrNull(value: unknown): string | null;
21
+ export declare function boolOrNull(value: unknown): boolean | null;
22
+ export declare function listOfMaps(value: unknown): JsonMap[];
23
+ /** First string value under `key` at any nesting depth. */
24
+ export declare function deepFindString(json: unknown, key: string): string | null;
25
+ /** Map values coerced to strings (for `formFields`). */
26
+ export declare function stringMap(map: JsonMap | null): Record<string, string> | null;
27
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Logging. The SDK prints nothing by default.
3
+ * Pass `logger` to `SwichPay.initialize()` to receive redacted debug lines.
4
+ */
5
+ export type SwichPayLogger = (message: string) => void;
6
+ /** Request/response body keys never logged in full. */
7
+ export declare const SENSITIVE_DATA_KEYS: ReadonlySet<string>;
8
+ /** Copies `data` with sensitive keys masked at any depth (nested objects and arrays), for logging only. */
9
+ export declare function redactForLog(data: Record<string, unknown> | null | undefined): Record<string, unknown> | null;
10
+ /** Copies `headers` with credentials masked, for logging only. */
11
+ export declare function redactHeaders(headers: Record<string, string>): Record<string, string>;
12
+ /** Wraps an optional logger so callers can log unconditionally. */
13
+ export declare function createLog(logger?: SwichPayLogger): SwichPayLogger;
14
+ export declare function safeJson(value: unknown): string;
15
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1,12 @@
1
+ /** `true` in a browser (or jsdom); `false` during SSR, in Node and in workers without a DOM. */
2
+ export declare function isBrowser(): boolean;
3
+ /** `true` inside a React Native app (Hermes/JSC), where there is a `window` but no `document`. */
4
+ export declare function isReactNative(): boolean;
5
+ /**
6
+ * `true` when the code runs on an end user's device - a browser or a mobile app - where any
7
+ * value in the bundle can be read by whoever has the app.
8
+ */
9
+ export declare function isClientRuntime(): boolean;
10
+ /** Throws a `SwichPayValidationException` when a browser-only feature is used during SSR. */
11
+ export declare function assertBrowser(feature: string): void;
12
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1,23 @@
1
+ /** Client-side card validation, run before anything leaves the device. */
2
+ export declare const CardValidators: {
3
+ /** Digits-only and 12-19 long after removing whitespace. No Luhn: sandbox test cards fail it. */
4
+ readonly isValidNumber: (number: string) => boolean;
5
+ /** Month 1-12 and not expired; a 2-digit year means 20xx. Valid through the end of the month. */
6
+ readonly isValidExpiry: (month: number, year: number, now?: Date) => boolean;
7
+ readonly isValidCvv: (cvv: string) => boolean;
8
+ readonly detectBrand: (number: string) => CardBrand;
9
+ };
10
+ export type CardBrand = 'visa' | 'mastercard' | 'amex' | 'unknown';
11
+ /** Client-side validation for bank/RTP account identifiers. */
12
+ export declare const AccountValidators: {
13
+ /** Spaces removed and upper-cased - the form IBANs are sent in. */
14
+ readonly normalizeIban: (input: string) => string;
15
+ /** `PK` + 2 check digits + 4-letter bank code + 16 characters. Format only, no mod-97. */
16
+ readonly isValidPkIban: (input: string) => boolean;
17
+ };
18
+ /** Parses `MM/YY` into numbers, or `null` when it isn't that shape. */
19
+ export declare function parseExpiry(value: string): {
20
+ month: number;
21
+ year: number;
22
+ } | null;
23
+ //# sourceMappingURL=validators.d.ts.map
@@ -0,0 +1,21 @@
1
+ import type { FlowController } from './core/index.js';
2
+ export type StateOf<C> = C extends FlowController<infer S> ? S : never;
3
+ /**
4
+ * Owns a headless controller for the component's lifetime and subscribes to its state. `start`
5
+ * runs one tick after mount, so StrictMode's mount → unmount → mount starts it exactly once
6
+ * (a second start would create a second payment session, which SwichPay rejects).
7
+ */
8
+ export declare function useController<C extends FlowController<any>>(create: () => C, start?: (controller: C) => void): [C, StateOf<C>];
9
+ /** The latest value, readable from callbacks without re-subscribing. */
10
+ export declare function useLatest<T>(value: T): {
11
+ readonly current: T;
12
+ };
13
+ export interface AsyncState<T> {
14
+ data: T | undefined;
15
+ error: unknown;
16
+ loading: boolean;
17
+ reload: () => void;
18
+ }
19
+ /** Runs `load` on mount (and on `reload()`), ignoring results that arrive after unmount. */
20
+ export declare function useAsync<T>(load: () => Promise<T>, deps: readonly unknown[]): AsyncState<T>;
21
+ //# sourceMappingURL=hooks.d.ts.map