Judopay Documentation

iOS

Configuring Apple Pay™ for iOS

To configure Apple Pay™:

  1. Add the Apple Pay™ configuration

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

Caution

Apple Pay™ transactions require additional parameters in order to work correctly.

To set all the Apple Pay™ required parameters, use the JPApplePayConfiguration:

NSDecimalNumber *itemOnePrice = [NSDecimalNumber decimalNumberWithString:@"649.99"];
NSDecimalNumber *itemTwoPrice = [NSDecimalNumber decimalNumberWithString:@"55.00"];
NSDecimalNumber *totalPrice = [NSDecimalNumber decimalNumberWithString:@"704.99"];

NSArray *mySummaryItems = @[
  [JPPaymentSummaryItem itemWithLabel:@"iPhone XR 254GB" amount:itemOnePrice],
  [JPPaymentSummaryItem itemWithLabel:@"iPhone XR Case" amount:itemTwoPrice],
  [JPPaymentSummaryItem itemWithLabel:@"Apple Store" amount:totalPrice],
];

Note

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.

This is how the JPApplePayConfiguration looks:

NSArray *mySummaryItems

JPApplePayConfiguration *applePayConfig;
applePayConfig = [[JPApplePayConfiguration alloc] initWithMerchantId:@"my-merchant-id"
                                                            currency:@"GBP"
                                                         countryCode:@"GB"
                                                 paymentSummaryItems:mySummaryItems];

Parameter

Description

merchantId

NSString

Your Apple Pay™ merchant ID.

This confirms you are able to accept payments.

currency

NSString

An ISO 4217 currency code.

countryCode

NSString

An ISO 3166-1 Alpha-2 country code.

paymentSummaryItems

NSArray

The list of items.

Note

The last item in the array should always represent the total amount.

Step Two - Add the instance to the object

1. Add the JPApplePayConfiguration instance to the JPConfiguration object:

configuration.applePayConfiguration = applePayConfig;

2. Call the Judo method

3. Invoke Apple Pay™ by providing the TransactionMode

  • This allows you to select

    • Payment or,

    • PreAuth

  • Set the Apple Pay™ configuration:

[judo invokeApplePayWithMode:TransactionModePayment
               configuration:myApplePayConfiguration
                  completion:^(JPResponse *response, NSError *error) {
    // Handle response or error
}];

Displaying Apple Pay™ as a Payment Method

To display Apple Pay™ as a payment method:

1. Configure the JPApplePayConfiguration object

2. From the JPConfiguration already created, call:

[self.judoKitSession invokePaymentMethodScreenWithMode:TransactionModePayment
                                         configuration:configuration
                                            completion:^(JPResponse *response, NSError *error) {
    // Handle the response and error
}];

Tip

In the example, the TransactionMode is set as the first method parameter. This is an enum value that allows the selection between Payment and PreAuth transactions.

Adding the Billing and Shipping Details

If you would like the consumer to provide their billing and shipping details, set the following properties:

  • requiredBillingContactFields 

  • requiredShippingContactFields

You can choose between multiple contact field types:

  • email address 

  • phone number 

  • post code

Example:

applePayConfig.requiredBillingContactFields = ContactFieldName | ContactFieldEmail;
applePayConfig.requiredShippingContactFields = ContactFieldAll;

Parameter

Description

ContactFieldName

Consumer's name.

ContactFieldEmail

Consumer's valid email address.

ContactFieldPhone

Consumer's valid phone number.

ContactFieldPostalAddress

Consumer's postal address.

ContactFieldAll

All the values above.

 

If you set shipping details as a required field, you must also set the shippingType and the shippingMethods properties.

 

To set the shipping type:

applePayConfig.shippingType = ShippingTypeDelivery;

Parameter

Description

ShippingTypeShipping

Shipping.

The default value.

ShippingTypeDelivery

Delivery.

ShippingTypeStorePickup

Store Pickup.

ShippingTypeServicePickup

Service Pickup.

Setting the shipping methods requires an array of PaymentShippingMethod objects. 

 

To set an array of paymentShippingMethod objects:

NSDecimalNumber *deliveryCost = [NSDecimalNumber decimalNumberWithString:@"25.0"];

PaymentShippingMethod *delivery;
delivery = [[PaymentShippingMethod alloc] initWithIdentifier:@"delivery"
                                                      detail:@"Deliver to your address"
                                                       label:@"Delivery"
                                                      amount:deliveryCost];

applePayConfig.shippingMethods = @[delivery];

Getting the Billing and Shipping Details

To get the billing and shipping information back from the consumer:

1. Set the returnedContactInfo: applePayConfig.returnedContactInfo = ReturnedInfoBillingContacts;

Parameter

Description

ReturnedInfoBillingContacts

Billing details returned.

The default value.

ReturnedInfoShippingContacts

Shipping details returned.

ReturnedInfoAll

Billing and Shipping details returned.