Preauth

A preauthorization places a hold on the cardholder's funds without capturing. Use it when the final amount may change (e.g., tips, adjustments, custom surcharging).

Prerequisites

  • Authenticated merchant with login()
  • Active location selected in app settings via setActiveLocationID() (iOS) or setActiveLocation() (Android)
  • Account linking and reader preparation completed on iOS, or location selection, enrollment, and reader preparation completed on Android

Persist eventId before submission. Create Android payment flows on Dispatchers.IO, apply flowOn(Dispatchers.IO), and collect from a Main/UI coroutine. Handle the full reader event flow described in the Android guide.

Use the handleTransactionEvent implementation in Android Running Payments. It handles progress, failure, pending or partial results, surcharge confirmation, and final approval or decline. The UI callbacks run on the main dispatcher.

Basic Preauth

iOS:

let breakdown = PaymentBreakdown(
    subtotal: 10000,
    taxRate: 8.75,
    taxAmount: 875,
    tipType: .fixed
)

let currency = CurrencyCode(currencyCode: "USD", displayName: "US Dollar")

let response = try await KoardMerchantSDK.shared.preauth(
    amount: 10875,
    breakdown: breakdown,
    currency: currency,
    eventId: eventId
)
try handleTransactionResponse(response) // Handler in iOS Running Payments

Android:

val breakdown = PaymentBreakdown(
    subtotal = 10000,
    taxRate = 8.75,
    taxAmount = 875,
    tipType = "fixed"
)

val flow = withContext(Dispatchers.IO) {
    sdk.preauth(
        activity = activity,
        amount = 10875,
        breakdown = breakdown,
        eventId = eventId
    )
}.flowOn(Dispatchers.IO)
flow.collect { event -> handleTransactionEvent(event) }

Preauth with Surcharge Bypass

To calculate surcharges yourself (e.g., BIN-based logic), bypass the processor's automatic surcharge:

iOS:

let breakdown = PaymentBreakdown(
    subtotal: 10000,
    taxRate: 8.75,
    taxAmount: 875,
    tipAmount: 2000,
    tipType: .fixed,
    surcharge: PaymentBreakdown.Surcharge(bypass: true)
)

let response = try await KoardMerchantSDK.shared.preauth(
    amount: 12875,       // subtotal + tax + tip (no surcharge yet)
    breakdown: breakdown,
    currency: currency,
    eventId: eventId
)

Android:

val breakdown = PaymentBreakdown(
    subtotal = 10000,
    taxRate = 8.75,
    taxAmount = 875,
    tipAmount = 2000,
    tipType = "fixed",
    surcharge = Surcharge(bypass = true)
)

val flow = withContext(Dispatchers.IO) {
    sdk.preauth(
        activity = activity,
        amount = 12875,
        breakdown = breakdown,
        eventId = eventId
    )
}.flowOn(Dispatchers.IO)
flow.collect { event -> handleTransactionEvent(event) }

After the preauth is authorized, use the returned card type and your configured eligibility rules to calculate any permitted custom surcharge, then apply it via incremental auth. The public response does not expose a BIN. If your approved workflow uses BIN classification, obtain it through that integration. Never apply a surcharge to debit cards. See the custom surcharge workflow for the full flow.

Parameters

Parameter Type Required Description
amount Int Yes Hold amount in minor units (cents)
breakdown PaymentBreakdown? No Itemized breakdown
currency CurrencyCode Yes (iOS) Currency for the transaction
eventId String? No Idempotency key (UUID recommended)
activity Activity Yes (Android) Android activity for NFC access

After Preauth

A preauth hold must be followed by one of:

Action Description
Capture Finalize at the same or lower amount
Incremental Auth Increase the hold (e.g., add surcharge)
Tip Adjust Update the tip before capture
Reverse Void the hold entirely

Result

This operation returns the transaction result. The Transaction Result lists the fields you can read from it.

See Also

  • Sale: One-step authorize + capture
  • Capture: Finalize a preauth
  • Surcharging: Bypass and custom surcharge workflows