Pay In
The Pay In component is Payabli’s native mobile UI for card and ACH payments in your app. It owns sensitive field state and renders a hosted form. See Tap to Pay if you’re looking for Payabli’s contactless payment component instead.
The component is available for iOS and Android. Where steps differ by platform, open the iOS or Android section.
Prerequisites
The requirements cover your build tools, your Payabli sandbox paypoint, and the OAuth permissions for each operation:
iOS
Before you start, confirm you have:
- Xcode 15 or later and Swift 5.9 or later
- iOS 16.0 or later as your deployment target
- A Payabli sandbox
entryPointwith card and ACH enabled - A Payabli
clientIdandclientSecretwith a permission for each operation you use. See OAuth authentication to provision them.
Android
Before you start, confirm you have:
minSdk23 or later andcompileSdk31 or later. The form’s Compose dependencies can require a highercompileSdk. If yours is too low, the Gradle error names the version you need.- Jetpack Compose, to render the Pay In form
- Payabli Maven repository credentials. Contact your Payabli representative to get them.
- A Payabli sandbox
entryPointwith card and ACH enabled - A Payabli
clientIdandclientSecretwith a permission for each operation you use. See OAuth authentication to provision them.
Installation
Install the Pay In component from the sdk-ios Swift package on iOS, or from Payabli’s Maven repository on Android:
iOS
Install PayabliSDKPayIn from the sdk-ios Swift package. These docs cover version 0.2.0. A later version can change the code that these docs show, so install 0.2.0:
Add the package
In Xcode, choose File → Add Package Dependencies… and enter the sdk-ios repository URL. Then choose the Exact Version dependency rule and enter 0.2.0:
Or add it to your Package.swift dependencies:
Your app’s deployment target must be iOS 16.0 or later. Tap to Pay needs iOS 16.7 or later.
The SDK sends error and usage events to Payabli. The events contain no card, payor, or account data. You can’t turn this off. The SDK’s privacy manifests declare what each module collects. PayabliSDKCore declares device ID, performance data, other diagnostic data, and product interaction, linked to the user, for app functionality and analytics. PayabliSDKPayIn declares payment info, name, email address, and user ID, linked to the user, for app functionality. None of this data is used for tracking. Regenerate your app’s privacy report in Xcode before you update your app’s App Store privacy details.
Android
Install sdk-android-payin from Payabli’s Maven repository. These docs cover version 0.2.0. A later version can change the code that these docs show, so install 0.2.0:
Add the repository
Payabli hosts the SDK in its own Maven repository.
Payabli’s Maven repository requires credentials. Get them from your Payabli representative before you add the repository, or the build can’t download the SDK.
Add the repository to settings.gradle.kts. The content block limits the repository to the groups that Payabli hosts there:
Keep payabli.maven.user and payabli.maven.password in ~/.gradle/gradle.properties or a secret store for your CI builds. Never commit them to your repository.
Add the dependency
Add sdk-android-payin to your app module’s build.gradle.kts:
sdk-android-payin includes sdk-android-core, which holds the session and configuration types, so you don’t need to add sdk-android-core separately.
To use the Pay In and Tap to Pay components in the same app, add com.payabli:sdk-android instead. It includes both components and requires minSdk 30. Add includeGroup("com.fiserv.ch") and includeGroup("com") to the repository’s content block as well, because the card reader library comes from those groups. Tap to Pay also needs the setup in Tap to Pay installation.
The SDK sends error and usage events to Payabli. The events contain no card, payor, or account data. You can’t turn this off. For Google Play’s Data safety form, note that the SDK collects device or other IDs, app interactions, and diagnostics. sdk-android-payin also collects financial info, and personal info from PayabliPayInForm: name, email address, and user IDs. None of this data is shared or used for tracking.
Backend token endpoint
The Pay In component authenticates every request with a short-lived Payabli access token, obtained through a tokenProvider function you implement.
Your backend holds the Payabli clientId and clientSecret, exchanges them for the access token, and never exposes them to your mobile app.
Create the project
This example server uses JavaScript with Node.js and Express.
Requires: Node.js 18 or later, and npm
Create a new Node.js project and enable ES modules:
Write the token endpoint
Create server.js with the following. It returns the token as { "accessToken": "..." }:
Create a .env file next to server.js with your credentials:
Anyone who can call this route gets a token that can charge, store payment methods, and void for your paypoint. Before you go live, replace authenticateUser and mayTakePayments with the same session and permission checks the rest of your app uses.
Keep clientId and clientSecret on your server, in environment variables or a secret store. Never commit .env to source control.
Call it from your app
Pass a tokenProvider that calls this endpoint and returns the token when you start the session:
iOS
A call that takes longer than 30 seconds, throws, or returns a token the SDK can’t use fails with PayabliErrorType.tokenProviderFailed. If Payabli refuses the new token too, the call fails with .tokenExpired (1002). The SDK doesn’t retry .tokenProviderFailed or .tokenExpired itself.
Android
A call that takes longer than 30 seconds, throws, or returns a token the SDK can’t use fails with PayabliErrorType.TOKEN_PROVIDER_FAILED. initialize and the token provider are suspend functions, so call initialize from a coroutine. Don’t catch CancellationException in the provider. The SDK doesn’t retry TOKEN_PROVIDER_FAILED or TOKEN_EXPIRED itself. Try again only when the user asks, or wait longer between attempts.
The SDK calls the token provider before its first request, and again when a token is rejected. Return a newly minted token each time. Concurrent callers share one call, so you don’t need to cache the token or schedule refreshes yourself. Don’t wait in the provider on an SDK call that needs a new token, because it can’t finish until the provider returns.
Anyone who can call your token endpoint gets a token that can charge, store payment methods, and void for your paypoint. Authenticate the caller and check that they’re allowed to take payments before you return a token.
Operations
The Pay In form has three operations:
- Store a payment method — Tokenizes a card or ACH account for later use, without charging it.
- Capture — Authorizes and captures a card or ACH payment in one step.
- Authorize — Authorizes a card payment without capturing it. The form offers card only in this mode.
iOS
PayabliPayIn’s operation parameter selects the hosted form’s behavior: .storePaymentMethod (the default), .capture, or .authorize.
PayabliPayIn also exposes direct methods for building your own UI: capture(_:), authorize(_:), captureAuthorizedTransaction(_:), voidTransaction(_:), readTransaction(_:), addCard(_:options:), addBankAccount(_:options:), and addPaymentMethod(_:options:). capture(_:) and authorize(_:) take a PayabliPayInRequest(paymentMethod:options:). readTransaction(_:) reads a transaction so you can check a payment whose outcome is unknown. These methods take card and bank details as String values in PayabliPayInCardData and PayabliPayInBankAccountData, so your app holds the raw values.
Android
PayabliPayInForm’s operation parameter selects the form’s behavior: PayabliPayInOperation.StoreMethod(options), PayabliPayInOperation.Capture(options), or PayabliPayInOperation.Authorize(options).
PayabliPayIn also exposes direct suspend methods for building your own UI: capture(request), authorize(request), captureAuthorizedTransaction(request), voidTransaction(transId), readTransaction(transId), and storeMethod(request). readTransaction reads a transaction so you can check a payment whose outcome is unknown. These methods take card numbers, security codes, and bank account numbers in SensitiveDigits buffers. Collect the digits into a CharArray, never a String. SensitiveDigits.of copies the array, so overwrite your array as soon as you build the buffer. Wrap each buffer in use, which erases the buffer when the block returns:
If you collect card data in your own UI and pass it to the direct methods, your app handles card numbers and security codes. That puts your app in scope for PCI DSS. The form keeps that data out of your app.
Implementation walkthrough
This walkthrough builds a minimal card or ACH capture, from constructing PayabliPayIn through rendering the form:
iOS
Loading walkthrough...
/// Add the imports
Import PayabliSDKCore, which holds the session and configuration types, and PayabliSDKPayIn. Then create a view model that holds the component. You can use your own API client and view model patterns. This walkthrough uses a minimal ObservableObject.
/// Implement the backend token provider
Add a function that calls your backend’s token endpoint and returns a Payabli access token. Your backend holds the Payabli clientSecret, not the app. In production, send your app’s own session credential with this request so your token endpoint can authenticate the caller.
/// Start the session
Start one PayabliSession with your entrypoint, environment, and token provider before you build a component. PayabliConfig throws if the entrypoint is blank. Start the session once: calling initialize again with the same settings returns the same session, and different settings throw invalidConfiguration. If Payabli refuses the session’s credential for good (tokenExpired), calling initialize again starts a new session. Pay In and Tap to Pay both run on this session.
/// Create the Pay In component
Construct PayabliPayIn on the session with the .capture operation and a requestConfiguration that describes the amount to charge. Identify the payor in customerData, because a paypoint can require customer identifiers and refuses a charge without them with E7020. Set orderId to your own order reference so you can find the transaction if its outcome is unknown.
/// Render the hosted form and handle the result
Add a view that renders PayabliPayInView and handles the result. The hosted form collects card or ACH details itself. Your view never sees raw card data. A returned result means that the payor was charged. If it has no transaction ID, find the transaction by orderId. If the error is PayabliPayInError.submissionInterrupted, the outcome is unknown. The error carries a paymentTransId when Payabli returned one. Read that transaction with readTransaction(_:), or find it by orderId, before you let the payor try again. The form shows the payor its own message for every error, so your onError handler only needs to reconcile and log.
Android
Loading walkthrough...
/// Add the imports
Import the core session and configuration types from com.payabli.sdk.core, and the Pay In types from com.payabli.sdk.payin. You can use your own API client and view model patterns. This walkthrough uses a minimal ViewModel and a composable screen.
/// Implement the backend token provider
Add a suspend function that calls your backend’s token endpoint and returns a Payabli access token. Your backend holds the Payabli clientSecret, not the app. In production, send your app’s own session credential with this request so your token endpoint can authenticate the caller.
/// Start the session
Start one PayabliSession with your entrypoint, environment, and token provider before you build a component. PayabliConfig throws if the entrypoint is blank. Start the session once. Calling initialize again with the same settings returns the same session. Different settings throw a PayabliException whose type is INVALID_CONFIGURATION. Pay In and Tap to Pay both run on this session. initialize is a suspend function, so call it from a coroutine.
/// Create the Pay In component
Construct PayabliPayIn in a ViewModel, and pass the view model’s viewModelScope. The component and any running submission then keep working after configuration changes, such as a screen rotation. Set the operation to PayabliPayInOperation.Capture. Identify the payor in customerData, because a paypoint can require customer identifiers and refuses a charge without them with E7020. Set orderId to your own order reference so you can find the transaction if its outcome is unknown. Set paymentReference to your own identifier for the payment. Store the operation in Compose state. After an unknown outcome, you can then replace it with an operation that sets attempt = PayabliAttempt.Retry. A retry resends the earlier payment’s idempotency key, so Payabli doesn’t charge the payor twice.
/// Render the form and handle the result
Add a composable that renders PayabliPayInForm and handles the result. The form collects card or ACH details itself. Your code never sees raw card data. A success means that the payor was charged. If the result has no transaction ID, find the transaction by orderId and store its ID. If the failure’s cause is PayInException.Unsettled, the outcome is unknown. When cause.paymentTransId is set, read the transaction with readTransaction and check its status. If the payment wasn’t charged, start a new payment with a new paymentReference. If its outcome is still unknown, send the next submission as a retry with the paymentReference that Unsettled returns. Hide the form until you resolve the earlier payment, even when the read fails. Otherwise, the payor can submit a new payment that charges again.
Implementation reference
The form’s configuration controls its fields, labels, and layout. The request configuration carries the data sent with each operation.
Form configuration
The form configuration controls which fields the form shows, how it groups and labels them, and how it formats input:
iOS
PayabliPayInFormConfiguration controls the hosted form’s fields, labels, and layout for every operation. Its options carry the data that the form sends when it stores a payment method. Its hiddenValues carry values that the form submits without showing a field. The hosted form is shared by all three operations. See Operations for what each one does.
Hosted methods the payor can select. For .authorize, the form offers card only. When the payor switches methods, the form clears the fields that only the other method shows.
Initial selected method. Falls back to the first allowed method if .card isn’t allowed.
Custom section grouping for card fields. Required and payment-summary fields are appended automatically if missing.
properties
Optional stable identifier. Defaults to the section title or its joined field names.
Section title, for example Card Information.
Per-section text style override.
Ordered PayabliPayInField values in this section.
Vertical spacing between inputs in this section.
Horizontal spacing for paired inputs in this section.
Per-field vertical spacing overrides, keyed by field.
.inputs for a section of input fields, or .summary for the section that shows the operation’s amounts. A capture or authorize form without a .summary section gets one. A .summary section with no title has the heading Payment. An .inputs section with no title has no heading.
Custom section grouping for ACH fields. .secCode is never rendered, even if listed.
properties
Optional stable identifier. Defaults to the section title or its joined field names.
Section title, for example Card Information.
Per-section text style override.
Ordered PayabliPayInField values in this section.
Vertical spacing between inputs in this section.
Horizontal spacing for paired inputs in this section.
Per-field vertical spacing overrides, keyed by field.
.inputs for a section of input fields, or .summary for the section that shows the operation’s amounts. A capture or authorize form without a .summary section gets one. A .summary section with no title has the heading Payment. An .inputs section with no title has no heading.
Flat card field order, used only when cardSections is nil.
Flat ACH field order, used only when bankSections is nil.
Values submitted with the form without rendering an editable field. The form also sends its ACH values and customerData with captures and authorizations. Its methodDescription replaces orderDescription on a charge.
properties
.personal or .business.
.ppd, .web, .tel, .ccd, or .boc.
Default or hidden customer data, merged with any visible customer fields.
properties
Custom identifier fields, when the paypoint uses custom identifiers instead of name, email, or customer ID.
Options sent when the form stores a payment method with .storePaymentMethod. These correspond to the options of Save a payment method.
properties
properties
Custom identifier fields, when the paypoint uses custom identifiers instead of name, email, or customer ID.
vendorId and vendorNumber.
Client-side validation, run before a request is sent. Same fields and defaults as validation in PayabliPayInRequestConfiguration. On a store form, validation in requestConfiguration replaces it.
Title, subtitle, submit button text, field labels, and placeholders.
properties
Form title. Unset by default, so the form shows no title.
Submit button text. Unset by default, so the button names the operation: Pay for .capture, Authorize for .authorize, and Save for .storePaymentMethod. While a submission runs, the button shows the operation in progress, such as Paying….
Visible and accessibility label text, keyed by PayabliPayInField.
Placeholder text, keyed by PayabliPayInField.
Label on the payment summary’s Total row.
.external shows visible labels. .placeholder uses placeholder-first inputs.
Global visible-label override. Leave unset to follow labelLayout.
Fields to hide the visible label for. Accessibility labels are unaffected.
Card number spacing, expiration separator, and ACH account masking.
properties
Adds visual card number grouping.
Separator used in expiration entry. An empty string resolves to /.
Masks ACH account number entry in the hosted field. The routing number isn’t masked.
Default and per-field input sizes. Height is clamped to the accessibility minimum touch target.
properties
Default PayabliPayInInputSize: optional width, height (default 52), and horizontalPadding (default 14).
Per-field PayabliPayInInputSize overrides, keyed by PayabliPayInField.
.leading, .trailing, or .hidden.
.top or .aboveSubmitButton. The form shows the payor a fixed message for the failure’s category, never the SDK’s error text. A failed save shows a message about saving. When Payabli rejects a specific field, the form marks that field instead of showing a message.
Optional visible fields to require. .amount is always required.
Whether the payment summary shows the Amount row.
Text styles and spacing for the read-only amount and fee rows on capture and authorize forms. Forms that store a payment method leave the rows out. The row labels come from labels.fieldLabels for .amount, .serviceFee, and .surchargeFee, and the Total row’s label from labels.total. The Total row shows totalAmount, which already includes any surcharge. The Amount row shows totalAmount minus the service fee and the surcharge.
properties
Font and color for the label text.
Font and color for the value text.
Card, ACH, customer, and payment-summary fields available for fields, cardFieldOrder, bankFieldOrder, requiredFields, and hiddenFieldLabels.
cases
bankSections doesn’t render it.Android
Construct PayabliPayIn on the session, then render it with PayabliPayInForm:
PayabliPayIn takes three values: the session, the paypoint’s entryPoint, and a CoroutineScope. Use a scope that survives configuration changes, such as a screen rotation. A ViewModel’s viewModelScope works. If your app creates PayabliPayIn again when the activity is re-created, the form loses the result of a submission that’s still running.
PayabliPayInForm takes these parameters:
The PayabliPayIn component that the form submits through.
The operation that the form runs when the payor submits it: StoreMethod(options), Capture(options), or Authorize(options). See Operations.
The form’s fields, sections, and layout, described later in this section.
A Compose Modifier for the form.
Title, subtitle, submit button text, field labels, and placeholders.
properties
Form title. Unset by default, so the form shows no title.
Submit button text. Unset by default, so the button names the operation: Pay for Capture, Authorize for Authorize, and Save for StoreMethod. While a submission runs, the button shows the operation in progress, such as Paying….
Visible and accessibility label text, keyed by PayInField.
Placeholder text, keyed by PayInField.
Label on the payment summary’s Total row.
Overrides the form’s style. See Style.
Called when a submission succeeds. For Capture and Authorize, the value is Succeeded.Payment, and its result is a PayInResult. For StoreMethod, the value is Succeeded.Method, and its storedMethod is a PayInStoredMethod.
Called when a submission fails. See Outcomes and errors.
Called when the payor switches between Card and BankAccount.
PayInFormConfiguration controls the form’s fields, sections, and layout for every operation. It takes these fields:
Methods the payor can select. For Authorize, the form offers card only.
Initial selected method. If it isn’t in allowedMethods, the form selects the first allowed method.
The card fields in each section, in order. defaultCardSections() returns cardholder name, card number, expiration, security code, and postal code. A summary section with the amounts follows them.
properties
Ordered PayInField values in this section.
Section title, for example Card Information.
Inputs for a section of input fields, or Summary for the section that shows the operation’s amounts. A Summary section can list only Amount, ServiceFee, and SurchargeFee. A Summary section with no title, or a blank one, has the heading Payment. An Inputs section with no title, or a blank one, has no heading.
The ACH fields in each section, in order. defaultBankSections() returns account holder, routing number, account number, and account type. A summary section with the amounts follows them.
properties
Ordered PayInField values in this section.
Section title, for example Card Information.
Inputs for a section of input fields, or Summary for the section that shows the operation’s amounts. A Summary section can list only Amount, ServiceFee, and SurchargeFee. A Summary section with no title, or a blank one, has the heading Payment. An Inputs section with no title, or a blank one, has no heading.
Optional visible fields to require. The form already requires every visible field except MethodDescription, CustomerNumber, DeviceId, and the summary fields.
External shows labels above the fields. Placeholder uses Material floating labels.
Fields to hide the visible label for. Accessibility labels are unaffected.
Card number grouping, expiration separator, and ACH account masking.
properties
Adds visual card number grouping.
Separator used in expiration entry. It can’t be empty, and it can’t contain digits.
Masks ACH account number entry. The routing number isn’t masked.
Whether the summary section shows the Amount row. The Amount row shows totalAmount minus the service fee and the surcharge. The Total row shows totalAmount, which already includes any surcharge.
The SDK checks a configuration when you build it. If the form couldn’t submit as configured, PayInFormConfiguration throws IllegalArgumentException. Common causes:
- A card form is missing one of the card fields.
- A summary section lists a field other than
Amount,ServiceFee, orSurchargeFee. - A section lists a field that its payment method doesn’t use, such as
RoutingNumberin a card section.
Card, ACH, customer, and payment summary fields available for sections, requiredFields, hiddenFieldLabels, and labels.
cases
StoreMethod only.Request configuration
The request configuration carries the payment and customer data that each operation sends to Payabli:
iOS
PayabliPayInRequestConfiguration carries the request data for hosted capture and authorize forms. On a store form, its paymentDetails aren’t used. Its customerData is used ahead of options.customerData, and its validation replaces options.validation. The direct capture(_:) and authorize(_:) methods take a PayabliPayInRequest instead. Build it with PayabliPayInRequest(paymentMethod:options:): pass the card, bank account, or stored method as paymentMethod, and this configuration as options:
properties
The amount charged. It includes serviceFee and surchargeFee. Must be greater than 0 after rounding to two decimal places, so 0.001 is refused. serviceFee plus surchargeFee must be less than totalAmount.
Included in totalAmount. Must not be negative.
Included in totalAmount. Must not be negative.
For example, USD.
Defaults merged with form-entered customer data. A paypoint can require customer identifiers, such as customerNumber. If they’re missing, the paypoint refuses the charge with E7020. See the unified response codes reference.
properties
Custom identifier fields, when the paypoint uses custom identifiers instead of name, email, or customer ID.
Your own order reference. Set it on every request so you can find the transaction in the Payabli Portal if the outcome is unknown. A retry must send the same orderId as the payment it repeats.
Your own identifier for this payment. The SDK doesn’t send it to Payabli. If you don’t set one, the SDK generates one and returns it with submissionInterrupted. A blank value is refused. The SDK creates and stores the idempotency key for every charge, so you never set one.
.newPayment or .retry. Set .retry, with the same paymentReference, only to try again a payment whose outcome is unknown. See Retry a payment.
Client-side validation, run before a request is sent.
properties
Runs a checksum on card numbers to catch typos before the request is sent.
Runs an ABA checksum on ACH routing numbers.
Android
PayInTransactionOptions carries the request data for Capture and Authorize forms. It isn’t used for StoreMethod. The direct capture and authorize methods take a PayInRequest instead, which pairs a required paymentMethod with these options.
properties
The amount charged. It includes serviceFee and surchargeFee. Must be greater than 0 after rounding to two decimal places, so 0.001 is refused. serviceFee plus surchargeFee must be less than totalAmount.
Included in totalAmount. Must not be negative.
Included in totalAmount. Must not be negative.
For example, USD.
Defaults merged with form-entered customer data. A paypoint can require customer identifiers, such as customerNumber. If they’re missing, the paypoint refuses the charge with E7020. See the unified response codes reference.
properties
Payabli’s internal customer ID, when the customer is already registered.
Your own order reference. Set it on every request so you can find the transaction in the Payabli Portal if the outcome is unknown. A retry must send the same orderId as the payment it repeats.
Checks a bank account before it’s debited, in addition to any check that the merchant’s settings already run. Setting this value to false doesn’t turn off that check.
Applies only when the payor can’t be matched to an existing customer. When this value is true, each such payment creates a new customer record.
Client-side validation, run before a request is sent.
properties
Runs a checksum on card numbers to catch typos before the request is sent.
Runs an ABA checksum on ACH routing numbers.
Your own identifier for this payment. The SDK doesn’t send it to Payabli. If you don’t set one, the SDK generates one and returns it in PayInException.Unsettled.paymentReference. A blank value is refused. The SDK creates and stores the idempotency key for every charge, so you never set one.
NewPayment or Retry. Set Retry, with the same paymentReference, only to try again a payment whose outcome is unknown. See Retry a payment. PayabliAttempt is in com.payabli.sdk.core.model.
PayInStoreOptions carries the options for StoreMethod forms. The direct storeMethod method takes the same options in a PayInStoreRequest. These correspond to the options of Save a payment method.
properties
Payabli’s internal customer ID, when the customer is already registered.
vendorNumber, name, ein, phone, and email.
Client-side validation, run before a request is sent. Same fields and defaults as validation in PayInTransactionOptions.
Sheet presentation
On iOS, you can present the form in a sheet. On Android, you place the form in a container of your own:
iOS
PayabliPayInSheetConfiguration controls the sheet presentation for .payabliPayInSheet(...). The sheet wraps the same hosted form as PayabliPayInView, so configuration, requestConfiguration, and style still apply:
Sheet title. Falls back to the form’s labels.title when movesFormHeaderToSheetHeader is true.
Sheet subtitle. Falls back to the form’s labels.subtitle when movesFormHeaderToSheetHeader is true.
.close, .back, or .hidden.
Dismisses the sheet automatically after onCompleted fires.
SwiftUI presentation detents. An empty set resolves to .large.
SwiftUI drag indicator visibility.
Padding around the sheet’s content.
Moves the form’s title and subtitle into the sheet header instead of rendering them inline.
Adds a detent sized to the form’s measured content height, when it fits.
Expands to .large if the form’s content doesn’t fit the selected detent.
Android
The Android SDK doesn’t include a sheet. Render PayabliPayInForm in a container of your own, such as a Material ModalBottomSheet.
Response reference
A successful operation returns the transaction or the saved payment method:
iOS
PayabliPayInResult is a unified wrapper for both token-storage and transaction operations.
.storedPaymentMethod or .transaction.
Stored-method result code, or transaction response code.
Human-readable result or failure reason, when the service returns one.
Present for .transaction results. Additional detail beyond reason.
Present for .transaction results. Suggested next step, when the service returns one.
Present when kind is .storedPaymentMethod.
properties
nil when the service’s response doesn’t include an ID.
.card or .bankAccount.
Present when kind is .transaction. Covers capture, authorize, and capture-authorized results.
properties
Optional, and can be absent even in a completed result. When it’s absent, the call still succeeded: a capture was charged, and an authorization placed a hold. Find the transaction by your orderId to get its ID. When it’s present, you can read the transaction with readTransaction(_:).
The order reference sent with the request, when present.
The transaction’s status, taken from transStatus. It’s nil when transStatus is absent. .captured means paid. .declined, .voided, and .blocked mean not paid. .initiated, .authorized, .failed, and .other(_:) mean that the outcome is unknown. Read the transaction again later before you act on it.
Processor-level response detail. See Make a transaction (v2) for the underlying field semantics.
properties
The order reference the processor returned, when present.
Present for .transaction results. The raw response the transaction fields above were parsed from.
properties
Same shape as transaction above.
Android
A successful Capture or Authorize returns a PayInResult. A successful StoreMethod returns a PayInStoredMethod. readTransaction returns a PayInTransaction directly, not inside a PayInResult. A transaction that you read this way doesn’t include connectorName or customerId.
properties
The service’s response code.
properties
Optional, and can be absent even in a completed result. When it’s absent, the call still succeeded: a capture was charged, and an authorization placed a hold. Find the transaction by your orderId to get its ID.
The transaction’s status, taken from transStatus. It’s null when the response has no status number. Captured means paid. Declined, Voided, and Blocked mean not paid. Initiated, Authorized, Failed, and Other mean that the outcome is unknown. Read the transaction again later before you act on it. Other carries the number in raw.
properties
The stored method’s ID. To charge it later, pass PayInPaymentMethod.Stored(method, storedMethodId) as the payment method.
Card or BankAccount.
Outcomes and errors
Every operation ends in an outcome that tells you whether the payor was charged and whether it’s safe to retry:
iOS
Every charge ends in one of three outcomes: charged, not charged, or unknown. Only not charged is safe to charge again as a new payment. To repeat a payment whose outcome is unknown, send it as a retry. See Retry a payment.
A success means something different for each call:
For voidTransaction(_:), transactionFailed means the void was refused. It doesn’t mean the original payment wasn’t charged.
Don’t show error.localizedDescription to the payor, and don’t log it. It names what the service rejected and can quote what was submitted. Show the payor a message for the error’s category instead, such as .declined, .retryLater, or .outcomeUnknown, and log (error as? any PayabliError)?.code. Check for submissionInterrupted before you check category. This error keeps the category of the error that caused it, so a rate-limit or credential error can arrive for a payment that Payabli processed. The form shows the payor its own message, so you don’t need to show one for form errors.
Android
Every charge ends in one of three outcomes: charged, not charged, or unknown. Only not charged is safe to charge again as a new payment. To repeat a payment whose outcome is unknown, send it as a retry. See Retry a payment.
Every direct method returns a Kotlin Result. If the call is canceled, the method throws a CancellationException instead. A form reports its result through onCompleted and onFailed. A success means something different for each call:
Check for PayInException.Unsettled before you branch on type or category. An Unsettled failure keeps the type and category of the error that caused it, such as TOKEN_EXPIRED. The category alone doesn’t tell you whether the payor might have been charged.
For voidTransaction, a refusal means that the void was refused. It doesn’t mean that the original payment wasn’t charged.
If you call captureAuthorizedTransaction or voidTransaction again with the same transaction ID after an unknown outcome, the SDK resends the same key. If Payabli refuses that repeat, the failure is PayInException.Unsettled with type RETRY_REFUSED. Read the transaction instead of calling again.
When a form submission fails, PayInSubmissionState.Failed carries:
cause: The exception. It tells you whether a payment might still be outstanding. Check it first.fieldErrors: The fields that the service refused, keyed byPayInField. It’s empty when the refusal names no field.
When cause is PayInException.Unsettled, its paymentReference names the payment to retry, and its paymentTransId names the transaction to read back when Payabli returned one.
After Payabli responds, the form clears the card number, expiration date, security code, routing number, and account number. If the submission is refused before Payabli can process it, such as for an amount that can’t be sent, the form keeps these values.
PayInException.Refused and PayInException.ServiceError carry failure, a PayInFailure with the service’s code, reason, explanation, action, and paymentTransId. Show reason, explanation, and action to the payor, but don’t log them, because they can repeat what was submitted. Log the exception’s code instead.
Retry a payment
When a payment’s outcome is unknown, you can send the same payment again as a retry. Payabli recognizes the repeat and doesn’t charge the payor twice:
iOS
Every charge sends an idempotency key that the SDK creates and stores, so you don’t set one. Name each new payment with paymentReference on the request’s options, or let the SDK name it. A charge whose outcome is unknown ends in submissionInterrupted, which carries that paymentReference.
Read the transaction first when you can. To repeat the same payment, set attempt: .retry and the same paymentReference on the options. The SDK resends that payment’s key, so Payabli recognizes the repeat and doesn’t charge twice:
A retry with no paymentReference is refused as invalid input and isn’t sent.
A retry follows these rules:
- Same payment. A retry must have the same amount, service fee, surcharge, currency, and kind of payment method as the payment it repeats. If that payment set an
orderId, the retry must set the same one. Otherwise, the call fails with.retryNotSamePayment(1022) and isn’t sent. - One call per payment at a time. While a call for a payment is still being sent, any other call for the same payment fails with
.paymentReferenceOpen(1023) and isn’t sent. This applies to a retry, and to a capture or void of a transaction that’s still being captured or voided. A new payment that reuses thepaymentReferenceof a payment whose outcome is unknown also fails with 1023. To repeat that payment, send it as a retry. A blankpaymentReferenceis refused as invalid input. - Refused retry. If Payabli refuses the retry, the call ends in
submissionInterruptedwith type.retryRefused(1021). The earlier attempt reached Payabli, and its outcome is still unknown. Read the transaction before you try again. If Payabli refuses the retry because it matches an earlier payment, the type is.conflict. - Keys in memory, shared per entrypoint. The SDK stores each key in memory for a limited time after the latest send whose outcome is unknown. Every
PayabliPayInfor the same entrypoint and environment shares the stored keys, so a retry from a newPayabliPayInresends the key. The SDK stores at most 16 keys for each entrypoint and environment. A retry that Payabli refuses, or one that never leaves the device, doesn’t extend that time. A retry sends a new key, and can charge again, if that time has passed, if 16 keys were already stored when the payment was sent, or if your app restarted. In those cases, read the transaction instead of retrying.
captureAuthorizedTransaction(_:) and voidTransaction(_:) resend the stored key for their transaction automatically.
Android
Every charge sends an idempotency key that the SDK creates and stores, so you don’t set one. Name each new payment with paymentReference, or let the SDK name it. A charge whose outcome is unknown fails with PayInException.Unsettled, which returns that paymentReference.
Read the transaction first when you can. To repeat the same payment, send it with the same paymentReference and attempt = PayabliAttempt.Retry. The SDK resends that payment’s key, so Payabli recognizes the repeat and doesn’t charge twice:
A retry with no paymentReference fails with PayInException.InvalidInput naming paymentReference, and isn’t sent.
A retry follows these rules:
- Same payment. A retry must have the same amount, service fee, surcharge, currency, and kind of payment method as the payment it repeats. If that payment set an
orderId, the retry must set the same one. Otherwise, the call fails withRETRY_NOT_SAME_PAYMENT(1022) and isn’t sent. - One call per payment at a time. While a call for a payment is still being sent, any other call for the same payment fails with
PAYMENT_REFERENCE_OPEN(1023) and isn’t sent. This applies to a retry, and to a capture or void of a transaction that’s still being captured or voided. A new payment that reuses thepaymentReferenceof a payment whose outcome is unknown also fails with 1023. To repeat that payment, send it as a retry. - Refused retry. If Payabli refuses the retry because it already has that payment, the failure is
PayInException.UnsettledwithtypeRETRY_REFUSED(1021). The earlier attempt reached Payabli, and its outcome is still unknown. Read the transaction before you try again. - Keys in memory, shared per entrypoint. The SDK stores each key in memory. Every
PayabliPayInfor the same entrypoint and environment shares the stored keys, so a retry from a newPayabliPayInresends the key. The SDK stores keys for up to 16 unknown payments for each entrypoint and environment. - Time limit. The SDK keeps a key for four minutes after the latest send whose outcome is unknown. A retry refused with
RETRY_REFUSED, or one that never leaves the device, doesn’t restart the four minutes. - When a retry is a new payment. A retry sends a new key, and can charge again, if four minutes have passed, if your app restarted, or if 16 keys were already stored. In those cases, read the transaction instead of retrying.
captureAuthorizedTransaction and voidTransaction don’t take attempt. If you call either one again with the same transaction ID, the SDK resends the stored key.
Theming and diagnostics
Style the form to match your app, and use the SDK’s diagnostics when you need to debug.
Style
The form follows your app’s look by default. You can override its fonts, colors, shapes, and spacing:
iOS
Use PayabliPayInStyle to style the hosted form. Pass it directly to PayabliPayInView or .payabliPayInSheet(...), or inject it with .payabliPayInStyle(_:).
To use a custom font:
Android
The form uses the colors, typography, and shapes of your app’s MaterialTheme. Light mode, dark mode, and dynamic color work without extra setup. To change individual values, build a style from the defaults and your overrides:
To apply one style to every form in a part of your UI, provide it through the LocalPayInFormStyle composition local. PayInFormStyleOverrides can set:
If you draw your own payment summary, use PayInSummaryRows to get each row as the form shows it: labelText and totalLabelText for the labels, rowAmount and totalRowAmount for the amounts, and formattedAmount for an amount as text.
Diagnostics
Each platform gives you a different way to debug a failure. On Android, use a verbose log level only for local debugging or QA:
iOS
To debug a failure on iOS, log the error’s code and category. The iOS SDK has no diagnostics handler and no log level that you can set:
Don’t log localizedDescription, reason, or detail, because they can quote what was submitted. Give the code to Payabli support when you report a failure.
Android
The Android SDK has no diagnostics handler. To debug, set the SDK’s log level with PayabliSession.setLogLevel. The SDK writes its log to Logcat. It writes messages at the level you set and at every more severe level. LogLevel.NONE turns logging off.
By default, debug builds log at DEBUG. Release builds log nothing unless you call setLogLevel, whichever environment the app uses. Use a verbose level only for local debugging or QA. Don’t ship it in production builds.
Android also filters each log tag, so DEBUG lines don’t appear until you turn on the tag. To see them, run adb shell setprop log.tag.<TAG> DEBUG for each tag you need: PayabliCore, PayabliAuth, PayabliNetwork, PayabliTokenization, PayabliTapToPay, or PayabliTelemetry.
Example app
Each SDK repository includes an example app and a local token server that you can run against your sandbox paypoint:
iOS
The sdk-ios repository includes PayabliDemo, a SwiftUI example app that demonstrates PayabliPayIn and PayabliTTP (storing a payment method, card and ACH capture, and Tap to Pay), alongside a bundled local Node.js token server for testing.
Configure your secrets
Copy the secrets template and the environments template. Copy ExtraEnvironments.swift without changes, because the app offers sandbox and production. Then fill in your sandbox identifiers and point the app at the bundled local token server:
Loading walkthrough...
/// Set your sandbox identifiers
In App/Configuration/Secrets.swift, set the sandbox entry in entryPoints to your sandbox entryPoint. There’s no App ID to set: the SDK reads it from the signed app, and the TapToPay tab shows the value to register as an authorized app. localNetworkHost is the fallback host a physical device uses when you don’t pass -PayabliTokenHost. Set it to the output of scutil --get LocalHostName on your Mac, followed by .local:
/// Point the app at the local token server
Both token endpoints ship pointing at a placeholder backend. Switch them to DemoConfiguration.TokenServer.accessTokenURL, which resolves to 127.0.0.1 in the Simulator, so the Save and Capture tabs work there without a real backend. The TapToPay tab needs a physical device, which also needs the server setup in the next step:
Start the local token server
In a separate terminal, start the bundled LocalTokenServer. It needs Node.js 18 or later:
Edit .env and set PAYABLI_ACCESS_TOKEN to a short-lived sandbox access token, then start the server:
The server binds only to 127.0.0.1 by default and doesn’t authenticate callers, so run it only on your own machine.
Tap to Pay requires a physical device. To test on one, the phone must reach the server over your network:
-
Start the server on all interfaces. Do this only on a trusted network, and stop the server when you’re done:
-
In Xcode, choose Product → Scheme → Edit Scheme → Run → Arguments and pass your Mac’s local network address, on the same network as the phone:
-
Allow Local Network access when the app asks for it on the phone. See the
LocalTokenServerREADME for the credential-exchange mode and physical-device networking notes.
Run the app
Open PayabliDemo.xcodeproj in Xcode and set DEVELOPMENT_TEAM on the project, not on a target, so every target signs with it. Select the PayabliDemo sandbox scheme, which picks the sandbox entry from Secrets.entryPoints, and run it. The Save and Capture tabs work in the Simulator. The TapToPay tab requires a physical device that meets the prerequisites.
The example app assumes a sandbox entryPoint with card, ACH, and Tap to Pay enabled. Contact your Payabli representative if your sandbox paypoint doesn’t have these enabled yet.
Android
The sdk-android repository includes a Jetpack Compose example app that demonstrates PayabliPayIn and PayabliTTP (storing a payment method, card and ACH capture, and Tap to Pay), alongside a bundled local Node.js token server for testing.
Clone the repository
Clone sdk-android at the release you’re integrating:
The build downloads the card reader library from Payabli’s Maven repository. Add the credentials that Payabli gave you to ~/.gradle/gradle.properties:
Configure your settings
Copy the settings template, then set your sandbox entrypoint:
secrets.properties holds no credentials, because the app gets its access token from the local token server. To check the signing certificate before device attestation runs, set payabli.demo.signingCertificate to the SHA-256 digest of the certificate the build is signed with.
Start the local token server
In a separate terminal, start the bundled token server. It needs Node.js 18 or later and has no dependencies:
Edit .env and set PAYABLI_ACCESS_TOKEN to a short-lived sandbox access token, then start the server:
The server binds only to 127.0.0.1 by default and doesn’t authenticate callers, so run it only on your own machine. How the app reaches it depends on where the app runs:
-
Emulator (Pay In only): The app reaches the server at
10.0.2.2:8787with no setup. -
Physical phone with USB debugging (Pay In only): Forward the port over USB:
-
Physical phone for Tap to Pay: Tap to Pay requires USB debugging and developer options to be turned off, so
adb reverseisn’t available. The phone reaches the server over your network instead:-
On a trusted network only, start the server on all interfaces instead, and stop it when you’re done:
-
In
example/secrets.properties, setpayabli.demo.tokenHostto your computer’s local network address and port, for example192.168.1.42:8787. -
Add the same local network address to
example/src/debug/res/xml/network_security_config.xml, because the app permits plain HTTP only to the addresses listed there.
-
See the example-server README for the credential exchange mode and other networking options.
Run the app
To run the Save and Capture tabs on an emulator or on a phone with USB debugging, install and launch the app from the repository root:
The TapToPay tab needs:
- A physical phone that meets the prerequisites
- The example app enrolled with Payabli for your computer
com.payabli.example.appregistered as one of the paypoint’s authorized apps
To set up Android Tap to Pay, including enrolling your app with the card reader and testing in sandbox, contact Payabli support.
The build is signed with your computer’s Android debug key, so each developer needs their own enrollment. To enroll, run ./gradlew :example:signingReport and copy the SHA-256 value under Variant: debug. Send that value to your Payabli representative with the package name com.payabli.example.app.
Tap to Pay requires developer options to be turned off, so you can’t install this build with adb. Build the Android package (APK) instead:
The APK is at example/build/outputs/apk/debug/example-debug.apk. Install it on the phone as a downloaded APK or through Firebase App Distribution. Google Play doesn’t accept a debug-signed APK, even on a testing track, and sandbox doesn’t require a Google Play install.
Turn off developer options and USB debugging before you install the app. If this device had them turned on before, restart it after you turn them off, then install the app.
The Config tab shows the values that the SDK uses, and checks whether the app can reach the token server.
The example app assumes a sandbox entryPoint with card, ACH, and Tap to Pay enabled. Contact your Payabli representative if your sandbox paypoint doesn’t have these enabled yet.
Related resources
See these related resources to help you get the most out of Payabli.
Prerequisites
- Mobile components overview - Learn how Payabli’s native mobile SDK components let you accept payments in your mobile app