Judopay's Swift SDK for a simple, quick, and secure integration of in-app payments.
Swift Other
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
DeviceDNA @ adc77d2
TrustKit @ 25e3c04


CocoaPods Compatible Carthage Compatible License Platform Twitter

Judo Swift SDK for iOS

The judo Swift SDK is a framework for integrating easy, fast and secure payments inside your app with judo. It contains an exhaustive in-app payments and security toolkit that makes integration simple and quick. If you are integrating your app in Objective-C, we highly recommend you to use the judoKitObjC port.

Use our UI components for a seamless user experience for card data capture. Minimise your PCI scope with a UI that can be themed or customised to match the look and feel of your app.


Version 7.0.0+ requires Xcode 9 and Swift 4.

Version 6.2.5+ requires Xcode 8 and Swift 3.

Version 6.2.4 is the last version to support Xcode 7.3.1 and Swift 2.2.

Getting started

1. Integration

If your integration is based on Carthage, then visit our GitHub Wiki.

If you are integrating the SDK manually then follow the guide here:

If you are integrating using CocoaPods, follow the steps below.

  • You can install CocoaPods using Homebrew or with the following command:
$ gem install cocoapods
  • Add judo to your Podfile to integrate it into your Xcode project:
platform :ios, '9.0'

pod 'JudoKit', '~> 7.1'
  • Then run the following command:
$ pod install
  • Please make sure to always use the newly generated .xcworkspace file not not the projects .xcodeproj file.

  • In your Xcode environment, go to your Project Navigator (blue project icon) called Pods, select the JudoKit target and open the tab called Build Phases.

  • Add a new Run Script Phase and drag it above the Compile Sources build phase.

  • In the shell script, paste the following line:

sh "${PODS_ROOT}/DeviceDNA/Framework/strip-frameworks-cocoapods.sh"

2. Setup

Add import JudoKit to the top of the file where you want to use the SDK.

You need to set your token and secret when initializing JudoKit:

// initialize the SDK by setting it up with a token and a secret
var judoKit = JudoKit(token: "<TOKEN>", secret: "<SECRET>")

To instruct the SDK to communicate with the Sandbox environment, include the following lines in the ViewController where the payment should be initiated:

// setting the SDK to Sandbox Mode - once this is set, the SDK wil stay in Sandbox mode until the process is killed

When you are ready to go live you can remove this line.

3. Make a payment

func paymentOperation() {
    guard let ref = Reference(consumerRef: "<CONSUMER_REFERENCE>") else { return }
    try! judoKit.invokePayment(judoId, amount: Amount(decimalNumber: 0.01, currency: currentCurrency), reference: ref, completion: { (response, error) in
        self.dismiss(animated: true, completion: nil)
        if let error = error {
            if error.code == .userDidCancel {
                self.dismiss(animated: true, completion: nil)
            var errorTitle = "Error"
            if let errorCategory = error.category {
                errorTitle = errorCategory.stringValue()
            self.alertController = UIAlertController(title: errorTitle, message: error.message, preferredStyle: .alert)
            self.alertController!.addAction(UIAlertAction(title: "OK", style: .cancel, handler: nil))
            self.dismiss(animated: true, completion:nil)
        if let resp = response, let receipt = resp.items.first {
            self.cardDetails = receipt.cardDetails
            self.paymentToken = receipt.paymentToken()
        let sb = UIStoryboard(name: "Main", bundle: nil)
        let viewController = sb.instantiateViewController(withIdentifier: "detailviewcontroller") as! DetailViewController
        viewController.response = response
        self.navigationController?.pushViewController(viewController, animated: true)

Note: Please make sure that you are using a unique Consumer Reference for each different consumer.

Next steps

Judo's Swift SDK supports a range of customization options. For more information on using judo for iOS see our wiki documentation or API reference.