purchase

abstract suspend fun purchase(amount: String, customMetaData: Map<String, String> = emptyMap(), timeOut: Int? = null, currency: Currency, type: PaymentType): Flow<PurchaseResult<SdkSuccessAnswer.Purchase>>

Initiates a purchase transaction with the specified amount, currency and payment type.

When type is PaymentType.QR or PaymentType.CARD_AND_QR, the terminal creates a QR order and the flow additionally emits PurchaseResult.QrOrderCreated containing the QR image (Base64 PNG) and order details to render to the buyer. QR payment requires an authorized external QR candidate. The final PurchaseResult.Success carries SdkSuccessAnswer.Purchase with a non-null SdkSuccessAnswer.Purchase.qrReceipt when the purchase was paid via QR.

Return

Flow emitting a PurchaseResult with SdkSuccessAnswer.Purchase with receipt, QR receipt and metadata details if successful, or a PurchaseResult.Error if the operation fails.

Additionally, the flow can emit intermediate states: - PurchaseResult.InitOperation: Indicates the terminal is being configured. - PurchaseResult.ReaderReady: Indicates the terminal is ready and waiting for the card. - PurchaseResult.Processing: Indicates the transaction is being processed. - PurchaseResult.QrOrderCreated: Indicates a QR order was created; carries the QR image and order details.

In CommunicationType.INTENT mode the QR code is rendered by the POS application itself: PurchaseResult.QrOrderCreated is not emitted. The purchase parameters travel as intent extras (amount, customMetaData, timeOut, currency — ISO 4217 code, paymentType).

Parameters

amount

The amount of the purchase, in kopecks. For example, 100 == 1 ruble.

customMetaData

A map of key-value pairs containing additional info for the transaction. This metadata is stored along with the transaction and can be used later for searching, filtering.

timeOut

Card wait timeout in seconds. null uses the POS default (60 seconds).

currency

The transaction currency, e.g. Currency.RussianRouble.

type

The payment type: card only, QR only, or both (see PaymentType).


abstract suspend fun purchase(amount: String, customMetaData: Map<String, String> = emptyMap(), timeOut: Int? = null): Flow<PurchaseResult<SdkSuccessAnswer.Purchase>>

Deprecated

Use the purchase overload with currency and payment type

Replace with

purchase(amount, customMetaData, timeOut, Currency.RussianRouble, PaymentType.CARD)

Initiates a purchase transaction with the specified amount.

Behaves like purchase called with Currency.RussianRouble and PaymentType.CARD: a card-only transaction, no QR order is created.

Return

Flow emitting a PurchaseResult with SdkSuccessAnswer.Purchase with invoice and receipt details if successful, or a PurchaseResult.Error if the operation fails.

Additionally, the flow can emit intermediate states: - PurchaseResult.InitOperation: Indicates the terminal is being configured. - PurchaseResult.ReaderReady: Indicates the terminal is ready and waiting for the card. - PurchaseResult.Processing: Indicates the transaction is being processed.

Note: These intermediate states will only be emitted when the communication type is set to CommunicationType.AIDL.

Parameters

amount

The amount of the purchase, in kopecks. For example, 100 == 1 ruble.

customMetaData

A map of key-value pairs containing additional info for the transaction. This metadata is stored along with the transaction and can be used later for searching, filtering.

timeOut

Card wait timeout in seconds. null uses the POS default (60 seconds).