You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Overview


This is the documentation for the Axepta iOS SDK, which describes how to integrate payments in your iOS app.

The integration of the SDK is achieved by following a list of mandatory steps as described below:

  • Configuration of the merchant account in the Axepta system.
  • ‘Axepta’ SDK pod installation.
  • Configuration of the SDK by inserting appropriate data retrieved from Axepta.
  • Configuration of preferable payment methods.
  • Authentication against the merchant backend.
  • Insertion of the payment data.
  • Checkout.
  • Handling of errors.

List of supported payment methods

The iOS SDK currently supports the following payment methods:

  • Credit Card
  • Direct Debit
  • PayPal
  • Apple Pay
  • WeChat

For more information please check below chapter 4.3.


Requirements


Requirements in order to be able to use the SDK:

Preparation

  • Existing merchant account at Axepta
  • Merchant ID which you will receive from Axepta after creation of the merchant account
  • Backend and the belonging URL on merchant side to create and deliver a auth token (see chapter 4.2)
  • Website and the belonging URL’s on merchant side to forward and show the status of a payment process in case of a success, failure or a notify event (see chapter 4.3.2).

Development

  • Installed cocoapods on the development machine - minimum version of cocoa pods is v1.1.1
  • Minimum required Xcode version is Xcode 8
  • iOS 10 as minimum deployment target

Apple Pay

  • Registered Apple Developer Account
  • Configured app in the Apple Developer center - activated for Apple Pay
  • Configured Apple Merchant ID
  • Certificate Signing-Request-File received from Axepta to create a Payment Processing Certificate

For more information see below in chapter 4.4 Apple Pay.

 Installation


If not already done, please install cocoapods. Here https://guides.cocoapods.org/using/getting-started.html you will find the HowTo for that.

When CocoaPods is installed, you need to activate your Xcode project for CocoaPods in the way that is described here: https://guides.cocoapods.org/using/using-cocoapods.html

That means you have to create a Podfile inside the root directory of your project. You could do this with the following command within terminal in the root folder of your project:

pod init

Then add the following line to your Podfile:

pod 'Axepta'

and run the following command within terminal in the root folder of your project:

pod install

If there comes an error like “ [!] Unable to find a specification for `Axepta` ” you should update your local CocoaPods repositories by

pod update

After them try again

pod install


Now you should have a configured xcode workspace with the integrated Axepta Framework. From now use the workspace file to open your Xcode project.


 How to implement


You could find a demo on https://github.com/axepta/Axepta-iOS


Try the demo in order to see how it works or use the following step by step guideline.

Configuration

Configure the SDK by importing the Axepta class and inserting the configuration parameters you receive from Axepta or parameter merchantAppleID that you create yourself.

The AppDelegate class is the appropriate place to do so.

#import "AppDelegate.h"

#import <Axepta/Axepta.h>

@implementation AppDelegate

- ( BOOL ) application :( UIApplication *) application

didFinishLaunchingWithOptions :( NSDictionary *) launchOptions

{

AxeptaConfiguration.merchantID = @"YOUR_MERCHANT_ID";

AxeptaConfiguration.merchantAppleID = @"YOUR_APPLE_MERCHANT_ID";

return YES;

}

@end


Authentication

One requirement for the Mobile SDK is to insert the respective Merchant’s URL in order to be able to receive the auth token. The SDK is responsible to retrieve then the token under the hood and use it appropriately when executing payment requests. An appropriate place to do that is inside AppDelegate with the rest of Configuration. For more information, see the Axepta documentation .

#import "AppDelegate.h"

#import <Axepta/Axepta.h>

@implementation AppDelegate

- ( BOOL ) application :( UIApplication *) application

didFinishLaunchingWithOptions :( NSDictionary *) launchOptions

{

AxeptaConfiguration.merchantID = @"YOUR_MERCHANT_ID";

AxeptaConfiguration.merchantAppleID = @"YOUR_APPLE_MERCHANT_ID";

AxeptaConfiguration.authURL = @"YOUR_AUTH_URL";

return YES;

}

@end

Making a payment

Assumed your app user inserted some products into the basket, typed the shipping address and now wants to make the payment - that means you want to provide/show different payment methods to the user, so that he can choose from.

For that you need to ask the SDK for supported payment methods:


Retrieve payment methods

