JudoSDK 4.7.4

JudoSDK 4.7.4

License Custom
ReleasedLast Release Apr 2016

Maintained by Judopay.



JudoSDK 4.7.4

judoNative SDK for iOS

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.

***Due to industry-wide security updates, versions below 4.7.2 of this SDK will no longer be supported after 1st Oct 2016. For more information regarding these updates, please read our blog here.***

Instructions

The judopayments iOS SDK includes header files and a single static library.

Sign up for judopayments

  • To use the judopay SDK, you'll need to sign up and get your app token

Requirements

  • Supports target deployment of iOS version 6.0+.
  • Supports armv7 and armv7s devices, but not armv6.

Installation

Manual

  1. Add these frameworks to your project.

    • CoreGraphics
    • Foundation
    • MobileCoreServices
    • QuartzCore
    • Security
    • SystemConfiguration
    • UIKit
  2. Drag the JudoPay.framework and JudoPay.bundle to your Xcode project and add the -ObjC and -all_load to your projects linker flags

  3. Add judopayments open source license acknowledgments to your app's acknowledgments.

Additional Setup

  1. add #import <JudoPay/JudoPay.h> to the top of the file where you want to use the SDK.

  2. 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

  3. 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:]

  4. 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.

Examples

{
    "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"
}
  • To save a card for later use, retrieve the cardDetails dictionary and yourConsumerReference from the above response and store them securely. Use the following static method on JudoSDK to make another payment using the card token:
- (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;
  • Refer to the header files for more usage options and information.

Sample code

// 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);
                              }];
  • To register a card without paying, use the registerCard method
- (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;

Hints & Tips

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

Sample Apps

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.