Start Transaction

tapToPaySdk.startTransaction(activity, transactionRequest)

Create a TransactionRequest and invoke tapToPaySdk.startTransaction() to start a payment or refund. Transaction results will be received in the onTransactionResult callback passed to tapToPaySdk.registerTransactionResultHandler().

Copy
Copied
@Throws(InvalidTransactionParamException::class)
fun startTransaction(
    activity: ComponentActivity,
    transactionRequest: TransactionRequest
)

Throws InvalidTransactionParamException Exception

It is strongly recommended to handle any exceptions thrown by tapToPaySdk.startTransaction() otherwise your App will crash. Throws InvalidTransactionParamException when one of the following conditions is not met.

  • amountInCents must be positive and non zero
  • amountInCents must be less than 10,000,000 ($100,000.00)
  • reference must not be blank

Parameters

activity
required
ComponentActivity

The Android Activity

transactionRequest
required
TransactionRequest

The request parameters for the transaction.

TransactionRequest

Request parameters for the transaction. This determines if the transaction is a purchase or refund. PosInfo must be set via sdk.setPosInfo(posInfo) or in this function otherwise an error will be thrown. See PosInfo.

Copy
Copied
@Parcelize
data class TransactionRequest(
    val type: TransactionType,
    val amountInCents: Int,
    val reference: String,
    var posInfo: PosInfo? = null,
) : Parcelable

Parameters

type
required
TransactionType

The type of transaction

Enum: "PURCHASE" "REFUND"
amountInCents
required
Int

The amount in cents.

reference
required
String

The identifier for the transaction and MUST be unique.

posInfo
PosInfo

Optionally provide the PosInfo per transaction. PosInfo must be provided via this parameter or in sdk.setPosInfo() otherwise an error will be thrown.

Copyright © Tyro Payments 2019-2024. All right reserved.