TransactionRequest

class TransactionRequest @JvmOverloads constructor(val amount: Amount, val type: TransactionType = TransactionType.PURCHASE, val cashbackAmount: Amount? = null, val pan: String? = null, val expiryDate: String? = null, val cvc2: String? = null, val salesId: String? = null, val transactionId: String = UUID.randomUUID().toString())

Payment request passed to Terminal.startTransaction or Terminal.startTransactionAsync. Use the factory for the payment type, such as purchase or purchaseWithCashback. The constructor enforces the same rules as the builders. Reversals use ReversalRequest.

Constructors

Link copied to clipboard
constructor(amount: Amount, type: TransactionType = TransactionType.PURCHASE, cashbackAmount: Amount? = null, pan: String? = null, expiryDate: String? = null, cvc2: String? = null, salesId: String? = null, transactionId: String = UUID.randomUUID().toString())

Types

Link copied to clipboard

Base builder shared by every transaction-type-specific builder below (PurchaseBuilder, PurchaseWithCashbackBuilder, LoadBuilder, FundingBuilder, ForcedAcceptanceBuilder, CashAdvanceBuilder, CreditBuilder). Each subclass fixes TransactionRequest.type to the one it was created for and only exposes the fields that apply to that type - for example only PurchaseWithCashbackBuilder exposes cashbackAmount(...), since that field is meaningless for every other TransactionType. There is intentionally no generic builder that lets a caller pick an arbitrary type and then guess which other fields apply to it.

Link copied to clipboard
Link copied to clipboard
object Companion
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Builds a standard TransactionType.PURCHASE request - the default for every existing call site.

Link copied to clipboard

Builds a TransactionType.PURCHASE_WITH_CASHBACK request. cashbackAmount(...) must be called - unlike amount, there is no reasonable default for it, and the whole point of this transaction type is to carry one.

Properties

Link copied to clipboard

Amount to charge.

Link copied to clipboard
val cashbackAmount: Amount? = null

Cashback included in amount. Required for TransactionType.PURCHASE_WITH_CASHBACK, null for every other payment type. Must use the total's currency and not exceed the total.

Link copied to clipboard
val cvc2: String? = null

Card verification code for pan (EP2 <Card Verification Code 2>). Optional and only meaningful together with pan/expiryDate - non-PCI brands only.

Link copied to clipboard
val expiryDate: String? = null

Card expiry date for pan, EMV format YYMM (EP2 <Application Expiration Date>). Required together with pan.

Link copied to clipboard
val pan: String? = null

Card PAN for manual PAN key entry ("MPKE", EP2 <Application Primary Account Number (PAN)>), typed in by the cashier instead of read from the physical card. null for the normal case where the terminal reads the card. Required together with expiryDate.

Link copied to clipboard
val salesId: String? = null

Tags which "sale" this transaction belongs to (1..n transactions can share a salesId, e.g. split tender) - only meaningful for TransactionType.PURCHASE, TransactionType.CASH_ADVANCE or TransactionType.FUNDING. Use a POS-generated UUID.

Link copied to clipboard

Application-generated id used for recovery via Terminal.fetchTransactionStatus/Terminal.resume. Defaults to a random UUID; set explicitly to control it, for example to persist it before starting the transaction (see "Payment recovery" in the README).

Link copied to clipboard

Kind of transaction to start. Defaults to TransactionType.PURCHASE.

Functions

Link copied to clipboard
open override fun toString(): String

Masks pan/cvc2 so logging a TransactionRequest never leaks sensitive card data.