Simple SDKs

eWAY is the easiest way to accept payments in your app or on your website. Get integrated and start selling more, faster - in a range of languages using the eWAY SDKs, helpful documentation, and 24/7 support from real humans. eWAY - with you every step of the way.

eWAY Apple Pay Quickstart

Taking payments with Apple Pay in your iOS app is easy while using the eWAY iOS SDK.

Apple Pay and eWAY SDK

This quickstart guide covers how to setup and use Apple Pay with the iOS SDK. It should be read in conjunction with Apple’s Apple Pay documentation, in particular:

Setup

To use Apple Pay with eWAY the following setup steps should be followed.

Create an iOS Merchant ID

A Merchant ID is used to identify your Apple Pay account. To create one:

  1. In your Apple Developer account, navigate to the Merchant IDs page.
  2. Select the add button, and enter a description and unique Merchant ID (e.g. merchant.com.yourname).

Request a CSR

In order to create a certificate for use with Apple Pay, you will need to use an eWAY issued CSR. Please contact eWAY directly for a CSR for Apple Pay.

Create an Apple Pay Certificate

Once you have your eWAY issued CSR, you can generate a certificate use to encrypt your payment tokens.

  1. Navigate to the iOS Add Certificate page in your Apple Developer account.
  2. Select “Apply Pay Certificate” and click “Continue“.
  3. Select the Merchant ID you create in the earlier step.
  4. Click “Next” on the next page.
  5. Upload the CSR provided by eWAY. Note: you must use an eWAY provided CSR to use Apple Pay with eWAY.
  6. Once uploaded, you’ll be presented with a page where you can download your certificate.

Please send your Apple Pay certificate to eWAY so that it can be loaded into your account.


Add your Merchant ID to Xcode

The final step is to add your Apple iOS Merchant ID to your iOS app project in Xcode.

  1. Open your project in Xcode.
  2. Navigate to your project’s settings and open “Capabilities“.
  3. Toggle “Apple Pay” to On.
  4. A prompt may open asking you to log into your Apple Developer account.
  5. Check the box next to the iOS Merchant ID you used to generate the Apple Pay certificate in the previous steps.

Install the eWAY iOS SDK

If you haven’t already, don’t forget to install the eWAY iOS SDK – this can be done with CocoaPods
  1. Add the eWAY iOS SDK to the project’s Podfile:

    1. pod 'eWAYPaymentsSDK'
  2. Then run

    1. pod install

    to download and install the SDK


Using the eWAY iOS SDK with Apple Pay

To complete a transaction with Apple Pay and eWAY is three step process:

  1. Create an Apple Pay request
  2. Display the Apple Pay prompt
  3. Fetch the transaction response

The eWAY iOS SDK on GitHub contains an example project with an Apple Pay integration (Example/eWAYPaymentsSDK+ApplePay), this is best used to understand the process and implementation.

Please also follow the steps in the eWAY iOS Getting Started guide to configure the SDK (such as setting the Public API Key). Apple Pay is not available on eWAY’s Sandbox.


Create an Apple Pay Request

To initiate a payment with Apple Pay, a PKPaymentRequest object is used by the eWAY iOS SDK to pass all the transaction information. This must include details such as the iOS Merchant ID, the transaction amount, currency and item details. Optional details such as customer and shipping information can also be passed. Full details of PKPaymentRequest are available in the iOS Developer Library.


  1. // Set this to your Apple Pay Merchant ID from Developer account
  2. merchantIdentifier = @"You Merchant ID from Developer account";


  3. countryCode = @"AU";

  4. //Indicate which payment networks you support by populating the supportedNetworks property with an array of string constants.
  5. supportedNetworks = @[PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa];

  6. //Indicate which payment processing protocols you support by setting a value for the merchantCapabilities property
  7. merchantCapabilities = PKMerchantCapability3DS;

  8. //Create an instance of PKShippingMethod for each available shipping method
  9. PKShippingMethod *standard =
  10. [PKShippingMethod summaryItemWithLabel:@"Standard Shipping" amount:[NSDecimalNumber decimalNumberWithString:@"0.05"]];
  11. standard.detail = @"5 Business Days";
  12. standard.identifier = @"standard";
  13. PKShippingMethod *express =
  14. [PKShippingMethod summaryItemWithLabel:@"Express Shipping" amount:[NSDecimalNumber decimalNumberWithString:@"0.10"]];
  15. express.detail = @"Next Day";
  16. express.identifier = @"next-day";

  17. shippingMethods = @[standard, express];

  18. //Payment summary items, represented by the PKPaymentSummaryItem class, describe the different parts of the payment request to the user.
  19. PKPaymentSummaryItem *firstItem = [PKPaymentSummaryItem summaryItemWithLabel:@"iPad" amount:[NSDecimalNumber decimalNumberWithString:@"3.00"]];
  20. PKPaymentSummaryItem *secondItem = [PKPaymentSummaryItem summaryItemWithLabel:@"iWatch" amount:[NSDecimalNumber decimalNumberWithString:@"1.00"]];
  21. PKPaymentSummaryItem *shippingItem = [PKPaymentSummaryItem summaryItemWithLabel:standard.identifier amount:standard.amount];

  22. //The last payment summary item in the list is the grand total. Calculate the grand total amount by adding the amounts of all the other summary items.
  23. NSDecimalNumber *total = [firstItem.amount decimalNumberByAdding:[secondItem.amount decimalNumberByAdding:shippingItem.amount]];
  24. PKPaymentSummaryItem *totalItem = [PKPaymentSummaryItem summaryItemWithLabel:@"Your Company Name" amount:total];

  25. paymentSummaryItems = @[firstItem, secondItem, shippingItem,totalItem];

  26. currencyCode = @"AUD";

  27. //Populate the requiredBillingAddressFields and requiredShippingAddressFields properties of the payment authorization view controller to indicate what billing and shipping information is needed
  28. requiredBillingAddressFields = PKAddressFieldPostalAddress | PKAddressFieldName;
  29. requiredShippingAddressFields = PKAddressFieldPostalAddress;

