Charge Integrator

Usage

To initiate a payment you will need to call the SDK charge() method. This can only be done once the SDK has been initialised and authorised.

import com.yoco.payments.sdk.YocoSDK
import com.yoco.payments.sdk.data.YocoStaff
import com.yoco.payments.sdk.data.params.PaymentParameters
import com.yoco.payments.sdk.data.enums.PaymentType
import com.yoco.payments.sdk.data.enums.SupportedCurrency
// Required: Amount in cents
val amount = amountStr.toLong() * 100
// Optional: Additional user info
val userInfo = HashMap<String, Any>().apply {
this["UserId"] = "test01"
this["Title"] = "Manager"
}
// Optional: Additional meta data info
val metaData = HashMap<String, String>().apply {
this["meta"] = "data"
}
// Optional: Params containing additional for advanced functionality
val params = PaymentParameters(
receiptDelegate = DefaultReceiptDelegate(),
userInfo = userInfo,
metaData = metaData,
staffMember = YocoStaff(name = "John", staffNumber = "007"),
note = "test note",
billId = "test-bill-id",
transactionCompleteNotifier = { _: Int, _: PaymentResult ->
// Do something once the payment is complete
},
receiptNumber = UUID.randomUUID().toString()
)
// Initiating the payment
YocoSDK.charge(
// required parameters
context = context,
amountInCents = amount,
paymentType = PaymentType.CARD,
currency = SupportedCurrency.ZAR,
// optional: parameters
tippingConfig = this.tippingConfig, //defaults to TippingConfig.DO_NOT_ASK_FOR_TIP
printerConfig = this.printerConfig,
params = params
)
note

If no user has logged in, you WILL be prompted to login using your Yoco account details. If successful, it will continue to the payment flow.

Handling Payment Result