@tapayadot/accept-react-native 1.3.2 → 1.14.1

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 (47) hide show
  1. package/README.md +196 -363
  2. package/android/build.gradle +23 -34
  3. package/android/src/main/java/com/tapaya/acceptsdkreactnative/AcceptSdkReactNativeModule.kt +191 -673
  4. package/android/src/main/java/com/tapaya/acceptsdkreactnative/Errors.kt +81 -0
  5. package/android/src/main/java/com/tapaya/acceptsdkreactnative/Parsing.kt +166 -0
  6. package/android/src/main/java/com/tapaya/acceptsdkreactnative/Serialization.kt +216 -0
  7. package/app.json +2 -2
  8. package/app.plugin.js +1 -1
  9. package/build/Accept.d.ts +255 -0
  10. package/build/Accept.d.ts.map +1 -0
  11. package/build/Accept.js +387 -0
  12. package/build/Accept.js.map +1 -0
  13. package/build/Accept.types.d.ts +352 -0
  14. package/build/Accept.types.d.ts.map +1 -0
  15. package/build/Accept.types.js +9 -0
  16. package/build/Accept.types.js.map +1 -0
  17. package/build/AcceptError.d.ts +53 -0
  18. package/build/AcceptError.d.ts.map +1 -0
  19. package/build/AcceptError.js +107 -0
  20. package/build/AcceptError.js.map +1 -0
  21. package/build/AcceptSdkReactNativeModule.d.ts +67 -26
  22. package/build/AcceptSdkReactNativeModule.d.ts.map +1 -1
  23. package/build/AcceptSdkReactNativeModule.js +53 -3
  24. package/build/AcceptSdkReactNativeModule.js.map +1 -1
  25. package/build/index.d.ts +7 -237
  26. package/build/index.d.ts.map +1 -1
  27. package/build/index.js +7 -254
  28. package/build/index.js.map +1 -1
  29. package/build/utils.d.ts.map +1 -1
  30. package/build/utils.js +2 -2
  31. package/build/utils.js.map +1 -1
  32. package/expo-module.config.json +1 -6
  33. package/package.json +8 -12
  34. package/plugin/withAcceptSdk.js +45 -0
  35. package/build/AcceptSdkReactNative.types.d.ts +0 -259
  36. package/build/AcceptSdkReactNative.types.d.ts.map +0 -1
  37. package/build/AcceptSdkReactNative.types.js +0 -2
  38. package/build/AcceptSdkReactNative.types.js.map +0 -1
  39. package/ios/.xcode.env +0 -11
  40. package/ios/AcceptSdkReactNative.podspec +0 -33
  41. package/ios/AcceptSdkReactNativeAppDelegate.swift +0 -13
  42. package/ios/AcceptSdkReactNativeModule.swift +0 -749
  43. package/ios/Podfile +0 -63
  44. package/ios/Podfile.properties.json +0 -4
  45. package/ios/acceptsdkreactnative.xcodeproj/project.pbxproj +0 -540
  46. package/ios/acceptsdkreactnative.xcodeproj/xcshareddata/xcschemes/acceptsdkreactnative.xcscheme +0 -88
  47. package/plugin/withCustomRepoModule.js +0 -96
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Accept.js","sourceRoot":"","sources":["../src/Accept.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,MAAM,MAAM,8BAA8B,CAAC;AAElD;;;GAGG;AACH,IAAI,aAAa,GAAG,CAAC,CAAC;AACtB,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,CAAC;AAEpD,4CAA4C;AAC5C,MAAM,UAAU,GAAG,CAAC,KAAmB,EAAE,EAAE,CACzC,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,CAAC;AAE7D;;GAEG;AACH,MAAM,IAAI,GAAG;IACX;;;;;OAKG;IACH,YAAY,CAAC,aAAqB;QAChC,OAAO,SAAS,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,CAAC;IAC7D,CAAC;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,GAAG,GAAG;IACV,iGAAiG;IACjG,IAAI,OAAO;QACT,OAAO,MAAM,CAAC,aAAa,EAAE,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACH,IAAI,YAAY;QACd,OAAO,aAAa,CAAC,GAAG,EAAE,CAAC,MAAM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AC;IACzB,CAAC;IAED;;;OAGG;IACH,QAAQ;QACN,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAED;;;;;;;;;;;OAWG;IACH,wBAAwB,CACtB,MAAc,EACd,gBAAwB,KAAK;QAE7B,OAAO,aAAa,CAAC,GAAG,EAAE,CACxB,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,aAAa,CAAC,CACvD,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import type {\n AcceptDisplay,\n AcceptLogEntry,\n AcceptLogLevel,\n AcceptSubscription,\n AcceptTheme,\n ActivateTerminalResult,\n InitializeOptions,\n MerchantConfig,\n MerchantInformation,\n MinimumAmount,\n OnboardingStatus,\n PayResult,\n PaymentEvent,\n PaymentOptions,\n PaymentRequest,\n PaymentState,\n PaymentStatus,\n PaymentSubscription,\n PluginStatus,\n PluginUpdateInfo,\n RefundReason,\n SdkState,\n} from \"./Accept.types\";\nimport { mapErrors, mapErrorsSync, toAcceptError } from \"./AcceptError\";\nimport Native from \"./AcceptSdkReactNativeModule\";\n\n/**\n * Correlates a `pay()` call with its events. Monotonic within a JavaScript context, which is all\n * that is needed: the native side only ever routes an event back to the caller that started it.\n */\nlet nextRequestId = 0;\nconst newRequestId = () => `pay-${++nextRequestId}`;\n\n/** A payment event that ends the stream. */\nconst isTerminal = (event: PaymentEvent) =>\n event.type === \"result\" || event.type === \"creationFailed\";\n\n/**\n * Authentication surface. Mirrors `Accept.auth`.\n */\nconst auth = {\n /**\n * Authenticates the SDK for the merchant identified by `merchantToken`. Must succeed before\n * {@link merchant} or {@link payments} can be used.\n *\n * @throws AcceptError `NotInitialized`, `NoInternetConnection`, `Unknown`.\n */\n authenticate(merchantToken: string): Promise<void> {\n return mapErrors(() => Native.authenticate(merchantToken));\n },\n};\n\n/**\n * SDK-level configuration and diagnostics. Mirrors `Accept.sdk`.\n */\nconst sdk = {\n /** The version of the Accept SDK for Android bundled in this build. Safe before `initialize`. */\n get version(): string {\n return Native.getSdkVersion();\n },\n\n /**\n * Whether the SDK was initialized against production.\n *\n * @throws AcceptError `NotInitialized`.\n */\n get isProduction(): boolean {\n return mapErrorsSync(() => Native.isProduction());\n },\n\n /**\n * This device's stable identifier, assigned on the first successful\n * {@link auth.authenticate} and retained until the app is uninstalled.\n *\n * @returns the device id, or `null` before the first authentication.\n * @throws AcceptError `NotInitialized`, `Unknown`.\n */\n deviceId(): Promise<string | null> {\n return mapErrors(() => Native.getDeviceId());\n },\n\n /**\n * The minimum payable amount per supported currency.\n *\n * @throws AcceptError `NotInitialized`, `NoInternetConnection`, `Unknown`.\n */\n minimumAmounts(): Promise<MinimumAmount[]> {\n return mapErrors(() => Native.getMinimumAmounts());\n },\n};\n\n/**\n * Merchant profile and onboarding. Mirrors `Accept.merchant`. Requires {@link auth.authenticate}.\n */\nconst merchant = {\n /**\n * The merchant's business profile, or `null` if onboarding hasn't been submitted yet.\n *\n * @throws AcceptError `NotAuthenticated`, `NoInternetConnection`, `Unknown`.\n */\n info(): Promise<MerchantInformation | null> {\n return mapErrors(() => Native.getMerchantInfo());\n },\n\n /**\n * The merchant's payment configuration.\n *\n * @throws AcceptError `NotAuthenticated`, `NoInternetConnection`, `Unknown`.\n */\n config(): Promise<MerchantConfig> {\n return mapErrors(() => Native.getMerchantConfig());\n },\n\n /**\n * Whether the merchant is ready to accept payments, or what is blocking it.\n *\n * @throws AcceptError `NotAuthenticated`, `NoInternetConnection`, `Unknown`.\n */\n onboardingStatus(): Promise<OnboardingStatus> {\n return mapErrors(() => Native.getOnboardingStatus());\n },\n\n /**\n * The currency codes the merchant accepts. Shorthand for `config().availableCurrencies`.\n *\n * @throws AcceptError `NotAuthenticated`, `NoInternetConnection`, `Unknown`.\n */\n availableCurrencies(): Promise<string[]> {\n return mapErrors(() => Native.getAvailableCurrencies());\n },\n};\n\n/**\n * Payments. Mirrors `Accept.payments`. Requires {@link auth.authenticate}.\n */\nconst payments = {\n /**\n * Sets the defaults applied to payments that don't override them on {@link pay}.\n *\n * Only the keys present are changed, so one option can be set without disturbing the others.\n * `display` is also what the terminal warm-up fired by {@link auth.authenticate} follows — set it\n * before authenticating to keep the warm-up off the merchant's screen.\n */\n setOptions(options: PaymentOptions): void {\n Native.setPaymentOptions(options);\n },\n\n /**\n * Launches the plugin's payment flow and streams its lifecycle to `listener`.\n *\n * Never throws: a failure to create the payment arrives as a `creationFailed` event carrying an\n * {@link AcceptError}. The stream ends after `result` or `creationFailed`, at which point the\n * subscription removes itself.\n *\n * ```ts\n * Accept.payments.pay({ amount: 1000, currency: 'USD' }, (event) => {\n * if (event.type === 'result' && event.payResult.type === 'success') {\n * console.log(event.payResult.paymentToken);\n * }\n * });\n * ```\n *\n * @returns a handle that stops delivering events; see {@link PaymentSubscription.remove}.\n */\n pay(\n request: PaymentRequest,\n listener: (event: PaymentEvent) => void,\n ): PaymentSubscription {\n const requestId = newRequestId();\n let removed = false;\n\n const subscription = Native.addListener(\"onPaymentEvent\", (payload) => {\n if (payload.requestId !== requestId) return;\n if (isTerminal(payload.event)) remove();\n listener(payload.event);\n });\n\n const remove = () => {\n if (removed) return;\n removed = true;\n subscription.remove();\n Native.stopPaymentEvents(requestId);\n };\n\n Native.startPayment(requestId, request);\n return { remove };\n },\n\n /**\n * {@link pay} reduced to its outcome, for callers that don't render the intermediate states.\n *\n * @returns the terminal {@link PayResult}.\n * @throws AcceptError whatever the payment would have reported as `creationFailed` — including\n * `PaymentInProgress`, `NotAuthenticated`, `PluginNotReadyForPayments`, `AmountBelowMinimum`,\n * and `LocationPermissionRequired`.\n */\n payAsync(request: PaymentRequest): Promise<PayResult> {\n return new Promise<PayResult>((resolve, reject) => {\n payments.pay(request, (event) => {\n if (event.type === \"result\") resolve(event.payResult);\n else if (event.type === \"creationFailed\")\n reject(toAcceptError(event.error));\n });\n });\n },\n\n /**\n * The current status of the payment identified by `paymentToken`.\n *\n * @throws AcceptError `NotAuthenticated`, `SessionExpired`, `PaymentNotFound`,\n * `NoInternetConnection`, `Unknown`.\n */\n status(paymentToken: string): Promise<PaymentStatus> {\n return mapErrors(() => Native.getPaymentStatus(paymentToken));\n },\n\n /**\n * Cancels the payment identified by `paymentToken`.\n *\n * @returns the resulting {@link PaymentState}.\n * @throws AcceptError `NotAuthenticated`, `SessionExpired`, `PaymentNotFound`,\n * `NoInternetConnection`, `Unknown`.\n */\n cancel(paymentToken: string): Promise<PaymentState> {\n return mapErrors(() => Native.cancelPayment(paymentToken));\n },\n\n /**\n * Refunds the payment identified by `paymentToken`.\n *\n * @returns the resulting {@link PaymentState}.\n * @throws AcceptError `NotAuthenticated`, `SessionExpired`, `PaymentNotFound`,\n * `NoInternetConnection`, `Unknown`.\n */\n refund(paymentToken: string, reason: RefundReason): Promise<PaymentState> {\n return mapErrors(() => Native.refundPayment(paymentToken, reason));\n },\n};\n\n/**\n * The Accept plugin app — the companion that drives the physical terminal. Mirrors `Accept.plugin`.\n */\nconst plugin = {\n /**\n * Whether the plugin app is installed on this device.\n *\n * @throws AcceptError `NotInitialized`, `Unknown`.\n */\n isInstalled(): boolean {\n return mapErrorsSync(() => Native.isPluginInstalled());\n },\n\n /**\n * Opens the plugin's store listing so the merchant can install it. Uses the organization's\n * branded listing when one is configured and the SDK is authenticated.\n *\n * @throws AcceptError `NotInitialized`, `Unknown`.\n */\n install(): Promise<void> {\n return mapErrors(() => Native.installPlugin());\n },\n\n /**\n * Runs the plugin's terminal activation flow and resolves when it finishes. Activation is\n * required before the device can take card payments.\n *\n * @throws AcceptError `ActivationInProgress`, `NotAuthenticated`, `PluginUnavailable`,\n * `NoInternetConnection`, `NoTidsAvailableForMerchant`, `MerchantOnboardingIncomplete`,\n * `Unknown`.\n */\n activateTerminal(): Promise<ActivateTerminalResult> {\n return mapErrors(() => Native.activateTerminal());\n },\n\n /**\n * The plugin's current installed/authenticated/ready state.\n *\n * @throws AcceptError `NotInitialized`, `PluginUnavailable`, `PluginTimeout`, `Unknown`.\n */\n status(): Promise<PluginStatus> {\n return mapErrors(() => Native.getPluginStatus());\n },\n\n /**\n * Whether a newer plugin build is available on Google Play. Call {@link install} to send the\n * merchant to its listing.\n *\n * @throws AcceptError `NotInitialized`, `PluginUnavailable`, `PluginTimeout`, `Unknown`.\n */\n updateInfo(): Promise<PluginUpdateInfo> {\n return mapErrors(() => Native.getPluginUpdateInfo());\n },\n\n /**\n * Logs the merchant out of the plugin app.\n *\n * @throws AcceptError `NotInitialized`, `PluginUnavailable`, `PluginTimeout`, `Unknown`.\n */\n logout(): Promise<void> {\n return mapErrors(() => Native.logoutPlugin());\n },\n};\n\n/**\n * Screen topology, for dual-sided POS hardware. Mirrors `Accept.displays`.\n *\n * Every member reads the platform live, so a display hot-plugged or powered off between calls is\n * reflected immediately. None of them throw.\n */\nconst displays = {\n /** Every display the device currently reports, primary first. */\n all(): AcceptDisplay[] {\n return Native.getDisplays();\n },\n\n /**\n * The customer-facing panel of a dual-sided device, or `null` on single-screen devices. This is\n * what `{ type: 'customerFacing' }` targets.\n */\n customerFacing(): AcceptDisplay | null {\n return Native.getCustomerFacingDisplay();\n },\n\n /** Whether a customer-facing display is available right now. */\n get isDualScreen(): boolean {\n return Native.isDualScreen();\n },\n};\n\n/** The listener currently receiving forwarded SDK logs, if any. */\nlet logSubscription: AcceptSubscription | null = null;\n\n/**\n * Entry point to the Accept SDK. Mirrors the `Accept` object in the Accept SDK for Android, so the\n * Android reference documentation applies unchanged.\n *\n * ```ts\n * import Accept from '@tapayadot/accept-react-native';\n *\n * Accept.initialize({ isProduction: false });\n * await Accept.auth.authenticate(merchantToken);\n *\n * if (!Accept.plugin.isInstalled()) await Accept.plugin.install();\n * await Accept.plugin.activateTerminal();\n *\n * const result = await Accept.payments.payAsync({ amount: 1000, currency: 'USD' });\n * ```\n */\nexport const Accept = {\n auth,\n sdk,\n merchant,\n payments,\n plugin,\n displays,\n\n /**\n * Initializes the SDK against sandbox or production. Must be called before any other surface is\n * used — typically once, at app startup.\n *\n * Safe to call more than once; each call resets which environment subsequent requests target.\n */\n initialize(options: InitializeOptions = {}): void {\n Native.initialize(options.isProduction ?? false);\n },\n\n /** The SDK's current lifecycle state. */\n get state(): SdkState {\n return Native.getState();\n },\n\n /**\n * Subscribes to {@link state} transitions. The listener fires with the current state on\n * subscription, then on every change.\n */\n addStateListener(listener: (state: SdkState) => void): AcceptSubscription {\n return Native.addListener(\"onStateChange\", ({ state }) => listener(state));\n },\n\n /**\n * Clears all locally persisted SDK state — auth token, device id, cached config, and theme — and\n * resets {@link state} to `idle`. Call this on merchant logout.\n *\n * @throws AcceptError `Unknown`.\n */\n clear(): Promise<void> {\n return mapErrors(() => Native.clear());\n },\n\n /**\n * Enables or disables diagnostic logging. Shorthand for {@link setLogLevel}: `true` maps to\n * `'DEBUG'`, `false` to `'NONE'`.\n */\n setDebugLoggingEnabled(enabled: boolean): void {\n Native.setDebugLoggingEnabled(enabled);\n },\n\n /**\n * Sets the verbosity of diagnostic logging. Defaults to `'DEBUG'` against sandbox and `'NONE'`\n * against production; call after {@link initialize} to override.\n */\n setLogLevel(level: AcceptLogLevel): void {\n Native.setLogLevel(level);\n },\n\n /**\n * Routes SDK logs into `listener` instead of Logcat, for forwarding into your own logging stack.\n * Pass `null` to restore the default Logcat sink.\n */\n setLogger(listener: ((entry: AcceptLogEntry) => void) | null): void {\n logSubscription?.remove();\n logSubscription = listener ? Native.addListener(\"onLog\", listener) : null;\n Native.setLogForwardingEnabled(listener !== null);\n },\n\n /**\n * Sets the branding applied to the plugin's activation, status, and payment screens.\n *\n * Session-wide, not per payment: it persists until changed or cleared with `null`. Pushed to the\n * plugin opportunistically the next time it is bound or launched, so there is no confirmation\n * that it was applied — the plugin may not be installed or running yet.\n */\n setTheme(theme: AcceptTheme | null): void {\n Native.setTheme(theme);\n },\n\n /**\n * The theme currently set via {@link setTheme}, or `null`. Reflects local SDK state only, not\n * whether the plugin applied it.\n */\n getTheme(): AcceptTheme | null {\n return Native.getTheme();\n },\n\n /**\n * Stores `base64` image data in SDK-private storage and returns a `content://` URL the plugin can\n * read — for a logo the host app holds locally rather than at a stable URL. Use the result\n * anywhere an {@link AcceptTheme} image field takes a URL.\n *\n * `assetToBase64` from `@tapayadot/accept-react-native/utils` turns a `require('./logo.png')`\n * into the expected string.\n *\n * @param fileExtension the extension to store the data under, without a leading dot. Tells the\n * plugin how to decode it; defaults to `'png'`.\n * @throws AcceptError `NotInitialized`.\n */\n createLocalThemeImageUri(\n base64: string,\n fileExtension: string = \"png\",\n ): string {\n return mapErrorsSync(() =>\n Native.createLocalThemeImageUri(base64, fileExtension),\n );\n },\n};\n"]}
@@ -0,0 +1,352 @@
1
+ /**
2
+ * Types mirroring the Accept SDK for Android.
3
+ *
4
+ * Every name here corresponds 1:1 to a type in `com.tapaya.accept`, so the Android reference
5
+ * documentation applies unchanged. Kotlin sealed interfaces become tagged unions discriminated on
6
+ * `type`; Kotlin enums become string-literal unions.
7
+ */
8
+ /**
9
+ * Lifecycle state of the SDK. Mirrors `SdkState`.
10
+ *
11
+ * - `idle` — {@link Accept.initialize} has not been called yet.
12
+ * - `initialized` — ready for {@link AcceptAuth.authenticate}.
13
+ * - `authenticated` — the merchant and payments surfaces are usable.
14
+ */
15
+ export type SdkState = "idle" | "initialized" | "authenticated";
16
+ /** Options for {@link Accept.initialize}. */
17
+ export type InitializeOptions = {
18
+ /** `true` to target production, `false` (the default) to target sandbox. */
19
+ isProduction?: boolean;
20
+ };
21
+ /** Verbosity threshold for the SDK's diagnostic logging, least to most verbose. */
22
+ export type AcceptLogLevel = "NONE" | "ERROR" | "WARN" | "INFO" | "DEBUG" | "VERBOSE";
23
+ /** A single diagnostic log line, delivered to the listener passed to {@link Accept.setLogger}. */
24
+ export type AcceptLogEntry = {
25
+ level: AcceptLogLevel;
26
+ /** Stable Logcat-style tag identifying the SDK. */
27
+ tag: string;
28
+ /** Human-readable, already redacted message. */
29
+ message: string;
30
+ /** Message of the cause associated with this line, when there is one. */
31
+ throwable: string | null;
32
+ };
33
+ /** Discriminator on {@link AcceptError}; mirrors the `AcceptException` subclass names. */
34
+ export type AcceptErrorCode = "NotInitialized" | "NotAuthenticated" | "PluginUnavailable" | "PaymentInProgress" | "ActivationInProgress" | "PluginAlreadyAuthenticated" | "PluginMerchantMismatch" | "NoTidsAvailableForMerchant" | "MerchantOnboardingIncomplete" | "UnsupportedCurrency" | "CurrencyNotAvailableForMerchant" | "AmountBelowMinimum" | "TransactionTimeoutOutOfRange" | "PluginNotReadyForPayments" | "PaymentCreationFailed" | "LocationPermissionRequired" | "LocationUnavailable" | "LocationTimeout" | "NoInternetConnection" | "SessionExpired" | "PaymentNotFound" | "PluginTimeout" | "UnknownEnvironment" | "Unknown";
35
+ /** The payload fields carried by the error codes that have any. */
36
+ export type AcceptErrorDetails = {
37
+ /** `MerchantOnboardingIncomplete`: the merchant's current onboarding state. */
38
+ state?: OnboardingState;
39
+ /** `UnsupportedCurrency`, `CurrencyNotAvailableForMerchant`, `AmountBelowMinimum`. */
40
+ currency?: string;
41
+ /** `AmountBelowMinimum`: the minimum required amount, in minor units. */
42
+ minimum?: number;
43
+ /** `TransactionTimeoutOutOfRange`: the out-of-range value that was passed, in milliseconds. */
44
+ transactionTimeoutMs?: number;
45
+ /** `PluginNotReadyForPayments`: the plugin's status at the time of the call. */
46
+ status?: PluginStatus;
47
+ /** `UnknownEnvironment`: the environment key that was not recognized. */
48
+ environment?: string;
49
+ /** `PaymentCreationFailed`, `Unknown`: the underlying error's message. Not for end-user display. */
50
+ cause?: string;
51
+ };
52
+ /** The minimum payable amount for one currency. Mirrors `MinimumAmount`. */
53
+ export type MinimumAmount = {
54
+ /** ISO 4217 currency code. */
55
+ currency: string;
56
+ /** The minimum amount, in the currency's minor unit. */
57
+ amount: number;
58
+ };
59
+ /** Mirrors `BusinessType`. */
60
+ export type BusinessType = "INDIVIDUAL" | "COMPANY" | "NONPROFIT_ORGANIZATION" | "GOVERNMENT_ENTITY" | "PARTNERSHIP";
61
+ /** The merchant's payment configuration. Mirrors `MerchantConfig`. */
62
+ export type MerchantConfig = {
63
+ /** ISO 4217 codes the merchant is configured to accept. */
64
+ availableCurrencies: string[];
65
+ /** The merchant's default currency, when one is set. */
66
+ currency: string | null;
67
+ };
68
+ /** The merchant's business profile. Mirrors `MerchantInformation`. */
69
+ export type MerchantInformation = {
70
+ merchantId: string;
71
+ email: string;
72
+ businessType: BusinessType;
73
+ legalName: string;
74
+ registrationNumber: string;
75
+ mcc: string;
76
+ addressLine1: string;
77
+ city: string;
78
+ country: string;
79
+ vatNumber: string | null;
80
+ incorporationDate: string | null;
81
+ addressLine2: string | null;
82
+ postalCode: string | null;
83
+ state: string | null;
84
+ phone: string | null;
85
+ averageItemValue: number | null;
86
+ expectedMonthlyTurnover: number | null;
87
+ businessModelDescription: string | null;
88
+ numberOfEmployees: number | null;
89
+ annualTurnover: number | null;
90
+ balanceSheetTotal: number | null;
91
+ statementDescriptor: string | null;
92
+ termsVersion: string | null;
93
+ };
94
+ /** Mirrors `OnboardingState`. */
95
+ export type OnboardingState = "NOT_STARTED" | "PENDING" | "ACTIVE" | "ATTENTION_NEEDED" | "ACTION_REQUIRED" | "BLOCKED" | "WAITING_FOR_KYB" | "WAITING_FOR_STAKEHOLDERS" | "PENDING_ACQUIRER_APPROVAL";
96
+ /** Whether the merchant can accept payments, or what is blocking it. Mirrors `OnboardingStatus`. */
97
+ export type OnboardingStatus = {
98
+ type: "readyForPayments";
99
+ } | {
100
+ type: "requiresAction";
101
+ state: OnboardingState;
102
+ };
103
+ /** Lifecycle state of a payment on the backend. Mirrors `PaymentState`. */
104
+ export type PaymentState = "PENDING" | "SUCCESS" | "CANCELLED" | "REFUNDED" | "FAILED" | "ACTION_NEEDED";
105
+ /** Mirrors `PaymentStatus`. Amounts are decimal strings as returned by the backend. */
106
+ export type PaymentStatus = {
107
+ state: PaymentState;
108
+ paymentToken: string;
109
+ requestedAmount: string;
110
+ requestedCurrency: string;
111
+ settlementAmount: string;
112
+ settlementCurrency: string;
113
+ createdAt: string;
114
+ receiptUrl: string;
115
+ processedAt: string | null;
116
+ };
117
+ /** Mirrors `RefundReason`. */
118
+ export type RefundReason = "CUSTOMER_REQUEST" | "DUPLICATE" | "FRAUDULENT" | "EXPIRED_CHARGE";
119
+ /** Card-scheme detail for the completed transaction. Mirrors `ReceiptDetails`. */
120
+ export type ReceiptDetails = {
121
+ merchantId: string | null;
122
+ terminalId: string | null;
123
+ cardBrand: string | null;
124
+ appLabel: string | null;
125
+ aid: string | null;
126
+ maskedPan: string | null;
127
+ responseCode: string | null;
128
+ transactionTimestamp: string | null;
129
+ };
130
+ /** Why the plugin reported a `failed` {@link PayResult}. Mirrors `PayFailureReason`. */
131
+ export type PayFailureReason = "INVALID_INTENT" | "NOT_ACTIVATED" | "TERMINAL_INIT_FAILED" | "PAYMENT_SETUP_FAILED" | "PLUGIN_UNAVAILABLE" | "UNKNOWN";
132
+ /** Terminal outcome of a payment run by the plugin. Mirrors `PayResult`. */
133
+ export type PayResult = {
134
+ type: "success";
135
+ paymentToken: string;
136
+ metadata: Record<string, string> | null;
137
+ authCode: string | null;
138
+ receiptDetails: ReceiptDetails | null;
139
+ receiptUrl: string | null;
140
+ } | {
141
+ type: "declined";
142
+ metadata: Record<string, string> | null;
143
+ receiptDetails: ReceiptDetails | null;
144
+ receiptUrl: string | null;
145
+ } | {
146
+ type: "canceled";
147
+ metadata: Record<string, string> | null;
148
+ } | {
149
+ type: "failed";
150
+ reason: PayFailureReason;
151
+ metadata: Record<string, string> | null;
152
+ };
153
+ /**
154
+ * Lifecycle of a payment request, delivered to the listener passed to {@link AcceptPayments.pay}.
155
+ * Mirrors `PaymentEvent`.
156
+ *
157
+ * Exactly one of `result` or `creationFailed` ends the stream.
158
+ */
159
+ export type PaymentEvent = {
160
+ type: "creating";
161
+ } | {
162
+ type: "created";
163
+ paymentToken: string;
164
+ receiptUrl: string | null;
165
+ } | {
166
+ type: "launched";
167
+ } | {
168
+ type: "result";
169
+ payResult: PayResult;
170
+ } | {
171
+ type: "creationFailed";
172
+ error: {
173
+ code: AcceptErrorCode;
174
+ message: string;
175
+ } & AcceptErrorDetails;
176
+ };
177
+ /** How the plugin dismisses its receipt screen. Mirrors `DismissBehavior`. */
178
+ export type DismissBehavior = {
179
+ type: "manual";
180
+ } | {
181
+ type: "delayed";
182
+ delayMs: number;
183
+ };
184
+ /** Whether the plugin prints a paper receipt. Mirrors `ReceiptPrintBehavior`. */
185
+ export type ReceiptPrintBehavior = "automatic" | "onDemand" | "disabled";
186
+ /** What the plugin shows after a payment completes. Mirrors `PaymentReceiptConfig`. */
187
+ export type PaymentReceiptConfig = {
188
+ type: "dismissImmediately";
189
+ } | {
190
+ type: "show";
191
+ /** Defaults to `true`. */
192
+ showQrCodeReceipt?: boolean;
193
+ /** Defaults to `{ type: 'manual' }`. */
194
+ dismissBehavior?: DismissBehavior;
195
+ /** Defaults to `'onDemand'`. */
196
+ printBehavior?: ReceiptPrintBehavior;
197
+ };
198
+ /** Which face of the device carries the NFC antenna. Mirrors `OnDeviceSurface`. */
199
+ export type OnDeviceSurface = "back" | "frontScreen";
200
+ /** Where the merchant should tap the card. Mirrors `NfcPositionConfig`. */
201
+ export type NfcPositionConfig = {
202
+ type: "unspecified";
203
+ } | {
204
+ type: "externalAbove";
205
+ } | {
206
+ type: "externalReader";
207
+ message?: string;
208
+ } | {
209
+ type: "onDevice";
210
+ surface: OnDeviceSurface;
211
+ /** Horizontal position of the antenna, 0..1 across the surface. */
212
+ xFraction: number;
213
+ /** Vertical position of the antenna, 0..1 down the surface. */
214
+ yFraction: number;
215
+ };
216
+ /** Which screen the plugin's payment UI runs on. Mirrors `PaymentDisplay`. */
217
+ export type PaymentDisplay = {
218
+ type: "default";
219
+ } | {
220
+ type: "customerFacing";
221
+ } | {
222
+ type: "specific";
223
+ displayId: number;
224
+ };
225
+ /** Session-wide payment defaults. Mirrors the parameters of `AcceptPayments.setOptions`. */
226
+ export type PaymentOptions = {
227
+ receiptConfig?: PaymentReceiptConfig;
228
+ nfcPosition?: NfcPositionConfig;
229
+ /**
230
+ * How long the plugin waits for the card tap, in milliseconds; 0..120000. Pass `null` to restore
231
+ * the plugin's own fallback (~60 seconds). Omit the key to leave the current default alone.
232
+ */
233
+ transactionTimeoutMs?: number | null;
234
+ display?: PaymentDisplay;
235
+ };
236
+ /** A payment to run. Mirrors the parameters of `AcceptPayments.pay`. */
237
+ export type PaymentRequest = {
238
+ /** The amount to charge, in the currency's minor unit (e.g. cents for USD). */
239
+ amount: number;
240
+ /** ISO 4217 currency code. */
241
+ currency: string;
242
+ /** Token of an existing payment session to resume. */
243
+ paymentToken?: string;
244
+ /** Overrides the session default for this payment only. */
245
+ receiptConfig?: PaymentReceiptConfig;
246
+ /** Overrides the session default for this payment only. */
247
+ nfcPosition?: NfcPositionConfig;
248
+ /** Key-value data attached to the payment and echoed back on the {@link PayResult}. */
249
+ metadata?: Record<string, string>;
250
+ /** A fixed tip, in the currency's minor unit. When set, the plugin skips its own tip screen. */
251
+ tip?: number;
252
+ /** Overrides the session default for this payment only; 0..120000 milliseconds. */
253
+ transactionTimeoutMs?: number;
254
+ /** Overrides the session default for this payment only. */
255
+ display?: PaymentDisplay;
256
+ };
257
+ /** Handle returned by {@link AcceptPayments.pay}. */
258
+ export type PaymentSubscription = {
259
+ /**
260
+ * Stops delivering events for this payment. The plugin's UI is already on screen by then — it is
261
+ * dismissed by the user, or the payment is voided with {@link AcceptPayments.cancel}.
262
+ */
263
+ remove: () => void;
264
+ };
265
+ /** The plugin app's installed/authenticated/ready state. Mirrors `PluginStatus`. */
266
+ export type PluginStatus = "notInstalled" | "notAuthenticated" | "authenticated" | "readyForPayments" | "merchantMismatch";
267
+ /** Whether a newer plugin build is on Google Play. Mirrors `PluginUpdateInfo`. */
268
+ export type PluginUpdateInfo = {
269
+ type: "upToDate";
270
+ } | {
271
+ type: "updateAvailable";
272
+ priority: number;
273
+ } | {
274
+ type: "unknown";
275
+ };
276
+ /** Why an activation attempt failed. Mirrors `ActivateTerminalFailureReason`. */
277
+ export type ActivateTerminalFailureReason = "INVALID_INTENT" | "HANDOVER_FAILED" | "CONFIRM_FAILED" | "MERCHANT_NOT_ONBOARDED" | "UNKNOWN";
278
+ /** Outcome of {@link AcceptPlugin.activateTerminal}. Mirrors `ActivateTerminalResult`. */
279
+ export type ActivateTerminalResult = {
280
+ type: "success";
281
+ } | {
282
+ type: "canceled";
283
+ } | {
284
+ type: "failed";
285
+ reason: ActivateTerminalFailureReason;
286
+ };
287
+ /** One display the device reports. Mirrors `AcceptDisplay`. */
288
+ export type AcceptDisplay = {
289
+ id: number;
290
+ name: string;
291
+ isPrimary: boolean;
292
+ isPresentation: boolean;
293
+ widthPx: number;
294
+ heightPx: number;
295
+ };
296
+ /** Mirrors `AcceptThemeColors`. Values are hex strings — `#RRGGBB` or `#AARRGGBB`. */
297
+ export type AcceptThemeColors = {
298
+ primary?: string;
299
+ onPrimary?: string;
300
+ primaryContainer?: string;
301
+ onPrimaryContainer?: string;
302
+ secondary?: string;
303
+ onSecondary?: string;
304
+ secondaryContainer?: string;
305
+ onSecondaryContainer?: string;
306
+ error?: string;
307
+ onError?: string;
308
+ errorContainer?: string;
309
+ onErrorContainer?: string;
310
+ background?: string;
311
+ onBackground?: string;
312
+ surface?: string;
313
+ onSurface?: string;
314
+ surfaceVariant?: string;
315
+ onSurfaceVariant?: string;
316
+ outline?: string;
317
+ outlineVariant?: string;
318
+ warning?: string;
319
+ onWarning?: string;
320
+ warningContainer?: string;
321
+ onWarningContainer?: string;
322
+ success?: string;
323
+ onSuccess?: string;
324
+ successContainer?: string;
325
+ onSuccessContainer?: string;
326
+ };
327
+ /**
328
+ * Mirrors `AcceptThemeImages`. Each value is a URL the plugin loads — either an `https://` URL, or
329
+ * a `content://` URL produced by {@link Accept.createLocalThemeImageUri} for an image the host app
330
+ * holds locally.
331
+ */
332
+ export type AcceptThemeImages = {
333
+ logoText?: string;
334
+ logoTextSolid?: string;
335
+ logoSymbol?: string;
336
+ logoSymbolWithBackground?: string;
337
+ };
338
+ /** Mirrors `AcceptThemeVariant`. */
339
+ export type AcceptThemeVariant = {
340
+ colors?: AcceptThemeColors;
341
+ images?: AcceptThemeImages;
342
+ };
343
+ /** Branding applied to the plugin's activation, status, and payment screens. Mirrors `AcceptTheme`. */
344
+ export type AcceptTheme = {
345
+ light?: AcceptThemeVariant;
346
+ dark?: AcceptThemeVariant;
347
+ };
348
+ /** Handle returned by the `on*` listeners. Mirrors Expo's `EventSubscription`. */
349
+ export type AcceptSubscription = {
350
+ remove: () => void;
351
+ };
352
+ //# sourceMappingURL=Accept.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Accept.types.d.ts","sourceRoot":"","sources":["../src/Accept.types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,aAAa,GAAG,eAAe,CAAC;AAEhE,6CAA6C;AAC7C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,4EAA4E;IAC5E,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAIF,mFAAmF;AACnF,MAAM,MAAM,cAAc,GACxB,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAE3D,kGAAkG;AAClG,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,cAAc,CAAC;IACtB,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAC;IACZ,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,yEAAyE;IACzE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAIF,0FAA0F;AAC1F,MAAM,MAAM,eAAe,GACvB,gBAAgB,GAChB,kBAAkB,GAClB,mBAAmB,GACnB,mBAAmB,GACnB,sBAAsB,GACtB,4BAA4B,GAC5B,wBAAwB,GACxB,4BAA4B,GAC5B,8BAA8B,GAC9B,qBAAqB,GACrB,iCAAiC,GACjC,oBAAoB,GACpB,8BAA8B,GAC9B,2BAA2B,GAC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AM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC,CAAC;AAEF,oCAAoC;AACpC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC5B,CAAC;AAEF,uGAAuG;AACvG,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B,IAAI,CAAC,EAAE,kBAAkB,CAAC;CAC3B,CAAC;AAIF,kFAAkF;AAClF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Types mirroring the Accept SDK for Android.
3
+ *
4
+ * Every name here corresponds 1:1 to a type in `com.tapaya.accept`, so the Android reference
5
+ * documentation applies unchanged. Kotlin sealed interfaces become tagged unions discriminated on
6
+ * `type`; Kotlin enums become string-literal unions.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=Accept.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Accept.types.js","sourceRoot":"","sources":["../src/Accept.types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","sourcesContent":["/**\n * Types mirroring the Accept SDK for Android.\n *\n * Every name here corresponds 1:1 to a type in `com.tapaya.accept`, so the Android reference\n * documentation applies unchanged. Kotlin sealed interfaces become tagged unions discriminated on\n * `type`; Kotlin enums become string-literal unions.\n */\n\n// ── Lifecycle ─────────────────────────────────────────────────────────────────\n\n/**\n * Lifecycle state of the SDK. Mirrors `SdkState`.\n *\n * - `idle` — {@link Accept.initialize} has not been called yet.\n * - `initialized` — ready for {@link AcceptAuth.authenticate}.\n * - `authenticated` — the merchant and payments surfaces are usable.\n */\nexport type SdkState = \"idle\" | \"initialized\" | \"authenticated\";\n\n/** Options for {@link Accept.initialize}. */\nexport type InitializeOptions = {\n /** `true` to target production, `false` (the default) to target sandbox. */\n isProduction?: boolean;\n};\n\n// ── Diagnostics ───────────────────────────────────────────────────────────────\n\n/** Verbosity threshold for the SDK's diagnostic logging, least to most verbose. */\nexport type AcceptLogLevel =\n \"NONE\" | \"ERROR\" | \"WARN\" | \"INFO\" | \"DEBUG\" | \"VERBOSE\";\n\n/** A single diagnostic log line, delivered to the listener passed to {@link Accept.setLogger}. */\nexport type AcceptLogEntry = {\n level: AcceptLogLevel;\n /** Stable Logcat-style tag identifying the SDK. */\n tag: string;\n /** Human-readable, already redacted message. */\n message: string;\n /** Message of the cause associated with this line, when there is one. */\n throwable: string | null;\n};\n\n// ── Errors ────────────────────────────────────────────────────────────────────\n\n/** Discriminator on {@link AcceptError}; mirrors the `AcceptException` subclass names. */\nexport type AcceptErrorCode =\n | \"NotInitialized\"\n | \"NotAuthenticated\"\n | \"PluginUnavailable\"\n | \"PaymentInProgress\"\n | \"ActivationInProgress\"\n | \"PluginAlreadyAuthenticated\"\n | \"PluginMerchantMismatch\"\n | \"NoTidsAvailableForMerchant\"\n | \"MerchantOnboardingIncomplete\"\n | \"UnsupportedCurrency\"\n | \"CurrencyNotAvailableForMerchant\"\n | \"AmountBelowMinimum\"\n | \"TransactionTimeoutOutOfRange\"\n | \"PluginNotReadyForPayments\"\n | \"PaymentCreationFailed\"\n | \"LocationPermissionRequired\"\n | \"LocationUnavailable\"\n | \"LocationTimeout\"\n | \"NoInternetConnection\"\n | \"SessionExpired\"\n | \"PaymentNotFound\"\n | \"PluginTimeout\"\n | \"UnknownEnvironment\"\n | \"Unknown\";\n\n/** The payload fields carried by the error codes that have any. */\nexport type AcceptErrorDetails = {\n /** `MerchantOnboardingIncomplete`: the merchant's current onboarding state. */\n state?: OnboardingState;\n /** `UnsupportedCurrency`, `CurrencyNotAvailableForMerchant`, `AmountBelowMinimum`. */\n currency?: string;\n /** `AmountBelowMinimum`: the minimum required amount, in minor units. */\n minimum?: number;\n /** `TransactionTimeoutOutOfRange`: the out-of-range value that was passed, in milliseconds. */\n transactionTimeoutMs?: number;\n /** `PluginNotReadyForPayments`: the plugin's status at the time of the call. */\n status?: PluginStatus;\n /** `UnknownEnvironment`: the environment key that was not recognized. */\n environment?: string;\n /** `PaymentCreationFailed`, `Unknown`: the underlying error's message. Not for end-user display. */\n cause?: string;\n};\n\n// ── SDK configuration ─────────────────────────────────────────────────────────\n\n/** The minimum payable amount for one currency. Mirrors `MinimumAmount`. */\nexport type MinimumAmount = {\n /** ISO 4217 currency code. */\n currency: string;\n /** The minimum amount, in the currency's minor unit. */\n amount: number;\n};\n\n// ── Merchant ──────────────────────────────────────────────────────────────────\n\n/** Mirrors `BusinessType`. */\nexport type BusinessType =\n | \"INDIVIDUAL\"\n | \"COMPANY\"\n | \"NONPROFIT_ORGANIZATION\"\n | \"GOVERNMENT_ENTITY\"\n | \"PARTNERSHIP\";\n\n/** The merchant's payment configuration. Mirrors `MerchantConfig`. */\nexport type MerchantConfig = {\n /** ISO 4217 codes the merchant is configured to accept. */\n availableCurrencies: string[];\n /** The merchant's default currency, when one is set. */\n currency: string | null;\n};\n\n/** The merchant's business profile. Mirrors `MerchantInformation`. */\nexport type MerchantInformation = {\n merchantId: string;\n email: string;\n businessType: BusinessType;\n legalName: string;\n registrationNumber: string;\n mcc: string;\n addressLine1: string;\n city: string;\n country: string;\n vatNumber: string | null;\n incorporationDate: string | null;\n addressLine2: string | null;\n postalCode: string | null;\n state: string | null;\n phone: string | null;\n averageItemValue: number | null;\n expectedMonthlyTurnover: number | null;\n businessModelDescription: string | null;\n numberOfEmployees: number | null;\n annualTurnover: number | null;\n balanceSheetTotal: number | null;\n statementDescriptor: string | null;\n termsVersion: string | null;\n};\n\n/** Mirrors `OnboardingState`. */\nexport type OnboardingState =\n | \"NOT_STARTED\"\n | \"PENDING\"\n | \"ACTIVE\"\n | \"ATTENTION_NEEDED\"\n | \"ACTION_REQUIRED\"\n | \"BLOCKED\"\n | \"WAITING_FOR_KYB\"\n | \"WAITING_FOR_STAKEHOLDERS\"\n | \"PENDING_ACQUIRER_APPROVAL\";\n\n/** Whether the merchant can accept payments, or what is blocking it. Mirrors `OnboardingStatus`. */\nexport type OnboardingStatus =\n | { type: \"readyForPayments\" }\n | { type: \"requiresAction\"; state: OnboardingState };\n\n// ── Payments ──────────────────────────────────────────────────────────────────\n\n/** Lifecycle state of a payment on the backend. Mirrors `PaymentState`. */\nexport type PaymentState =\n \"PENDING\" | \"SUCCESS\" | \"CANCELLED\" | \"REFUNDED\" | \"FAILED\" | \"ACTION_NEEDED\";\n\n/** Mirrors `PaymentStatus`. Amounts are decimal strings as returned by the backend. */\nexport type PaymentStatus = {\n state: PaymentState;\n paymentToken: string;\n requestedAmount: string;\n requestedCurrency: string;\n settlementAmount: string;\n settlementCurrency: string;\n createdAt: string;\n receiptUrl: string;\n processedAt: string | null;\n};\n\n/** Mirrors `RefundReason`. */\nexport type RefundReason =\n \"CUSTOMER_REQUEST\" | \"DUPLICATE\" | \"FRAUDULENT\" | \"EXPIRED_CHARGE\";\n\n/** Card-scheme detail for the completed transaction. Mirrors `ReceiptDetails`. */\nexport type ReceiptDetails = {\n merchantId: string | null;\n terminalId: string | null;\n cardBrand: string | null;\n appLabel: string | null;\n aid: string | null;\n maskedPan: string | null;\n responseCode: string | null;\n transactionTimestamp: string | null;\n};\n\n/** Why the plugin reported a `failed` {@link PayResult}. Mirrors `PayFailureReason`. */\nexport type PayFailureReason =\n | \"INVALID_INTENT\"\n | \"NOT_ACTIVATED\"\n | \"TERMINAL_INIT_FAILED\"\n | \"PAYMENT_SETUP_FAILED\"\n | \"PLUGIN_UNAVAILABLE\"\n | \"UNKNOWN\";\n\n/** Terminal outcome of a payment run by the plugin. Mirrors `PayResult`. */\nexport type PayResult =\n | {\n type: \"success\";\n paymentToken: string;\n metadata: Record<string, string> | null;\n authCode: string | null;\n receiptDetails: ReceiptDetails | null;\n receiptUrl: string | null;\n }\n | {\n type: \"declined\";\n metadata: Record<string, string> | null;\n receiptDetails: ReceiptDetails | null;\n receiptUrl: string | null;\n }\n | { type: \"canceled\"; metadata: Record<string, string> | null }\n | {\n type: \"failed\";\n reason: PayFailureReason;\n metadata: Record<string, string> | null;\n };\n\n/**\n * Lifecycle of a payment request, delivered to the listener passed to {@link AcceptPayments.pay}.\n * Mirrors `PaymentEvent`.\n *\n * Exactly one of `result` or `creationFailed` ends the stream.\n */\nexport type PaymentEvent =\n | { type: \"creating\" }\n | { type: \"created\"; paymentToken: string; receiptUrl: string | null }\n | { type: \"launched\" }\n | { type: \"result\"; payResult: PayResult }\n | {\n type: \"creationFailed\";\n error: { code: AcceptErrorCode; message: string } & AcceptErrorDetails;\n };\n\n/** How the plugin dismisses its receipt screen. Mirrors `DismissBehavior`. */\nexport type DismissBehavior =\n { type: \"manual\" } | { type: \"delayed\"; delayMs: number };\n\n/** Whether the plugin prints a paper receipt. Mirrors `ReceiptPrintBehavior`. */\nexport type ReceiptPrintBehavior = \"automatic\" | \"onDemand\" | \"disabled\";\n\n/** What the plugin shows after a payment completes. Mirrors `PaymentReceiptConfig`. */\nexport type PaymentReceiptConfig =\n | { type: \"dismissImmediately\" }\n | {\n type: \"show\";\n /** Defaults to `true`. */\n showQrCodeReceipt?: boolean;\n /** Defaults to `{ type: 'manual' }`. */\n dismissBehavior?: DismissBehavior;\n /** Defaults to `'onDemand'`. */\n printBehavior?: ReceiptPrintBehavior;\n };\n\n/** Which face of the device carries the NFC antenna. Mirrors `OnDeviceSurface`. */\nexport type OnDeviceSurface = \"back\" | \"frontScreen\";\n\n/** Where the merchant should tap the card. Mirrors `NfcPositionConfig`. */\nexport type NfcPositionConfig =\n | { type: \"unspecified\" }\n | { type: \"externalAbove\" }\n | { type: \"externalReader\"; message?: string }\n | {\n type: \"onDevice\";\n surface: OnDeviceSurface;\n /** Horizontal position of the antenna, 0..1 across the surface. */\n xFraction: number;\n /** Vertical position of the antenna, 0..1 down the surface. */\n yFraction: number;\n };\n\n/** Which screen the plugin's payment UI runs on. Mirrors `PaymentDisplay`. */\nexport type PaymentDisplay =\n | { type: \"default\" }\n | { type: \"customerFacing\" }\n | { type: \"specific\"; displayId: number };\n\n/** Session-wide payment defaults. Mirrors the parameters of `AcceptPayments.setOptions`. */\nexport type PaymentOptions = {\n receiptConfig?: PaymentReceiptConfig;\n nfcPosition?: NfcPositionConfig;\n /**\n * How long the plugin waits for the card tap, in milliseconds; 0..120000. Pass `null` to restore\n * the plugin's own fallback (~60 seconds). Omit the key to leave the current default alone.\n */\n transactionTimeoutMs?: number | null;\n display?: PaymentDisplay;\n};\n\n/** A payment to run. Mirrors the parameters of `AcceptPayments.pay`. */\nexport type PaymentRequest = {\n /** The amount to charge, in the currency's minor unit (e.g. cents for USD). */\n amount: number;\n /** ISO 4217 currency code. */\n currency: string;\n /** Token of an existing payment session to resume. */\n paymentToken?: string;\n /** Overrides the session default for this payment only. */\n receiptConfig?: PaymentReceiptConfig;\n /** Overrides the session default for this payment only. */\n nfcPosition?: NfcPositionConfig;\n /** Key-value data attached to the payment and echoed back on the {@link PayResult}. */\n metadata?: Record<string, string>;\n /** A fixed tip, in the currency's minor unit. When set, the plugin skips its own tip screen. */\n tip?: number;\n /** Overrides the session default for this payment only; 0..120000 milliseconds. */\n transactionTimeoutMs?: number;\n /** Overrides the session default for this payment only. */\n display?: PaymentDisplay;\n};\n\n/** Handle returned by {@link AcceptPayments.pay}. */\nexport type PaymentSubscription = {\n /**\n * Stops delivering events for this payment. The plugin's UI is already on screen by then — it is\n * dismissed by the user, or the payment is voided with {@link AcceptPayments.cancel}.\n */\n remove: () => void;\n};\n\n// ── Plugin ────────────────────────────────────────────────────────────────────\n\n/** The plugin app's installed/authenticated/ready state. Mirrors `PluginStatus`. */\nexport type PluginStatus =\n | \"notInstalled\"\n | \"notAuthenticated\"\n | \"authenticated\"\n | \"readyForPayments\"\n | \"merchantMismatch\";\n\n/** Whether a newer plugin build is on Google Play. Mirrors `PluginUpdateInfo`. */\nexport type PluginUpdateInfo =\n | { type: \"upToDate\" }\n | { type: \"updateAvailable\"; priority: number }\n | { type: \"unknown\" };\n\n/** Why an activation attempt failed. Mirrors `ActivateTerminalFailureReason`. */\nexport type ActivateTerminalFailureReason =\n | \"INVALID_INTENT\"\n | \"HANDOVER_FAILED\"\n | \"CONFIRM_FAILED\"\n | \"MERCHANT_NOT_ONBOARDED\"\n | \"UNKNOWN\";\n\n/** Outcome of {@link AcceptPlugin.activateTerminal}. Mirrors `ActivateTerminalResult`. */\nexport type ActivateTerminalResult =\n | { type: \"success\" }\n | { type: \"canceled\" }\n | { type: \"failed\"; reason: ActivateTerminalFailureReason };\n\n// ── Displays ──────────────────────────────────────────────────────────────────\n\n/** One display the device reports. Mirrors `AcceptDisplay`. */\nexport type AcceptDisplay = {\n id: number;\n name: string;\n isPrimary: boolean;\n isPresentation: boolean;\n widthPx: number;\n heightPx: number;\n};\n\n// ── Theming ───────────────────────────────────────────────────────────────────\n\n/** Mirrors `AcceptThemeColors`. Values are hex strings — `#RRGGBB` or `#AARRGGBB`. */\nexport type AcceptThemeColors = {\n primary?: string;\n onPrimary?: string;\n primaryContainer?: string;\n onPrimaryContainer?: string;\n secondary?: string;\n onSecondary?: string;\n secondaryContainer?: string;\n onSecondaryContainer?: string;\n error?: string;\n onError?: string;\n errorContainer?: string;\n onErrorContainer?: string;\n background?: string;\n onBackground?: string;\n surface?: string;\n onSurface?: string;\n surfaceVariant?: string;\n onSurfaceVariant?: string;\n outline?: string;\n outlineVariant?: string;\n warning?: string;\n onWarning?: string;\n warningContainer?: string;\n onWarningContainer?: string;\n success?: string;\n onSuccess?: string;\n successContainer?: string;\n onSuccessContainer?: string;\n};\n\n/**\n * Mirrors `AcceptThemeImages`. Each value is a URL the plugin loads — either an `https://` URL, or\n * a `content://` URL produced by {@link Accept.createLocalThemeImageUri} for an image the host app\n * holds locally.\n */\nexport type AcceptThemeImages = {\n logoText?: string;\n logoTextSolid?: string;\n logoSymbol?: string;\n logoSymbolWithBackground?: string;\n};\n\n/** Mirrors `AcceptThemeVariant`. */\nexport type AcceptThemeVariant = {\n colors?: AcceptThemeColors;\n images?: AcceptThemeImages;\n};\n\n/** Branding applied to the plugin's activation, status, and payment screens. Mirrors `AcceptTheme`. */\nexport type AcceptTheme = {\n light?: AcceptThemeVariant;\n dark?: AcceptThemeVariant;\n};\n\n// ── Subscriptions ─────────────────────────────────────────────────────────────\n\n/** Handle returned by the `on*` listeners. Mirrors Expo's `EventSubscription`. */\nexport type AcceptSubscription = {\n remove: () => void;\n};\n"]}
@@ -0,0 +1,53 @@
1
+ import type { AcceptErrorCode, AcceptErrorDetails } from "./Accept.types";
2
+ /**
3
+ * A failure raised by the Accept SDK. Mirrors `AcceptException` on Android.
4
+ *
5
+ * Branch on {@link AcceptError.code}; the payload-carrying codes expose their fields directly (see
6
+ * {@link AcceptErrorDetails}).
7
+ *
8
+ * ```ts
9
+ * try {
10
+ * await Accept.auth.authenticate(token);
11
+ * } catch (e) {
12
+ * if (AcceptError.is(e) && e.code === 'NoInternetConnection') retryLater();
13
+ * else throw e;
14
+ * }
15
+ * ```
16
+ */
17
+ export declare class AcceptError extends Error implements AcceptErrorDetails {
18
+ /** Which `AcceptException` this is. */
19
+ readonly code: AcceptErrorCode;
20
+ readonly state?: AcceptErrorDetails["state"];
21
+ readonly currency?: string;
22
+ readonly minimum?: number;
23
+ readonly transactionTimeoutMs?: number;
24
+ readonly status?: AcceptErrorDetails["status"];
25
+ readonly environment?: string;
26
+ readonly cause?: string;
27
+ constructor(code: AcceptErrorCode, message: string, details?: AcceptErrorDetails);
28
+ /** Narrows an unknown caught value to an {@link AcceptError}. */
29
+ static is(error: unknown): error is AcceptError;
30
+ }
31
+ /** The `{ code, message, ... }` shape the native side puts on `PaymentEvent.creationFailed`. */
32
+ type SerializedError = {
33
+ code: AcceptErrorCode;
34
+ message: string;
35
+ } & AcceptErrorDetails;
36
+ /** Rebuilds an {@link AcceptError} from the serialized form carried on a payment event. */
37
+ export declare function toAcceptError(serialized: SerializedError): AcceptError;
38
+ /**
39
+ * Rebuilds an {@link AcceptError} from a rejected native call.
40
+ *
41
+ * Expo only carries a `code` and a `message` across the bridge, so the native side packs the
42
+ * human-readable text and the error's fields into the message as JSON. Anything whose payload is
43
+ * missing or doesn't match the `code` — an Expo-level failure such as `ERR_INVALID_ARGUMENT`, or a
44
+ * crash in the module itself — is not an SDK error and is rethrown untouched rather than being
45
+ * dressed up as one.
46
+ */
47
+ export declare function rethrowAsAcceptError(error: unknown): never;
48
+ /** Runs [call], converting any SDK rejection into an {@link AcceptError}. */
49
+ export declare function mapErrors<T>(call: () => Promise<T>): Promise<T>;
50
+ /** Synchronous counterpart of {@link mapErrors}, for the SDK's non-suspending surfaces. */
51
+ export declare function mapErrorsSync<T>(call: () => T): T;
52
+ export {};
53
+ //# sourceMappingURL=AcceptError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcceptError.d.ts","sourceRoot":"","sources":["../src/AcceptError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAE1E;;;;;;;;;;;;;;GAcG;AACH,qBAAa,WAAY,SAAQ,KAAM,YAAW,kBAAkB;IAClE,uCAAuC;IACvC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAG/B,QAAQ,CAAC,KAAK,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC7C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC/C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;gBAGtB,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,kBAAuB;IAQlC,iEAAiE;IACjE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW;CAGhD;AAED,gGAAgG;AAChG,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,kBAAkB,CAAC;AAEvB,2FAA2F;AAC3F,wBAAgB,aAAa,CAAC,UAAU,EAAE,eAAe,GAAG,WAAW,CAGtE;AA0BD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAW1D;AAED,6EAA6E;AAC7E,wBAAsB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAMrE;AAED,2FAA2F;AAC3F,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAMjD"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * A failure raised by the Accept SDK. Mirrors `AcceptException` on Android.
3
+ *
4
+ * Branch on {@link AcceptError.code}; the payload-carrying codes expose their fields directly (see
5
+ * {@link AcceptErrorDetails}).
6
+ *
7
+ * ```ts
8
+ * try {
9
+ * await Accept.auth.authenticate(token);
10
+ * } catch (e) {
11
+ * if (AcceptError.is(e) && e.code === 'NoInternetConnection') retryLater();
12
+ * else throw e;
13
+ * }
14
+ * ```
15
+ */
16
+ export class AcceptError extends Error {
17
+ /** Which `AcceptException` this is. */
18
+ code;
19
+ // Payload fields, populated only for the codes that carry them.
20
+ state;
21
+ currency;
22
+ minimum;
23
+ transactionTimeoutMs;
24
+ status;
25
+ environment;
26
+ cause;
27
+ constructor(code, message, details = {}) {
28
+ super(message);
29
+ this.name = "AcceptError";
30
+ this.code = code;
31
+ Object.assign(this, details);
32
+ }
33
+ /** Narrows an unknown caught value to an {@link AcceptError}. */
34
+ static is(error) {
35
+ return error instanceof AcceptError;
36
+ }
37
+ }
38
+ /** Rebuilds an {@link AcceptError} from the serialized form carried on a payment event. */
39
+ export function toAcceptError(serialized) {
40
+ const { code, message, ...details } = serialized;
41
+ return new AcceptError(code, message, details);
42
+ }
43
+ /**
44
+ * Extracts the native side's JSON payload out of a rejection message.
45
+ *
46
+ * Expo does not hand the message across untouched: every module function rejection is wrapped in
47
+ * its `FunctionCallException`, which keeps the original `code` but rewrites the message as
48
+ *
49
+ * Call to function 'AcceptSdkReactNative.activateTerminal' has been rejected.
50
+ * → Caused by: {"code":"PluginAlreadyAuthenticated","message":"…"}
51
+ *
52
+ * and each further decoration prepends another line. So the payload is located rather than parsed
53
+ * from position zero — from the first `{` to the last `}`, which is exact here because the payload
54
+ * is the only brace-delimited run in the message.
55
+ */
56
+ function extractPayload(message) {
57
+ const start = message.indexOf("{");
58
+ const end = message.lastIndexOf("}");
59
+ if (start === -1 || end <= start)
60
+ return null;
61
+ try {
62
+ return JSON.parse(message.slice(start, end + 1));
63
+ }
64
+ catch {
65
+ return null;
66
+ }
67
+ }
68
+ /**
69
+ * Rebuilds an {@link AcceptError} from a rejected native call.
70
+ *
71
+ * Expo only carries a `code` and a `message` across the bridge, so the native side packs the
72
+ * human-readable text and the error's fields into the message as JSON. Anything whose payload is
73
+ * missing or doesn't match the `code` — an Expo-level failure such as `ERR_INVALID_ARGUMENT`, or a
74
+ * crash in the module itself — is not an SDK error and is rethrown untouched rather than being
75
+ * dressed up as one.
76
+ */
77
+ export function rethrowAsAcceptError(error) {
78
+ const code = error?.code;
79
+ const message = error?.message;
80
+ if (typeof code !== "string" || typeof message !== "string")
81
+ throw error;
82
+ const parsed = extractPayload(message);
83
+ if (parsed?.code !== code)
84
+ throw error;
85
+ return (() => {
86
+ throw toAcceptError(parsed);
87
+ })();
88
+ }
89
+ /** Runs [call], converting any SDK rejection into an {@link AcceptError}. */
90
+ export async function mapErrors(call) {
91
+ try {
92
+ return await call();
93
+ }
94
+ catch (error) {
95
+ rethrowAsAcceptError(error);
96
+ }
97
+ }
98
+ /** Synchronous counterpart of {@link mapErrors}, for the SDK's non-suspending surfaces. */
99
+ export function mapErrorsSync(call) {
100
+ try {
101
+ return call();
102
+ }
103
+ catch (error) {
104
+ rethrowAsAcceptError(error);
105
+ }
106
+ }
107
+ //# sourceMappingURL=AcceptError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcceptError.js","sourceRoot":"","sources":["../src/AcceptError.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,uCAAuC;IAC9B,IAAI,CAAkB;IAE/B,gEAAgE;IACvD,KAAK,CAA+B;IACpC,QAAQ,CAAU;IAClB,OAAO,CAAU;IACjB,oBAAoB,CAAU;IAC9B,MAAM,CAAgC;IACtC,WAAW,CAAU;IACrB,KAAK,CAAU;IAExB,YACE,IAAqB,EACrB,OAAe,EACf,UAA8B,EAAE;QAEhC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;IAED,iEAAiE;IACjE,MAAM,CAAC,EAAE,CAAC,KAAc;QACtB,OAAO,KAAK,YAAY,WAAW,CAAC;IACtC,CAAC;CACF;AAQD,2FAA2F;AAC3F,MAAM,UAAU,aAAa,CAAC,UAA2B;IACvD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,GAAG,UAAU,CAAC;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C;IAC9B,CAAC;AACH,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,aAAa,CAAI,IAAa;IAC5C,IAAI,CAAC;QACH,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC","sourcesContent":["import type { AcceptErrorCode, AcceptErrorDetails } from \"./Accept.types\";\n\n/**\n * A failure raised by the Accept SDK. Mirrors `AcceptException` on Android.\n *\n * Branch on {@link AcceptError.code}; the payload-carrying codes expose their fields directly (see\n * {@link AcceptErrorDetails}).\n *\n * ```ts\n * try {\n * await Accept.auth.authenticate(token);\n * } catch (e) {\n * if (AcceptError.is(e) && e.code === 'NoInternetConnection') retryLater();\n * else throw e;\n * }\n * ```\n */\nexport class AcceptError extends Error implements AcceptErrorDetails {\n /** Which `AcceptException` this is. */\n readonly code: AcceptErrorCode;\n\n // Payload fields, populated only for the codes that carry them.\n readonly state?: AcceptErrorDetails[\"state\"];\n readonly currency?: string;\n readonly minimum?: number;\n readonly transactionTimeoutMs?: number;\n readonly status?: AcceptErrorDetails[\"status\"];\n readonly environment?: string;\n readonly cause?: string;\n\n constructor(\n code: AcceptErrorCode,\n message: string,\n details: AcceptErrorDetails = {},\n ) {\n super(message);\n this.name = \"AcceptError\";\n this.code = code;\n Object.assign(this, details);\n }\n\n /** Narrows an unknown caught value to an {@link AcceptError}. */\n static is(error: unknown): error is AcceptError {\n return error instanceof AcceptError;\n }\n}\n\n/** The `{ code, message, ... }` shape the native side puts on `PaymentEvent.creationFailed`. */\ntype SerializedError = {\n code: AcceptErrorCode;\n message: string;\n} & AcceptErrorDetails;\n\n/** Rebuilds an {@link AcceptError} from the serialized form carried on a payment event. */\nexport function toAcceptError(serialized: SerializedError): AcceptError {\n const { code, message, ...details } = serialized;\n return new AcceptError(code, message, details);\n}\n\n/**\n * Extracts the native side's JSON payload out of a rejection message.\n *\n * Expo does not hand the message across untouched: every module function rejection is wrapped in\n * its `FunctionCallException`, which keeps the original `code` but rewrites the message as\n *\n * Call to function 'AcceptSdkReactNative.activateTerminal' has been rejected.\n * → Caused by: {\"code\":\"PluginAlreadyAuthenticated\",\"message\":\"…\"}\n *\n * and each further decoration prepends another line. So the payload is located rather than parsed\n * from position zero — from the first `{` to the last `}`, which is exact here because the payload\n * is the only brace-delimited run in the message.\n */\nfunction extractPayload(message: string): SerializedError | null {\n const start = message.indexOf(\"{\");\n const end = message.lastIndexOf(\"}\");\n if (start === -1 || end <= start) return null;\n try {\n return JSON.parse(message.slice(start, end + 1));\n } catch {\n return null;\n }\n}\n\n/**\n * Rebuilds an {@link AcceptError} from a rejected native call.\n *\n * Expo only carries a `code` and a `message` across the bridge, so the native side packs the\n * human-readable text and the error's fields into the message as JSON. Anything whose payload is\n * missing or doesn't match the `code` — an Expo-level failure such as `ERR_INVALID_ARGUMENT`, or a\n * crash in the module itself — is not an SDK error and is rethrown untouched rather than being\n * dressed up as one.\n */\nexport function rethrowAsAcceptError(error: unknown): never {\n const code = (error as { code?: string } | null)?.code;\n const message = (error as { message?: string } | null)?.message;\n if (typeof code !== \"string\" || typeof message !== \"string\") throw error;\n\n const parsed = extractPayload(message);\n if (parsed?.code !== code) throw error;\n\n return (() => {\n throw toAcceptError(parsed);\n })();\n}\n\n/** Runs [call], converting any SDK rejection into an {@link AcceptError}. */\nexport async function mapErrors<T>(call: () => Promise<T>): Promise<T> {\n try {\n return await call();\n } catch (error) {\n rethrowAsAcceptError(error);\n }\n}\n\n/** Synchronous counterpart of {@link mapErrors}, for the SDK's non-suspending surfaces. */\nexport function mapErrorsSync<T>(call: () => T): T {\n try {\n return call();\n } catch (error) {\n rethrowAsAcceptError(error);\n }\n}\n"]}