Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Note

→ Updated version will be provided end of 2023


Table of Contents
maxLevel6

...

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

...

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


 4.How to implement


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

...

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

...

[[ 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

}];


The values of Amount and Currency will be validated during the checkout process. So you have to ensure that you are using valid data.

...

The amount is the lowest unit of the currency you are using. That means if you are using EUR as currency, the amount needs to be in cents, e.g. an amount of 100 is 1 EUR.


URLSuccess and URLFailure are the URL’s to which the SDK redirect the status of a payment process. These URL’s normally point to a HTML site on your merchant backend toshow the status to the user of your app.

...

In the demo project, the payment methods are presented in a tableView, including ApplePay. In the following code snippet is demonstrated the population of a cell, providing a title and an image of the respective payment method.


PaymentMethodTableViewCell * cell = [ self . tableView

dequeueReusableCellWithIdentifier :@ "PaymentMethodTableViewCell" forIndexPath : indexPath ];

AxeptaPaymentMethod * paymentMethod = [[ self paymentMethods ]

objectAtIndex : indexPath . row ];

cell . labelTitle . text = paymentMethod . localizedDescription;

[ cell . paymentImageView setImage : paymentMethod . image ];


4.3.4.Checkout


After the configuration of the SDK is completed and all necessary payment data are imported, you can proceed with the checkout for a selected payment method.

Start the checkout by instantiating a AxeptaCheckout object. The AxeptaCheckout class is a top-level class that facilitates the payment procedure. It is responsible for validating payment data and instantiating a AxeptaCheckoutViewController object when a new payment is triggered by passing the respective paymentMethod including the paymentData .


AxeptaCheckout * checkout = [[ AxeptaCheckout alloc ] init ];


Proceed with the checkout by presenting a AxeptaCheckoutViewController which is a subclass of UIViewController encapsulating all the views’ stack.


AxeptaPaymentMethod * paymentMethod = [[ self paymentMethods ]

objectAtIndex : indexPath . row ];

[ self . checkout instantiateCheckoutViewControllerWithPaymentMethod : paymentMethod

onSuccess :^( AxeptaCheckoutViewController

* checkoutViewController ) {

checkoutViewController . delegate = self;

// show the new chekoutViewController

// maybe push it on navigation stack

} onFailure :^( NSError * error ) {

// handle the error

}];


Receive results from checkout by conforming to AxeptaCheckoutViewControllerDelegate and implementing its methods:


- ( void ) checkoutDidAuthorizePaymentForPaymentData :( id < AxeptaPaymentDataProtocol >) paymentData

withResponse :( AxeptaPaymentRespose *) response

-

( void ) checkoutDidFailToAuthorizePaymentForPaymentData :( id < AxeptaPaymentDataProtocol >) paymentData

withError :( NSError *) error withResponse :( AxeptaPaymentRespose *) response

- ( void ) checkoutDidCancelForPaymentData :( AxeptaPaymentData *) paymentData;



4.4.Apple Pay


4.4.1.Configuration

...

  • To enable Apple Pay for your app in XCode, open the Capabilities pane. Select the switch in the Apple Pay row, and then select the merchant ID you want the app to use.

  • Insert “ Merchant ID ” in the AppDelegate.


#import "AppDelegate.h"

#import <Axepta.h>

@implementation AppDelegate

- ( BOOL ) application :( UIApplication *) application

didFinishLaunchingWithOptions :( NSDictionary *) launchOptions

{

AxeptaConfiguration . merchantAppleID = @ "YOUR_MERCHANT_ID";

return YES;

}

@end


4.4.1.3. Testing Apple Pay transactions


Use the Apple Pay Sandbox environment to test your transactions with test payment cards.

...

Start Apple Pay by instantiating a AxeptaApplePay object. The AxeptaApplePay class is a top-level class that facilitates the Apple Pay payment procedure. It is responsible for validating payment data and instantiating a PKPaymentAuthorizationViewController object when a new payment is triggered by passing the respective paymentData and paymentMethod .


AxeptaApplePay * applePay = [[ AxeptaApplePay alloc ] init ];

applePay . delegate = self;


Setup PKPaymentSummaryItem objects:


PKPaymentSummaryItem * paymentSummaryItem1 = [[ PKPaymentSummaryItem alloc ] init ];

paymentSummaryItem1 . label = @ "SUMMARY_ITEM_1_LABEL";

paymentSummaryItem1 . amount = 'SUMMARY_ITEM_1_AMOUNT';

PKPaymentSummaryItem * paymentSummaryItem2 = [[ PKPaymentSummaryItem alloc ] init ];

