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.
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:
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.
A completion block that returns the transaction response or an error.
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:
Server to Server Example
1//Set the TransactionMode to TransactionModeServerToServer when calling the Judopay methods:23[judo invokePaymentMethodScreenWithMode:TransactionModeServerToServer
4 configuration:configuration
5 completion:^(JPResponse *response, JPError *error){6// Handle the payment token returned from the response7}];8910//Specify an Apple Pay™ transaction:1112[judo invokeApplePayWithMode:TransactionModeServerToServer
13 configuration:configuration
14 completion:^(JPResponse *response, JPError *error){15// Handle the payment token returned from the response16}];
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.
1//Call the method and handle the response from the completion block:23[judo invokeTokenTransactionWithType:JPTransactionTypePayment
4 configuration:configuration
5 details:cardTransactionDetails completion:^(JPResponse *response, JPError *error)6{7// Handle response / error8}];
3D Secure 2 for iOS
JudoKit-iOS is enabled for 3D Secure 2 (EMV 3DS).
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).
Using the Card Entry UI
The easiest way to integrate 3D Secure is to use the UI 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.
Card Entry UI
1JPAmount *amount =[[JPAmount alloc] initWithAmount:@"1.50" currency:@"GBP"];2JPReference *reference =[[JPReference alloc] initWithConsumerReference:@"consumer-reference" paymentReference:@"payment-reference"];34JPUIConfiguration *uiConfiguration =[JPUIConfiguration new];56// sets whether 3DS 2.0 UI billing information screen should be presented to the user7uiConfiguration.shouldAskForBillingInformation = YES;89// in case you don't want to present billing info screen to the user, you can set the address instead10JPAddress *address =[[JPAddress alloc] initWithAddress1:@"My house"11 address2:@"My street"12 town:@"My town"13 billingCountry:@"826"14 postCode:@"TR14 8PA"15 countryCode:@826];1617JPConfiguration *configuration =[[JPConfiguration alloc] initWithJudoID:@"my-judo-id" amount:amount reference:reference];18configuration.uiConfiguration = uiConfiguration;1920configuration.cardAddress = address;212223// sets the value for challenge request indicator,24// possible values:25//26// noPreference27// noChallenge28// challengePreferred29// challengeAsMandate30//31configuration.challengeRequestIndicator = @"challengeAsMandate";3233// sets the value for SCA exemption,34// possible values:35//36// lowValue37// secureCorporate38// trustedBeneficiary39// transactionRiskAnalysis40//41configuration.scaExemption = @"lowValue";4243// email address44configuration.emailAddress = @"[email protected]";4546// sets the maximum timeout for 3DS 2.0 transactions in minutes,47// always use 2 characters when setting the timeout48configuration.threeDSTwoMaxTimeout =30;4950// sets phone number country code51configuration.phoneCountryCode = @"44";5253// phone number54configuration.mobileNumber = @"11223344556677";
You have flexibility on how the payment experience looks to the consumer.
The JPConfiguration object has a uiConfiguration property of type JPUIConfiguration.
This allows you to:
Enable | disable the Address Verification Service
Show | hide the amount in the Payments Widget
Show | hide the amount in the payment button
Enable | disable consumers entering the CV2 code
Enable | disable consumers entering the cardholder name
Enable | disable consumers entering the billing information
You can also override some of the default iOS theming options.
See iOS Styles and Themes.
The JPUIConfiguration instance is set as part of the JPConfiguration object that is passed to our transactions.
Setting up an Incremental Authorisation
The incremental authorisation feature allows you to increment the value of your original preAuth for scenarios where you need to charge your customer a higher total amount.
By incrementing the preAuth value, you will be able to capture the total amount that you wish to charge your customer when you are ready.
The allowIncrement flag allows you to set up your initial preAuth so that it can be incremented by an additional amount.
This feature is only available with a limited set of processors - please check with your account manager before you use this feature.
isAllowIncrement is a part of the main JPConfiguration config object, and can be set directly during configuration setup.
If present = it is automatically applied for pre-auth requests.
If no value is provided = then false is set by default.
It is mandatory for merchants who have an MCC code of 6012 to submit additional Information about the primary account holder in primaryAccountDetails property for payment pre-authorisation.
To set the primary account details when using an alternative payment method, see Adding Payment Methods.
To set the primary account details to be sent with the transaction:
Set the primaryAccountDetails property of the JPConfiguration object:
Set the supportedCardNetworks property of the JPConfiguration object with one or more values from this list:
Card Network Name
Value
Visa
JPCardNetworkTypeVisa
MasterCard
JPCardNetworkTypeMasterCard
Maestro
JPCardNetworkTypeMaestro
AMEX
JPCardNetworkTypeAMEX
China Union Pay
JPCardNetworkTypeChinaUnionPay
JCB
JPCardNetworkTypeJCB
Diners Club International
JPCardNetworkTypeDinersClub
Discover
JPCardNetworkTypeDiscover
All
JPCardNetworkTypeAll
For the purpose of this exercise, Visa and MasterCard are set as the supported card networks:
configuration.supportedCardNetworks = JPCardNetworkTypeVisa | JPCardNetworkTypeMasterCard;
Setting a Card Address
To set the card address when using an alternative payment method, see Adding Payment Methods.
To send additional card address details with the transaction:
Set the cardAddress parameter in the JPConfiguration object:
The above properties are optional, so set only the ones you need.
Changing the Default Payment Methods
By default, all payment methods are displayed in the Payments Widget (as long as the required parameters are set).
You have the flexibility to include the payment methods you support, with pre-defined initialisers for each payment method.
To set the payment methods:
Set the paymentMethods property in the JPConfiguration object with your list of payment methods:
configuration.paymentMethods = JPPaymentMethodCard | JPPaymentMethodIDeal;
For the purpose of this exercise, Card and iDEAL transactions are set as the supported payment methods.
iOS Styles and Themes
To apply your own custom styles and theme options, override the following payment UI elements:
Initialise the theme object:
JPTheme *theme = [JPTheme new];
Set a custom back button image:
theme.backButtonImage = [UIImage imageNamed:@"my-custom-icon"];
Add the JPTheme instance to the JPUIConfiguration object:
configuration.uiConfiguration.theme = theme;
Payment Reference and MetaData
You can enable some additional information to be sent within a transaction, for example information to help with reconciliation or receipt tracking.
Setting up the paymentReference and metaData properties can allow for:
paymentReference:
unique payment reference for the transaction.
metaData:
Any additional details you require, specific to your organisation or internal systems.
Set up paymentReference and metaData Properties
1//Pass the paymentReference within the JPReference object with your transaction:23myReference =[[JPReference alloc] initWithConsumerReference:@"my-reference"4 paymentReference:@"my-payment-reference"];567//Set the metaData property to send metadata with your transaction:89myReference.metaData = @{10 @"my-key": @"my-value"11}
Adding Payment Methods
Before you can process Apple Pay™ payments with Judopay, you will need to set up Apple Pay™.
Setting up Apple Pay for iOS
Apple Pay™ is not supported on all Apple devices.
Before invoking any Apple Pay™ functionality within your app, test if it is supported on the device by performing these checks:
Use PKPaymentAuthorizationViewController canMakePayments
Checks if the device supports Apple Pay™ and has it enabled.
Queries both the device hardware and whether Apple Pay™ is enabled in the user’s region
Use PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks
A more detailed check to query whether a user has a registered card with particular card schemes.
Useful if you do not accept all card types.
Both methods are explained in the Apple developer documentation here.
Getting Your Apple Pay™ AccountSystem Requirements:
A compatible Apple device: iPhone 6 & 6 Plus | iPad Air 2 | iPad mini 3 | or newer
iOS 12.0 or newer
Xcode 14.0 or newer
Create a Merchant ID
We recommend creating a Merchant ID for each Merchant (i.e. business) accepting payments within your app.
To set up your Apple Pay™ account:
1
Access your Apple Developer Account.
Navigate to Certificates, Identifiers & Profiles.
2
From the side menu, click Merchant IDs.
3
In the iOS Merchant ID Settings screen, click the add button.
4
Set your Merchant ID.
The identifier you enter should be a reverse DNS style identifier prefixed with the word.
5
Click Done.
Create an Apple Pay™ CertificatePrerequisite
Request a Certificate Signing Request (CSR) file from Judopay.
When you’ve received your CSR, you can create your Apple Pay™ certificate.
To create your Apple Pay™ certificate:
1
From the side menu, select either:
Certificates > All
Merchant ID
2
The screen appears describing how to manually create your Certificate Signing Request (CSR).
As you’ve already obtained your CSR from Judopay, click Continue.
3
You will be prompted to state if you are processing transactions outside the United States.
Select No.
4
Click Continue.
5
Click Choose File to upload the CSR file provided by Judopay.
6
Click Generate.
7
The confirmation screen appears.
Your certificate is ready to download.
Click Download.
8
Click Done.
To complete your Apple Pay™ set-up send the certificate to Judopay.
Once received, we will add the certificate to your account and confirm it has been added.
Apple Certificates expire just over two years after generation.
For example a certificate generated on 13th May 2024 will expire on the 11th June 2025.
Refer to your Apple Developer Account for an accurate expiry date.
To generate a new certificate follow the steps above.
Set Up Apple Pay™ Entitlement
Apple Pay™ is built into the PassKit framework, which means you will need to configure the entitlement.
To set up the entitlement:
1
Select your build Target.
2
Select Capabilities.
3
Set the entitlement to Enabled.
4
Add the Merchant ID created earlier to the app.
You may need to refresh the list.
5
Open the entitlements file to confirm the Merchant ID has been added to your app.
Your account is now ready to process Apple Pay™ payments with Judopay.
Configure the iOS Mobile SDK to start making payments.
Apple Pay™ Button
Apple Pay™ allows the consumer to:
Bypass the standard checkout flow
Complete their payment with speed
When integrating with Apple Pay™, it is recommended to consider when to introduce the Apple Pay™ button.
This can be:
On a single item product listing page
Within a basket page with multiple items
Both of the above scenarios
The Apple Pay™ button enables consumers to make a purchase from the specific page they are browsing.
By tapping the Apple Pay™ button, the payment sheet is invoked to begin the checkout process.
For more information on the Apple Pay™ button, see Apple’s guidance of the PKPaymentButton Class Reference.
Best Practice Testing
You can test Apple Pay™ in the sandbox environment with the sandbox cards, however please note these test transactions will not work going upstream.
To test Apple Pay™ transactions, point to the live environment and use live cards.
We recommend performing | Pre-Authorizations | Card Payments | Full Refunds: via the Judopay Dashboard > History, or via an API call
We strongly recommend testing Apple Pay™ through each of these scenarios before you release the app:
Unsupported Device
Use a non-supported device in order to verify the whole recognition workflow works as expected.
Card not Supported
Use a card issued by a bank that does not support Apple Pay™. You can also use the test cards provided on the Judopay Dashboard to validate the error returned and expected behaviour.
Payment Cancelled
Cancel a transaction in process and see the results in the app and in your Judopay Dashboard history.
Poor / Loss of Connection
While a transaction is being processed, disconnect the internet connection to see if the app responds as expected.
Configuring Apple Pay for iOS
To configure Apple Pay™:
Add the Apple Pay™ configuration
Call the Apple Pay™ method
Step One: Adding the Apple Pay™ Configuration
All Judo transactions require a JPConfiguration instance passed as a method parameter.
The basic JPConfiguration requires:
Judo ID
Amount
Consumer reference
Apple Pay™ transactions require additional parameters in order to work correctly.
To set all the Apple Pay™ required parameters, use the JPApplePayConfiguration:
For each item you wish to list, you will need to sum up the item in the basket.
Payment summary items:
This is a list of JPPaymentSummaryItem objects, that describe the item being purchased, including the price.
In the example above, the item label was set to the merchant from where the item was purchased.
To add iDEAL support to your Payments Widget, set:
Currency code to EUR (Euro)
The judoId parameter in the JPConfiguration instance:
An example of a valid iDEAL configuration:
configuration.judoId = @"my-judo-id";
Once the currency and judoId are set, iDEAL will be available as a payment method in the Payments Widget.
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.