Skip to content
Last updated

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().

@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

activityComponentActivityrequired

The Android Activity

transactionRequestTransactionRequestrequired

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.

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

Parameters

typeTransactionTyperequired

The type of transaction

Enum"PURCHASE""REFUND"
amountInCentsIntrequired

The amount in cents.

referenceStringrequired

The identifier for the transaction and MUST be unique.

posInfoPosInfo

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