iOS
Integrating iOS with Judopay
We are currently working on updating the Swift sample app. See our Sample Apps here.
Prerequisites
- You have set up your Judopay account.
- Sign up for your sandbox account, to receive access to your Judopay dashboard and the sandbox environment.
- Your judoIds and tokens are configured and enabled as appropriate.
- For more information on permissions, see Permissions.
- You have the latest version of the iOS SDK.
For Mobile apps, we recommend using payment session authenticationpayment session authentication.
Integrating via Swift Package Manager (SPM)
- Search for JudoKit-iOS.
- Add JudoKit-iOS to your Package Dependencies.
Integrating via CocoaPods
Step One - To integrate the iOS mobile SDK via CocoaPods:
- Install CocoaPods with the following command: gem install cocoapods
- Via the terminal, navigate to your project's root directory
- Initialize CocoaPods with the following command: pod init
- A podfile is generated in the root directory
Step Two - To add the mobile SDK as a dependency:
- Open the podfile and add the following: pod 'JudoKit-iOS'
- Install the dependency with the following command: pod install
The Pod installation complete! message appears in the terminal.
If the Unable to find a specification error message appears, your CocoaPods repository, which stores a reference to all available pods, needs updating. To update your CocoaPods repository run: $ pod repo update
Ensure you always use the generated .xcworkspace file instead of the .xcodeproj file.
Integrating via Carthage
To integrate the iOS Mobile SDK via Carthage:
- Install Carthage on your machine:
- Using brew (terminal): brew install carthage
- In the root folder of your project, add a new file named Cartfile
- In Cartfile, add all the dependencies you need: For the purpose of this exercise: github "Judopay/JudoKit-iOS"
- In the terminal run the following command: carthage update--use-xcframeworks--platform ios
- Check your root folder has the following:
- Cartfile.resolved (File with all downloaded dependencies, including their versions)
- Carthage folder
- In Xcode, manually drag and drop the JudoKit-iOS xcframework and all the dependent xcframeworks into:
- Linked Frameworks
- Libraries section Frameworks are stored in folder Carthage > Build
- Rebuild the project
- Import the JudoKit-iOS into your project files: #import <JudoKit-iOS/JudoKit_iOS.h>
The iOS Mobile SDK is now ready to use in your iOS project.
Initialising a JudoKit Session
To get started:
To access the JudoKit class, import the JudoKit_iOS framework: #import <JudoKit_iOS/JudoKit_iOS.h>
To initialise a JudoKit session:
The difference between a basic authentication method and a session authentication method is:
- Basic authentications last indefinitely.
- Session authentications are valid for one transaction. This offers a more secure authentication approach.
Merchants operating in specific money movement and financial services categories, as defined by the card schemes must include additional data in the payment sessionpayment session. For more information, see Account Funding Transactions.
- Use either a basic (token:secret) authentication method, or a session (token & session) authentication method.
- Create a basic authentication instance: JPBasicAuthorization *authorization = [JPBasicAuthorization authorizationWithToken:@"token" andSecret:@"secret"]
- Create a payment session authentication instance: JPSessionAuthorization *authorization = [JPSessionAuthorization authorizationWithToken:@"token" andPaymentSession:@"session token"]
To create a JudoKit session: JudoKit *judo = [[JudoKit alloc] initWithAuthorization:authorization];
To communicate with the sandbox environment, enter: judo.isSandboxed = YES;
By default, Judopay allows jailbroken devices to access it's features. If you would like to restrict access to non-jailbroken devices only, use this initializer instead: JudoKit *judo = [[JudoKit alloc]initWithAuthorization:authorization "allowJailbrokenDevices:NO];
Setting the Parameters for a Successful Transaction
Use the JPConfiguration object to set the parameters. The JPConfiguration object is passed as a method parameter and communicates how the payment flow should behave.
To configure the JPConfiguration object, add your:
- JudoId
- JudoId format = 100100100
- Amount
- ConsumerReference
The JPAmount object sets your:
- Transaction amount
- Currency code
The JPReference object sets your reference details, for example your unique consumerReference, to identify your consumer. Now you can use this object to make a transaction.
Making a Transaction
3D Secure 2 is available on Judokit iOS version 3.0.0 or higher, and is available on Github. (Currently supports Visa and Mastercard. Amex coming soon).
Prerequisites
- You have integrated with the Mobile SDK
- You have set up the JPConfiguration instance with all the required properties
Card validation | Card formatting | Type | Detection | is handled by Judopay.
The available transaction types that can be passed as a parameter are:
- Payment
- PreAuth
- Check Card
- Save Card
For more details, see our Transaction API Reference documentation.
Once you have completed the prerequisite steps, you are ready to make a transaction. To make a transaction:
- Call the method and handle the response from the completion block:
Name | Type | Description |
|---|---|---|
type | TransactionType | An enum value that sets the transaction type. |
configuration | JPConfiguration | An object that configures the payment flow. |
completion | JPResponse JPError | A completion block that returns the transaction response or an error. |
User Interface
Pre-Built UI Component (Recommended) If you are using the pre-built UI component provided with our SDK, see Using the Pre-Built UI Card Entry Component. To configure the fields displayed in the default card entry UI, see Configuring the UI.
Custom UI Component If you are building your own custom UI component, see Using your own Custom Card Entry UI.
iOS Server to Server Transactions
The SDK also offers server-to-server capabilities. This works by sending the payment token back to the merchant the moment the consumer presses the Pay button. This allows the merchant to process and complete the transaction on their side.
Server-to-server capabilities are available for both transactions made through:
- The Payments Widget
- Apple Pay™
To specify a server-to-server transaction:
//Set the TransactionMode to TransactionModeServerToServer when calling the Judopay methods:
[judo invokePaymentMethodScreenWithMode:TransactionModeServerToServer
configuration:configuration
completion:^(JPResponse *response, JPError *error) {
// Handle the payment token returned from the response
}];
//Specify an Apple Pay™ transaction:
[judo invokeApplePayWithMode:TransactionModeServerToServer
configuration:configuration
completion:^(JPResponse *response, JPError *error) {
// Handle the payment token returned from the response
}];Token Payments and Preauths
If you are building your own card wallet, and not using a UI you can make a /payments or /preauths transaction using a stored card token.
- Follow the steps for Making a Transaction
- To make a token transaction:
//Call the method and handle the response from the completion block:
[judo invokeTokenTransactionWithType:JPTransactionTypePayment
configuration:configuration
details:cardTransactionDetails completion:^(JPResponse *response, JPError *error)
{
// Handle response / error
}];Using the Pre-Built UI Card Entry Component (Recommended)
The easiest way to integrate 3D Secure is to use the pre-built UI component within JudoKit, as this handles the 3D Secure flow for you. Using a 3D Secure Enabled credential, follow the steps for Making a Transaction.
We recommend using billingAddress and emailAddress fields for 3D Secure 2 transactions.
JPAmount *amount = [[JPAmount alloc] initWithAmount:@"1.50" currency:@"GBP"];
JPReference *reference = [[JPReference alloc] initWithConsumerReference:@"consumer-reference" paymentReference:@"payment-reference"];
JPUIConfiguration *uiConfiguration = [JPUIConfiguration new];
// sets whether 3DS 2.0 UI billing information screen should be presented to the user
uiConfiguration.shouldAskForBillingInformation = YES;
// in case you don't want to present billing info screen to the user, you can set the address instead
JPAddress *address = [[JPAddress alloc] initWithAddress1:@"My house"
address2:@"My street"
town:@"My town"
billingCountry:@"826"
postCode:@"TR14 8PA"
countryCode:@826];
JPConfiguration *configuration = [[JPConfiguration alloc] initWithJudoID:@"my-judo-id" amount:amount reference:reference];
configuration.uiConfiguration = uiConfiguration;
configuration.cardAddress = address;
// sets the value for challenge request indicator,
// possible values:
//
// noPreference
// noChallenge
// challengePreferred
// challengeAsMandate
//
configuration.challengeRequestIndicator = @"challengeAsMandate";
// sets the value for SCA exemption,
// possible values:
//
// lowValue
// secureCorporate
// trustedBeneficiary
// transactionRiskAnalysis
//
configuration.scaExemption = @"lowValue";
// email address
configuration.emailAddress = @"[email protected]";
// sets the maximum timeout for 3DS 2.0 transactions in minutes,
// always use 2 characters when setting the timeout
configuration.threeDSTwoMaxTimeout = 30;
// sets phone number country code
configuration.phoneCountryCode = @"44";
// phone number
configuration.mobileNumber = @"11223344556677";Using your own Custom Card Entry UI
You can implement a customisable UI layer, to replace the Pre-Built UI Component provided with Judopay's iOS SDK.
This customisation does not extend to the 3D Secure 2 flow, which remains unchanged and cannot be currently over-ridden.
Prerequisites
From the Integrating iOS with Judopay guide, you have completed the following:
- Set up the JPConfiguration instance with all the required properties.
Setting up your Custom Card Entry UI
Step One:
- Initiate the JPCardTransactionService
JPCardTransactionService *transactionService = [[JPCardTransactionService alloc] initWithAuthorization:self.authorization
isSandboxed:false
andConfiguration:self.configuration];Step Two:
- Initiate a JPCardTransactionDetails object.
- Populate the object with the necessary card details. These are the details you wish to capture in your custom UI layer.
JPCardTransactionDetails *cardTransactionDetails = [JPCardTransactionDetails new];
cardTransactionDetails.cardNumber = @"4976350000006891";
cardTransactionDetails.cardholderName = @"John Smith";
cardTransactionDetails.expiryDate = @"12/30";
cardTransactionDetails.securityCode = @"123";
(...) // Other transaction details (e.g. billing address)Use one of the following methods on the CardTransactionService instance to initiate the following transaction types:
- invokePaymentWithDetails
- invokePreAuthPaymentWithDetails
- invokeCheckCardWithDetails
- invokeSaveCardWithDetails
Processing a Payment
Call the invokePaymentWithDetails method and handle the response from the completion block:
[self.transactionService invokePaymentWithDetails:cardTransactionDetails
andCompletion:^(JPResponse *response, JPError *error) {
// Handle the transaction result (including error case) here.
}];Processing a Pre-Authorisation
Call the invokePreAuthPaymentWithDetails method and handle the response from the completion block:
[self.transactionService invokePreAuthPaymentWithDetails:cardTransactionDetails
andCompletion:^(JPResponse *response, JPError *error) {
// Handle the transaction result (including error case) here.
}];Performing a Check Card Request
Call the invokeCheckCardWithDetails method and handle the response from the completion block:
[self.transactionService invokeCheckCardWithDetails:cardTransactionDetails
andCompletion:^(JPResponse *response, JPError *error) {
// Handle the transaction result (including error case) here.
}];Performing a Save Card Request
Call the invokeSaveCardWithDetails method and handle the response from the completion block:
[self.transactionService invokeSaveCardWithDetails:cardTransactionDetails
andCompletion:^(JPResponse *response, JPError *error) {
// Handle the transaction result (including error case) here.
}];Setting up Recurring Payments
Make sure you are using:
- IOS SDK Version 6.5.0 (or higher)
Integration via React Native Mobile SDK is not currently supported.
Judopay provides support for Apple Pay™ recurring and deferred Merchant Initiated Transactions (MIT)s for Wallet Customer Initiated Transactions (CIT)s.
This feature enables merchants to utilise the Apple Pay™ recurring / deferred payment token, by also being able to use the token for Merchant-Initiated Transactions (MITs).
The Apple Pay™ recurring / deferred payment token is generated by Apple Pay's servers and sent to Judopay, where it is securely stored. In return, you will receive a Judopay token that is linked to the stored Apple Pay™ token. This Judopay token can then be used for future MITs.
Recurring Payments
Make sure you are using iOS version 16.0+ to enable recurring payments. (guard with if #available).
To trigger an initial transaction that allows you to set up an Apple Pay™ recurring payment token for future Merchant Initiated Transactions (MIT):
- Attach the recurring payment configuration object JPRecurringPaymentRequest to your Apple Pay™ configuration:
- Set the isInitialRecurringPayment flag in the Judopay configuration object to true.
- Invoke with the existing invokeApplePay(with:configuration:completion:)
import JudoKit_iOS
let total = JPPaymentSummaryItem(label: "Premium Plan",
amount: NSDecimalNumber(string: "25.00"))
let appleConfig = JPApplePayConfiguration(merchantId: "<APPLE_MERCHANT_ID>",
currency: "GBP",
countryCodse: "GB",
paymentSummaryItems: [total])
if #available(iOS 16.0, *) {
let regularBilling = JPRecurringPaymentSummaryItem(
label: "Premium Plan — monthly",
amount: NSDecimalNumber(string: "25.00"),
intervalUnit: .month,
intervalCount: 1,
startDate: Date(), // first billing date
andEndDate: nil) // nil -> open-ended subscription
let request = JPRecurringPaymentRequest(
paymentDescription: "Premium Plan subscription",
regularBilling: regularBilling,
andManagementURL: URL(string: "https://merchant.example.com/subscriptions")!)
request.billingAgreement = "Subscription auto-renews until cancelled."
appleConfig.recurringPaymentRequest = request
}
let config = JPConfiguration(judoID: "<JUDO_ID>",
amount: JPAmount("25.00", currency: "GBP"),
reference: reference)
config.applePayConfiguration = appleConfig
// First charge taken now, alongside mandate setup:
config.isInitialRecurringPayment = true
judoKit.invokeApplePay(with: .payment, configuration: config) { response, error in
// handle result
}Judopay acts as a pass-through service, whereby we supply the data needed by Apple Pay™ for them to return a device / merchant specific token that can be used for MIT transactions.
For a full description on all the object properties in the Apple Pay™ recurring payments flow, see the Apple Pay™ Documentation.
Deferred Payments
Make sure you are using iOS version 16.4+ to enable deferred payments. (guard with if #available).
To trigger an initial transaction that allows you to set up an Apple Pay™ deferred payment token for future Merchant Initiated Transactions (MIT):
- Attach the deferred payment configuration object JPDeferredPaymentRequest to your Apple Pay™ configuration
- Invoke with the existing invokeApplePay(with:configuration:completion:)
import JudoKit_iOS
let total = JPPaymentSummaryItem(label: "Hotel room reservation",
amount: NSDecimalNumber(string: "200.00"))
let appleConfig = JPApplePayConfiguration(merchantId: "<APPLE_MERCHANT_ID>",
currency: "GBP",
countryCode: "GB",
paymentSummaryItems: [total])
if #available(iOS 16.4, *) {
let deferredBilling = JPDeferredPaymentSummaryItem(
label: "Hotel room reservation",
amount: NSDecimalNumber(string: "200.00"),
deferredDate: Calendar.current.date(from: DateComponents(year: 2027, month: 1, day: 1))!)
let request = JPDeferredPaymentRequest(
paymentDescription: "Hotel room reservation",
deferredBilling: deferredBilling,
andManagementURL: URL(string: "https://merchant.example.com/bookings")!)
request.billingAgreement = "Your card will be charged on the billing date shown."
// Optional: date until which the shopper can cancel for free
request.freeCancellationDate = Calendar.current.date(from: DateComponents(year: 2026, month: 12, day: 25))
request.freeCancellationDateTimeZone = TimeZone(identifier: "Europe/London")
appleConfig.deferredPaymentRequest = request
}
let config = JPConfiguration(judoID: "<JUDO_ID>",
amount: JPAmount("200.00", currency: "GBP"),
reference: reference)
config.applePayConfiguration = appleConfig
judoKit.invokeApplePay(with: .payment, configuration: config) { response, error in
// handle result
}Judopay acts as a pass-through service, whereby we supply the data needed by Apple Pay™ for them to return a device / merchant specific token that can be used for MIT transactions.
For a full description on all the object properties in the Apple Pay™ deferred payments flow, see the Apple Pay™ Documentation.
Adding Payment Methods
Before you can process Apple Pay™ payments with Judopay, you will need to set up Apple Pay™.
Going Live with iOS
Point to the Live Environment
- In ViewController delete the line that specifies the targeted environment: judo.sandboxed = YES;
- Replace your sandbox API Token and Secret for the live API Token and Secret. Find these in Judopay Portal > Your apps > {app name} > Live Tokens
Test live payments
Use the live environment for testing before deploying your app.
- Ensure the SDK is properly configured for the live environment
- Use real debit or credit cards
- Test cards provided will not work in live
- We recommend to perform pre-authorizations followed by a void, or regular payments followed by a refund
- Send a refund through the JudopayPortal > History
- Test all payment scenarios and security features to verify the expected behaviour
Follow our suggested guidelines to simulate both positive / happy path scenarios, and negative scenarios in the sandbox environment to test your integration is working correctly. This will give you confidence for when your integration goes live.
See:



