Call startTransaction() after a successful device connection to initiate a card-present payment. The amount must be expressed in cents using the Currency type.
Function signature
finixClient.startTransaction(
amount: Currency,
type: TransactionType,
splitTransfers: [SplitTransfer]? = nil,
tags: ResourceTags? = nil,
buyerIdentityId: String? = nil,
surchargeAmount: Int? = nil,
tipAmount: Int? = nil,
signaturePending: Bool? = nil
) { (transferResponse: TransferResponse?, error: Error?) in
// handle result
}| Parameter | Type | Required | Description |
|---|---|---|---|
amount | Currency | Yes | Transaction amount. Use Currency(amount: Int, code: .USD) where amount is in cents (e.g., 1000 for $10.00). |
type | TransactionType | Yes | Type of transaction. Supported values: .SALE, .AUTHORIZATION, .REFUND. |
splitTransfers | [SplitTransfer]? | No | Split the transaction across multiple merchants. Requires ROLE_PARTNER credentials. |
tags | ResourceTags? | No | Custom key-value metadata attached to the transaction. |
buyerIdentityId | String? | No | Finix Identity ID of the buyer. |
surchargeAmount | Int? | No | Optional surcharge amount in cents. The SDK passes this value through as-is — surcharge logic must be handled by your application. |
tipAmount | Int? | No | Optional tip amount in cents. The SDK passes this value through as-is — tip logic must be handled by your application. |
signaturePending | Bool? | No | Set to true if a signature will be captured and submitted via /signature_uploads for this transfer. |
Currency
Construct a Currency value with the amount in cents and the ISO currency code.
Currency(amount: Int, code: CurrencyCode)| Parameter | Description |
|---|---|
amount | Integer amount in the smallest currency unit (cents for USD). For example, 1000 represents $10.00. |
code | ISO currency code. Use .USD for US dollars. |
Completion handler
The completion closure receives a TransferResponse on success or an Error on failure. Always dispatch UI updates back to the main actor.
| Parameter | Trigger |
|---|---|
transferResponse | Transaction approved. Contains the transfer and authorization details. |
error | Transaction declined or failed. Check error.localizedDescription for details. |
let amount = Currency(amount: 1000, code: .USD) // $10.00
finixClient.startTransaction(amount: amount, type: .SALE) { response, error in
Task { @MainActor in
// handle response and error
}
}
let amount = Currency(amount: 1000, code: .USD) // $10.00
// Convert from a decimal string (e.g., "10.00")
if let amountDouble = Double("10.00") {
let amount = Currency(amount: Int(amountDouble * 100), code: .USD)
}
let amount = Currency(amount: 1000, code: .USD)
finixClient.startTransaction(amount: amount, type: .SALE) { response, error in
Task { @MainActor in
if let error = error {
// transaction declined or failed
print("Error: \(error.localizedDescription)")
return
}
if let response = response {
// transaction approved — response contains transfer details
print("Transfer ID: \(response.id ?? "")")
}
}
}