Making a payment

Basic usage

The following example demonstrates the basic usage of the YocoSDK.charge method.

1import YocoSDK
2
3YocoSDK.charge(1000)
The charge amount must be a positive integer, specified in cents.

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.

1import YocoSDK
2
3var tippingSetting: TippingConfig = TippingConfig.DO_NOT_ASK_FOR_TIP
4let receiptNumber = UUID().uuidString
5
6let parameters = PaymentParameters(
7 receiptDelegate: self,
8 userInfo: [
9 "user": "info"
10 ],
11 staffMember: YocoStaff(staffNumber: "1234", name: "Joe Bloggs"),
12 receiptNumber: receiptNumber,
13 note: "test note",
14 transactionCompleteNotifier: { paymentResult in
15 // Do something once the payment is complete
16 })
17
18let transactionID = YocoSDK.charge(
19 1000,
20 paymentType: .card,
21 currency: .zar,
22 tippingConfig: tippingSetting,
23 paymentParameters: parameters,
24 printParameters: nil
25) { paymentResult in
26 // Do something once the Yoco SDK dismisses
27}

Supported PaymentType values

Here is a list of the currently supported payment methods:

MethodSwift
Card (default)PaymentType.card
CashPaymentType.cash

The cash payment type will show the receipt screen and will not go through any payment process.

Supported TippingConfig values

ConfigurationSwift value
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:)

Supported Currencies

Here is a list of the currently supported currencies:

CurrencySwift value
South African Rand (default)SupportedCurrency.zar