The judoNative iOS library lets you integrate secure in-app card payments into your iOS app. Judo's SDK enables a faster, simpler and more secure payment experience within your app.
The judopayments iOS SDK includes header files and a single static library.
Add these frameworks to your project.
Drag the JudoPay.framework and JudoPay.bundle to your Xcode project and add the -ObjC and -all_load to your projects linker flags
Add judopayments open source license acknowledgments to your app's acknowledgments.
add #import <JudoPay/JudoPay.h>
to the top of the file where you want to use the SDK.
To instruct the SDK to communicate with the sandbox, include the following line [[JudoAPIManager sharedSession] setSandboxMode]
When you are ready to go live you can remove this line. We would recommend to put this in the method didFinishLaunchingWithOptions
in your AppDelegate
You can also set your key and secret here if you do not wish to include it in all subsequent calls [[JudoSDKManager sharedSession] setToken: andSecret:]
A single line integration can be achieved with the following static method on JudoSDKManager:
- (void)judoPaymentWithAmount:(nonnull JPAmount *)amount
judoID:(nonnull NSString *)judoID
consumerRef:(nonnull NSString *)consumerRef
metaData:(nullable NSDictionary *)metaData
parentViewController:(nonnull id)viewController
success:(nullable void(^)(id __nullable JSON))successBlock
failure:(nullable void(^)(NSError * __nullable error))failureBlock;
Parse and inspect the returned JSON data object for details of the transaction.
{
"amount": 4,
"appearsOnStatementAs": "JudoPay/judoPayD",
"cardDetails": {
"cardLastfour": 3436,
"cardToken": "9CE128956DB34ED0902AC3E155EBC299",
"cardType": 1,
"endDate": 1215
},
"consumer": {
"yourConsumerReference": "yourconsumerref"
},
"createdAt": "2013-07-18T11:39:03.6000+01:00",
"judoId": 100016,
"merchantName": "judoPay Dev",
"netAmount": 4,
"originalAmount": 4,
"receiptId": 33712,
"result": "Success",
"type": "Payment"
}
- (void)judoPaymentWithAmount:(nonnull JPAmount *)amount
cardDetails:(nonnull NSDictionary *)cardDetails
judoID:(nonnull NSString *)judoID
consumerRef:(nonnull NSString *)consumerRef
metaData:(nullable NSDictionary *)metaData
parentViewController:(nonnull id)viewController
success:(nullable void (^)(id __nullable JSON))successBlock
failure:(nullable void (^)(NSError * __nullable error))failureBlock;
// SomeViewController.h
#import <JudoPay/JudoPay.h>
[JudoSDKManager judoPaymentWithAmount:4.0
judoID:@"100016"
consumerRef:@"yourConsumerRef"
metaData:nil
parentViewController:self
success:^(id responseObject) {
id object = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
NSLog(@"parsed response: %@", object);
// store these for later use
NSDictionary *cardDetails = [object valueForKey:@"cardDetails"];
NSString *consumerRef = [[object valueForKey:@"consumer"] valueForKey:@"yourConsumerReference"];
} withFailure:^(NSError *error) {
NSLog(@"Failure: %@", error);
}];
- (void)judoRegisterCard:(nonnull Card *)card
consumerRef:(nonnull NSString *)consumerRef
deviceID:(nullable NSString *)deviceID
parentViewController:(nonnull id)viewController
success:(nullable void(^)(id __nullable JSON))successBlock
failure:(nullable void(^)(NSError * __nullable error))failureBlock;
Most likely you will want to include a proper payment reference and consumer reference, helper classes are provided in the JudoPay SDK to facilitate this and make use of simple objects such as NSDictionary and NSString
The Swift and Objective C sample Apps included in this repository were written with Xcode 7. As of the moment of this beta release, Xcode 7 is still in Beta. Some things will not work as intended, so please bear with us and hope for a quick September release of the final version.