Yoco
public enum Yoco
The main interface for the YocoSDK.
-
Undocumented
Declaration
Swift
public static func setCleanUpCallback(callback: (() -> Void)?)
-
Initialise the YocoSDK.
This function should be called at app start or before calling any other function of the SDK.
Note
Do not call this function multiple times.Declaration
Swift
public static func initialise()
-
Configure the YocoSDK with your secret and for the environment to run in.
You may call this function multiple times to dynamically change configurations.
- secret: Your secret that must be acquired from Yoco.
- loggingEnabled: Enables or disables extra debug logs from the YocoSDK to print to the console.
- environment: Sets the environment to use,
.production
is the default environment. - locale: String representing the locale to be used for displaying the transaction and printing flow in the SDK.
Declaration
Swift
public static func configure(secret: String, loggingEnabled: Bool = false, environment: Environment = .production, locale: String? = nil)
-
Configure the YocoSDK with your secret and for the environment to run in.
You may call this function multiple times to dynamically change configurations.
- secret: Your Integrator secret that must be acquired from Yoco.
- apiToken: Your Integration Token that must be acquired from Yoco..
- loggingEnabled: Enables or disables extra debug logs from the YocoSDK to print to the console.
- environment: Sets the environment to use,
.production
is the default environment. - locale: String representing the locale to be used for displaying the transaction and printing flow in the SDK.
Declaration
Swift
public static func configure(secret: String, apiToken: String, loggingEnabled: Bool = false, environment: Environment = .production, locale: String? = nil)
-
charge(_:
paymentType: currency: tippingConfig: paymentParameters: printParameters: rootViewController: completionHandler: ) Charge a customer an amount in cents. The default currency is ZAR. The default payment type is by card.
It is recommended to hold onto the transactionID that is returned. This can be used to query the state of a previous transaction if the app unexpectedly closed during the processing of a transaction. Calling this function before a previous transaction has ended can result in unintended behaviour.
- cents: The amount in cents you want to charge the customer.
- paymentType: The payment method which the customer is using to pay.
- currency: The currency to charge the customer, must be one of the supported currency types.
- tippingConfig: Provide configuration for tipping. Possible options: Do not ask, ask on machine, or provide a numerical value for tip in cents
- rootViewController: If you need us to present onto a specific view controller, for example if the root view controller of your app is already presenting another view controller
completionHandler: The function that will be called at the end of a payment with the payment result.
Declaration
Swift
@discardableResult public static func charge(_ cents: UInt64, paymentType: YocoPaymentType = .card, currency: SupportedCurrency = .zar, tippingConfig: TippingConfig = TippingConfig.DO_NOT_ASK_FOR_TIP, paymentParameters: PaymentParameters? = nil, printParameters: PrintParameters? = nil, rootViewController: UIViewController? = nil, completionHandler: YocoCompletionHandler<PaymentResult>? = nil) -> String
Return Value
transactionID
-
Allow the user to go through the pairing flow without needing to start a transaction.
- rootViewController: If you need us to present onto a specific view controller, for example if the root view controller of your app is already presenting another view controller
Declaration
Swift
public static func pairTerminal(rootViewController: UIViewController? = nil, userInfo: [AnyHashable: Any]? = nil, completionHandler: YocoCompletionHandler<[String: Any]?>? = nil)
-
Undocumented
Declaration
Swift
public static func unpairTerminal(userInfo: [AnyHashable: Any]? = nil)
-
Refund a customer a previously completed transaction.
- transactionID: The unique identifier that was associated with the transaction, returned by
Yoco.charge(_:paymentType:currency:parameters:completionHandler:)
. - rootViewController: If you need us to present onto a specific view controller, for example if the root view controller of your app is already presenting another view controller
- completionHandler: The function that will be called at the end of a refund with the payment result.
Declaration
Swift
public static func refund(transactionID: String, refundParameters: RefundParameters? = nil, printParameters: PrintParameters? = nil, rootViewController: UIViewController? = nil, completionHandler: YocoCompletionHandler<PaymentResult>? = nil)
- transactionID: The unique identifier that was associated with the transaction, returned by
-
Logs out the current user. This will cause the user to have to log in again on their next call of
Yoco.charge(_:paymentType:currency:parameters:completionHandler:)
.Declaration
Swift
public static func logout()
-
Get the result of the transaction specified. Useful to check what happened to a transaction in the case of an app crash or something unexpected.
- transactionID: The ID of the transaction you want to get the result for.
- completionHandler: The callback function to be notified of when it has been fetched.
Declaration
Swift
public static func getPaymentResult(transactionID: String, completionHandler: @escaping (PaymentResult?, Swift.Error?) -> Void)
-
Lookup transactions by receiptNumber provided as optional property of
PaymentParameters
when creating chargeDeclaration
Swift
public static func getIntegratorTransactions(receiptNumber: String, completionHandler: @escaping ([PaymentResult]?, Swift.Error?) -> Void)
-
Checks wether the SDK is fully authenticated
Declaration
Swift
public static func isLoggedIn() -> Bool
-
Declaration
Swift
public static func showPaymentResult(_ paymentResult: PaymentResult, paymentParameters: PaymentParameters? = nil, printParameters: PrintParameters? = nil, rootViewController: UIViewController? = nil, completionHandler: YocoCompletionHandler<PaymentResult>? = nil)
-
Call this method inside
applicationWillTerminate(_ application: UIApplication)
in yourAppDelegate
so that the YocoSDK can do any cleanup it needs to when the application is unexpectedly terminated.Declaration
Swift
public static func applicationWillTerminate()
-
- Prints receipt and returns a result
- @param printParameters [PrintParameters] request containing configuration and data for executing print
- @param completionHandler [(PrintResult?) -> Void] completion handler invoked with print results
Declaration
Swift
public static func printReceipt(printParameters: PrintParameters, receiptInfo: ReceiptInfo, completionHandler: @escaping (PrintResult?) -> Void)
-
Undocumented
Declaration
Swift
public static func isPrinterAvailable(isPrinterAvailableCallback: @escaping (Bool, String?) -> Void)
-
Undocumented
Declaration
Swift
public static func setPrinterConfig(printerConfig: PrinterConfig)
-
Executes the print flow
@param printRequest - additional info in a config for print configuration @param completionHandler - [(PrintResult?) -> Void] to handle result returned
Declaration
Swift
public static func print(rootViewController: UIViewController? = nil, printParameters: PrintParameters, completionHandler: YocoCompletionHandler<PrintResult>?)
-
Undocumented
Declaration
Swift
public static func setFeatureUpdatingStrategy(_ strategy: FeatureUpdateStrategy)