Making a Payment

info

When calling YocoSDK.charge() without passing in a ActivityResultLauncher and handling the PaymentResult in onActivityResult, it will be assigned the PaymentResultInfo.RequestCode.CHARGE_REQUEST code

Parameters

  1. context: Context - The calling Activity/Fragment initiating the payment
  2. amountInCents: Long - Amount to be charged in cents
  3. paymentType: PaymentType - Payment type (Default: CARD)
  4. currency: SupportedCurrency - Currency that is associated with payment (Default: ZAR)
  5. askForTip: Boolean - (Optional) Flag to determine if the SDK should ask for tip
  6. params: PaymentParameters - (Optional) Provides additional info regarding the payment
    1. receiptDelegate: ReceiptDelegate? - (Optional) Receipt screen callback handler and util
    2. userInfo: Map<String, Any>? - (Optional) Map of key-value pairs, providing additional info regarding the user which will be returned to the PaymentResult
    3. metaData: Map<String, String>? - (Optional) Map of key-value pairs, providing additional info that will be passed on to the OnoSDK
    4. staffMember: YocoStaff? - (Optional) Yoco Staff member performing payment
    5. transactionId: String? - (Optional) a pre-set transactionId to use for the current transaction
    6. transactionCompleteNotifier: ((resultCode: Int, result: PaymentResult) -> Unit)? - (Optional) transaction completion handler
  7. result: ActivityResultLauncher<Intent>? - (Optional) activity result handler contract to handle intent result
danger

The context that is passed as a parameter MUST be calling activity/fragment's context and NOT the application context.

Supported Payment Types

Here is a list of supported payment types:

Payment TypeValue
Card (default)PaymentType.CARD
CashPaymentType.CASH
QRPaymentType.QR
info

The CASH payment type will always assume a successful payment and thus will complete the payment but can provide a way to handle the receipt

Supported Currencies

Here is a list of supported currencies:

CurrencyValue
South African Rand (ZAR) (default)SupportedCurrency.ZAR
Mauritian Rupee (MUR)SupportedCurrency.MUR