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 openPaymentBuilderObj = OpenPaymentBuilder()
    openPaymentBuilderObj.setAccessKey("accessToken")
    openPaymentBuilderObj.setEnvironment(.Sandbox)
    openPaymentBuilderObj.setPaymentToken("paymentToken") 
    openPaymentBuilderObj.setErrorColor("colorhexcode") // Optional
    openPaymentBuilderObj.setLogoUrl("Your LogoURL") // Optional
    openPaymentBuilderObj.setBgColor("colorhexcode") // Optional
let openPaymentOBj = openPaymentBuilderObj.buildObject()
    openPaymentOBj.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.
.Sandbox
.Live

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

setBgColor(): Main color of Layer will be changed to this . Example: #f8c5c5
Note : Only accepts hex code colors. Default color is applied if this key does not exist or proper value has not been passed.

setErrorColor(): Error color (icons/ error lines / error messages) of Layer will be changed to this . Example: #83025c
Note : Only accepts hex code colors. Optional key parameter. Default color is applied if this key does not exist or proper value has not been passed.

setLogoUrl(): Logo is changed to image source passed.
Note : If image source is not available, default Open logo will be used. Image might take time to
load depending on size of the image.

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.