paymentSummaryItem2 . label = @ "SUMMARY_ITEM_2_LABEL";

paymentSummaryItem2 . amount = 'SUMMARY_ITEM_2_AMOUNT';

PKPaymentSummaryItem * paymentSummaryItemTotal = [[ PKPaymentSummaryItem alloc ] init ];

paymentSummaryItemTotal . label = @ "Total";

paymentSummaryItemTotal . amount = 'TOTAL_AMOUNT';


Present the PKPaymentAuthorizationViewController :


AxeptaPaymentMethod * applePayPaymentMethod = [[ Axepta sharedInstance ]

paymentMethodForID : @ "pm_applepay" ];

NSArray * supportedNetworks = @[ PKPaymentNetworkVisa , PKPaymentNetworkMasterCard ,

PKPaymentNetworkAmex , PKPaymentNetworkDiscover ];

[ self . applePay

instantiatePKPaymentAuthorizationViewControllerWithPaymentMethod : self . paymentData

withPaymentSummaryItems : /*your array with PaymentSummaryItems*/

withSupportedNetworks : supportedNetworks

withRequiredShippingAddressFields : self . selectedPKShipping

paymentAuthorizationViewController :^( PKPaymentAuthorizationViewController

* applePayViewController ) {

// show apples pay view controller

[ self presentViewController : applePayViewController

animated : true

completion : nil ];

} onFailure :^( NSError * error ) {

// handle the error

}];


AxeptaApplePayDelegate


Implement AxeptaApplePayDelegate protocol’s methods in order to get notified of navigation actions and on ApplePay payment’s result:


- ( void ) applePayDidDismiss {

}

-

( void ) applePayDidAuthorizePaymentForPaymentData :( id < AxeptaPaymentDataProtocol >) paymentDa

ta withResponse :( AxeptaPaymentRespose *) response {

}

-

( void ) applePayDidFailToAuthorizePaymentForPaymentData :( id < AxeptaPaymentDataProtocol >) pay

mentData withError :( NSError *) error withResponse :( AxeptaPaymentRespose *) response {

}

- ( void ) applePayPaymentDidSelectPaymentMethod :( PKPaymentMethod *) paymentMethod

completion :( void (^)( NSArray < PKPaymentSummaryItem *> *)) completion {

}

- ( void ) applePayPaymentDidSelectShippingContact :( PKContact *) contact completion :( void

(^)( PKPaymentAuthorizationStatus , NSArray < PKPaymentSummaryItem *> *)) completion {

}



4.4.3. iOS Human Interface Guidelines

...

For making payments with WeChat developer should use WeChat class with the public method: startPaymentWithPaymentData.


AxeptaWeChat *weChat = [[ AxeptaWeChat alloc ] init ];

[weChat startPaymentWithPaymentData :paymentMethod

success :^( NSData *data) {

} failure :^( NSError *error) {

}];



4.6. PayPal


Developer first should declare the scheme that he will use to return to the merchant App.

...


It is important to use the values return and cancel as path segments for success and failure.

...

To respond to requests made to the custom URL type, the application openURL method must be implemented in the application delegate. The openURL method should send a notification to Axepta in order to complete or cancel the PayPal checkout. The notification keys must be same as follows:


- ( BOOL )application:( UIApplication *)application openURL:( NSURL *)url

sourceApplication:( NSString *)sourceApplication

annotation:( id )annotation {

if ([url. scheme localizedCaseInsensitiveCompare : @"com.merchant.MerchantApp.PayPalReturn" ]

== NSOrderedSame ) {

if ([url. host localizedCaseInsensitiveCompare : @"return" ] == NSOrderedSame ) {

NSNotificationCenter * nc = [ NSNotificationCenter defaultCenter ];

[nc postNotificationName : @"completePayPalCheckout" object : self userInfo : nil ];

}

else {

NSNotificationCenter * nc = [ NSNotificationCenter defaultCenter ];

[nc postNotificationName : @"cancelPayPalCheckout" object : self userInfo : nil ];

}

NSLog ( @"%@" , url. host );

return YES ;

}

return NO ;

}


Important note : Developer should add to main project -l"PPRiskComponent" under the Build settings → Other linker flags the Magnes library used by Axepta.

...

Since the Magnes library requires the location to send the payload risk to PayPal developer should activate it under info.plist by adding Privacy - Location When In Use Usage Description and some description text.

...

To init PayPal and call the payment method developer should use the following code:


AxeptaayPal *payPal = [[ AxeptaayPal alloc ] init ];

[payPal startPaypalPay :paymentMethod

success :^( NSData *data) {

//Handle the succes

} failure :^( NSError *error) {

//Handle the failure

}];