iOS SDK Integration Steps

OPEN Android SDK lets you seamlessly integrate OPEN Payment Gateway with your iOS app and start collecting payments from your customers

Create a payment_token

A payment token represents an order or a purchase. The first step to open up a Layer payment page on your website or checkout page is to create a payment_token

A payment_token can be created by referring to create payment token API. This API should be always called from your server. You will receive payment_token as a response from create payment token API.

Step 1 :

Add a framework in your iOS Project

Step 2 :

Framework Setup -

  • Select .xcodeproj file in Xcode
  • Select your target
  • Select general
  • Scroll down to framework section
  • Select Embed & Sign In Embed Column of Framework section

Step 3 :

App Setup -
In the iOS app, make any ViewController where you want to implement payment integration.

Initializing LayerPayment :
You can see below code, these are minimum and mandatory calls to enable payment processing. If any of it is missed then an error will be generated.

For example, consider parameters as follows.

let layerPayment = LayerPayment(paymentToken: "paymentToken",
                                accessKey: "yourAccessKey", 
                                environment: NetworkEnvironment.Live)

layerPayment.setBaseViewController(self)

Calls and Descriptions :

paymentToken : Mandatory to create the token using Create Token API.

environment: We have 2 environments.
Following ENUM can be passed to this method.
NetworkEnvironment.Sandbox
NetworkEnvironment.Live

accessKey: access_key is a unique key which you can generate from your Open dashboard.

Step 4 :

Implement Delegate -
To start the payment, first set LayerPayment delegate to get payment status

layerPayment.delegate = self

Step 5 :

Proceed to Payment -
To start the payment, just call startPayment() method of LayerPayment and after that transaction will get started.

layerPayment.startPayment()

Description :
onPaymentCompleted() - This method is invoked when a transaction is completed. It may either captured, failed , pending and cancelled

onPaymentError(): - Integration errors.

Getting Transaction Details

To get details of transactions, we have a callback method onPaymentCompleted() with a parameter of TransactionDetails.

To get details, below method of TransactionDetails are useful :

transactionDetails.paymentId
transactionDetails.paymentTokenId
transactionDetails.status

Call the webhook URL to get the complete response of the transactions.