Charge Integrator

Usage

To initiate a payment you will just need to call the SDK charge() method. This can only be done once the user has logged in to the SDK.

import com.yoco.payment_ui_sdk.YocoSDK
import com.yoco.payment_ui_sdk.data.YocoStaff
import com.yoco.payment_ui_sdk.data.params.PaymentParameters
import com.yoco.payment_ui_sdk.data.enums.PaymentType
import com.yoco.payment_ui_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 = this,
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 Receipts

Handling Payment Result