Integrate OPEN Payment Gateway with your iOS app and start collecting payments from your customers.
- XCode 13 or newer
- Cocoapods
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.
OpenPayment is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'OpenPayment'then run
pod installYou 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.
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)
| Method | Mandatory | Description |
|---|---|---|
| setAccessKey() | ✔ | Access key is a unique key which you can generate from your Open dashboard. |
| setEnvironment() | ✔ | Following ENUM can be passed to this method. .SANDBOX .LIVE |
| setPaymentToken() | ✔ | To create the token using Create Payment Token API. |
| setErrorColor() | Error color (icons/ error lines / error messages) of Layer will be changed to this . Example: #83025c | |
| setLogoUrl() | Logo is changed to image source passed. | |
| setBgColor() | Main color of Layer will be changed to this . Example: #f8c5c5 |
openPaymentOBj.delegate = self
To start the payment, just call startPayment() method of OpenPayment and after that transaction will get started.
openPaymentOBj.startPayment()
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.
To support UPI and other payment apps, add the following entry to your app's Info.plist:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>gpay</string>
<string>paytmmp</string>
<string>phonepe</string>
<string>bhim</string>
<string>amazonpay</string>
<string>payzapp</string>
<string>icici</string>
<string>axisbank</string>
<string>sbi</string>
<string>kotak</string>
<string>federal</string>
<string>yesbank</string>
<string>idfcbank</string>
<string>indus</string>
<string>pnb</string>
<string>ikwik</string>
<string>axispay</string>
<string>idfcup</string>
<string>kotak811</string>
<string>cred</string>
</array>
OpenPayment is available under the MIT license.