iOS

Integrate Leatherback's payment gateway into your iOS app.

🧪

To run the example project, clone the repo, run pod install from the Example directory, and input your Leatherback public key to test.

Requirements

  • Xcode 11.0 or greater
  • iOS 10 or greater

Installation

Add the following line to your Podfile:

pod 'LAAS'

Then run:

pod install

Usage

Step 1: Import the SDK

import LAAS

Step 2: Configure the Checkout

Create a LeatherBackTransactionParam with your payment details and present the LeatherBackViewController.

Set showPersonalInformation to true to let Leatherback collect the customer's name and email during checkout:

let param = LeatherBackTransactionParam(
    amount: 1.50,
    currencyCode: .GBP,
    channels: [.Card, .Account],
    showPersonalInformation: true,
    reference: "your unique reference number",
    key: "your public key",
    isProducEnv: false
)

let paymentVC = LeatherBackViewController(delegate: self, param: param)
present(paymentVC, animated: true)

Step 3: Handle Transaction Events

Conform your presenting view controller to the LeatherBackDelegate protocol to receive payment results:

class ViewController: UIViewController, LeatherBackDelegate {

    func onLeatherBackError(error: LeatherBackErrorResponse) {
        // Handle payment error
        print("error \(error.localizedDescription)")
    }

    func onLeatherBackSuccess(response: LeatherBackResponse) {
        // Use this reference to verify payment/transaction with Leatherback
        print("success \(response.reference)")
    }

    func onLeatherBackDimissal() {
        // Customer closed the payment gateway manually
        print("dismissed")
    }
}
Delegate MethodWhen It's Called
onLeatherBackSuccess(response:)Transaction completed successfully. Use response.reference to verify the payment.
onLeatherBackError(error:)Transaction failed. Inspect error.localizedDescription for details.
onLeatherBackDimissal()Customer closed the payment gateway without completing the transaction.

Configuration Reference

LeatherBackTransactionParam

ParameterTypeRequiredDefaultDescription
amountDoubleYesThe amount to charge the customer
currencyCodeCurrencyYesCurrency code (e.g., .NGN, .GBP)
keyStringYesYour Leatherback public key
showPersonalInformationBoolYestrue: Leatherback collects customer name and email at checkout. false: you must provide customerName and customerEmail.
isProducEnvBoolYestrue: use your production key. false: use your test key.
channels[PaymentChannels]NoAll channelsPayment channels to display. Set to nil to show all available options.
referenceStringNonilYour unique transaction reference. If empty, defaults to nil — the onLeatherBackSuccess delegate will return a generated reference.
customerEmailStringNonilCustomer's email address. Required when showPersonalInformation is false.
customerNameStringNonilCustomer's full name. Required when showPersonalInformation is false.
⚠️

When showPersonalInformation is set to false, you must provide both customerName and customerEmail. Omitting them will result in an incomplete checkout.


Available Currencies and Channels

CurrencyConstantAvailable Channels
NGN.NGN.Card, .Account
GBP.GBP.Card, .Account

Show all channels for a currency

Set channels to nil to automatically display all available payment options:

let param = LeatherBackTransactionParam(
    amount: 20.00,
    currencyCode: .GBP,
    channels: nil,  // Shows all available channels for GBP
    showPersonalInformation: true,
    key: "your public key",
    isProducEnv: false
)

Restrict to specific channels

Pass only the channels you want to offer:

let param = LeatherBackTransactionParam(
    amount: 20.00,
    currencyCode: .NGN,
    channels: [.Card],  // Only show card payments
    showPersonalInformation: true,
    key: "your public key",
    isProducEnv: false
)