Currently the SDK returns all the available methods by calling the method in the following code snippet. Merchant can use only the methods they are activated in Axepta.

[[ Axepta sharedInstance ] paymentMethodsOnSuccess :^( NSArray < AxeptaPaymentMethod *>

* paymentMethods ) {

// set the methods as a data source

} onFailure :^( NSError * error ) {

// do something with the error

}];


A good place to do this is a view controller class, which controls the view of the payment methods. So you could set this as data source for your view. In the example app we are doing this in the PaymentViewController class

Now in order to proceed with a payment it is necessary to configure the appropriate payment data for each payment method.

Configure payment data

Every received payment method holds a AxeptaPaymentData instance. You only need to insert all merchant's necessary payment data for the checkout (more details on PaymentData in Axepta documentation ). A good way to do that is after the receive of the supported payment methods:

[[ Axepta sharedInstance ] paymentMethodsOnSuccess :^( NSArray < AxeptaPaymentMethod *>

* paymentMethods )

{

// set the methods as a data source

self . paymentMethods = paymentMethods;

for ( AxeptaPaymentMethod * method in self . paymentMethods)

{

// Mandatory params

[ method . paymentData setParamWithKey :@ "TransID" withValue :@ "YOUR_TRANS_ID" ];

[ method . paymentData setParamWithKey :@ "Amount" withValue :@ "YOUR_AMOUNT";

[ method . paymentData setParamWithKey :@ "Currency" withValue :@ "YOUR_CURRENCY" ];

[ method . paymentData setParamWithKey :@ "URLSuccess" withValue :@ "YOUR_URL_SUCCESS" ];

[ method . paymentData setParamWithKey :@ "URLNotify" withValue :@ "YOUR_URL_NOTIFY" ];

[ method . paymentData setParamWithKey :@ "URLFailure" withValue :@ "YOUR_URL_FAILURE" ];

if ([method. pmID isEqualToString : @ "pm_cc" ]) {

[method. paymentData setParamWithKey : @ "MsgVer" withValue :

@ "YOUR_MSGVER" ];

}

// Url sucess, failure of paypal may be different from other payments

if ([method. pmID isEqualToString : @ "pm_paypal" ]) {

[ method . paymentData setParamWithKey :@ "URLSuccess"

withValue :@ "YOUR_URL_SUCCESS_PAYPAL" ];

[ method . paymentData setParamWithKey :@ "URLFailure"

withValue :@ "YOUR_URL_FAILURE_PAYPAL" ];

} else {

[ method . paymentData setParamWithKey :@ "URLSuccess" withValue :@ "YOUR_URL_SUCCESS" ];

[ method . paymentData setParamWithKey :@ "URLFailure" withValue :@ "YOUR_URL_FAILURE" ];

}

// Optional params

[ method . paymentData setParamWithKey :@ "RefNr" withValue :@ "YOUR_REF_NR" ];

[ method . paymentData setParamWithKey :@ "OrderDesc" withValue :@ "YOUR_ORDER_DESC" ];

[ method . paymentData setParamWithKey :@ "AddrCity" withValue :@ "YOUR_ADDR_CITY" ];

[ method . paymentData setParamWithKey :@ "FirstName" withValue :@ "YOUR_FIRST_NAME" ];

[ method . paymentData setParamWithKey :@ "LastName" withValue :@ "YOUR_LAST_NAME" ];

[ method . paymentData setParamWithKey :@ "AddrZip" withValue :@ "YOUR_ADDR_ZIP" ];

[ method . paymentData setParamWithKey :@ "AddrStreet" withValue :@ "YOUR_ADDR_STREET" ];

[ method . paymentData setParamWithKey :@ "AddrState" withValue :@ "YOUR_ADDR_STATE" ];

[ method . paymentData setParamWithKey :@ "Phone" withValue :@ "YOUR_PHONE" ];

[ method . paymentData setParamWithKey :@ "eMail" withValue :@ "YOUR_EMAIL" ];

[ method . paymentData setParamWithKey :@ "ShopID" withValue :@ "YOUR_SHOP_ID" ];

[ method . paymentData setParamWithKey :@ "Subject" withValue :@ "YOUR_SUBJECT" ];

}

} onFailure :^( NSError * error ) {

// do something with the error

}];


  • No labels