(from APSimpleViewController.m of the eWAY Apple Pay example project)


Display the Apple Pay Prompt

To authorise the payment, next the Apple Pay prompt needs to be displayed to the user so they can confirm the transaction. This is done with the ShowApplePayAuthorizationView function.

  1. transactionType = Purchase;
  2. method = ProcessPayment;

  3. //Create PKPaymentRequest
  4. [RapidAPI CreateApplePayRequest:merchantIdentifier countryCode:countryCode supportedNetworks:supportedNetworks merchantCapabilities:merchantCapabilities paymentSummaryItems:paymentSummaryItems currencyCode:currencyCode requiredBillingAddressFields:requiredBillingAddressFields billingAddress:nil requiredShippingAddressFields:requiredShippingAddressFields shippingAddress:nil shippingMethods:shippingMethods onCompletion:^(PKPaymentRequest *paymentRequest, NSError *error) {
  5.     if (error) {
  6.         NSLog(@"Error creating payment request: %@", [error localizedDescription]);
  7.        
  8.         UIAlertView *errorAlert = [[UIAlertView alloc]
  9.                                    initWithTitle: @"Error"
  10.                                    message: [error localizedDescription]
  11.                                    delegate:nil
  12.                                    cancelButtonTitle:@"OK"
  13.                                    otherButtonTitles:nil];
  14.         [errorAlert show];
  15.         return;
  16.     }
  17.    
  18.     //Bring up the PKPaymentAuthorizationViewController, pass the payment request to the view controller’s initializer
  19.     //Set a delegate for the view controller, and then present it.
  20.     [RapidAPI ShowApplePayAuthorizationView:paymentRequest withDelegateController:self];
  21.    
  22. }];

(from APSimpleViewController.m of the eWAY Apple Pay example project)


Fetch the Transaction Response

Once the Apple Pay prompt has completed, the transaction can be processed with eWAY. This is done with the submitApplePay function. It will return a SubmitPaymentResponse which contains key details such as any errors encountered and the SubmissionID. The SubmissionID can be passed to your backend server and used with eWAY’s Rapid Transaction Query API to fetch the result.


  1. [RapidAPI submitApplePay:payment transactionType:transactionType method:method completed:^(SubmitPaymentResponse *submitPaymentResponse) {
  2.     NSString *msg = [NSString stringWithFormat:@"%@",@{@"Errors":submitPaymentResponse.Errors,@"SubmissionID":submitPaymentResponse.SubmissionID, @"Status":[NSString stringWithFormat:@"%lu",(unsigned long)submitPaymentResponse.Status]}];
  3.     NSLog(@"Apple Pay Result %@", msg);
  4.     if (submitPaymentResponse.Status != Error && [submitPaymentResponse.SubmissionID length] > 0)
  5.         completion(PKPaymentAuthorizationStatusSuccess);
  6.     else
  7.         completion(PKPaymentAuthorizationStatusFailure);
  8.        
  9. }];

(from APSimpleViewController.m of the eWAY Apple Pay example project)

eWAY makes it easy for us to process and manage payments. They have an SDK that my developers liked working with and their payment management tools are very easy to use.

Dean Van Es, Managing Director FastCover