Making a payment
Basic usage
The amount that gets charged is in cents and must be a positive integer.
import YocoSDK
Yoco.charge(1000)
Advanced usage
This example shows you some of the extra functionality you can add to your use of the SDK by adding a PaymentParameters
object to the charge function call.
import YocoSDK
var tippingSetting: TippingConfig = TippingConfig.DO_NOT_ASK_FOR_TIP
let receiptNumber = UUID().uuidString
let parameters = PaymentParameters(receiptDelegate: self,
userInfo: [
"user" : "info"
],
staffMember: YocoStaff(staffNumber: "1234", name: "Joe Bloggs"),
receiptNumber: receiptNumber,
note: "test note",
transactionCompleteNotifier: { paymentResult in
// Do something once the payment is complete
}))
let transactionID = Yoco.charge(1000,
paymentType: .card,
currency: .zar,
tippingConfig: tippingSetting,
parameters: parameters) { paymentResult in
// Do something once the Yoco SDK dismisses
}
Supported Payment Types
Here is a list of the currently supported payment methods:
Method | Swift |
---|---|
Card (default) | PaymentType.card |
Cash | PaymentType.cash |
note
The cash payment type will show the receipt screen and will not go through any payment process, it is up to you to handle the receipt.
Supported TippingConfigs
Configuration | Swift |
---|---|
Do not ask for tip | TippingConfig.DO_NOT_ASK_FOR_TIP |
Ask for tip on reader | TippingConfig.ASK_FOR_TIP_ON_CARD_MACHINE |
Include amount as tip(programmatically) | TippingConfig.INCLUDE_TIP_IN_AMOUNT(tipInCents:) |
Supported Currencies
Here is a list of the currently supported currencies:
Currency | Swift |
---|---|
South African Rand (default) | SupportedCurrency.zar |