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. tippingConfig: TippingConfig - (Optional) Setting to determine if the SDK should ask for tip (Default DO_NOT_ASK_FOR_TIP)
  6. printerConfig: PrinterConfig - Not set by integrators, set to null
  7. 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. staffMember: YocoStaff? - (Optional) Yoco Staff member performing payment
    4. note: String - (Optional) Additional note to attach to this transaction
    5. billId: String - (Optional) Unique idenitifer of a bill to attach this transaction to
    6. receiptNumber: String? - (Optional) a pre-set identifier that can be used to lookup this transaction later
    7. transactionCompleteNotifier: ((resultCode: Int, result: PaymentResult) -> Unit)? - (Optional) transaction completion handler
  8. 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
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

Supported TippingConfigs

Tipping ConfigurationValue
Do not ask for tipTippingConfig.DO_NOT_ASK_FOR_TIP
Ask for tip on readerTippingConfig.ASK_FOR_TIP_ON_CARD_MACHINE
Include amount as tip(programmatically)TippingConfig.INCLUDE_TIP_IN_AMOUNT(tipInCents:)