- XCode 13 or newer
A payment token represents an order or a purchase. The first step to open a Layer payment page on your website or checkout page is to create a
payment_token can be created by referring to the create payment token API. This API should always be called from your server. You will receive
payment_token as a
response from the create payment token API.
OpenPayment is available through CocoaPods. To install it, simply add the following line to your Podfile:
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.
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)
|setAccessKey()||(Y)||Access key is a unique key which you can generate from your Open dashboard.|
|setEnvironment()||(Y)||Following ENUM can be passed to this method. .SANDBOX .LIVE|
|setPaymentToken()||(Y)||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|
To start the payment, first set OpenPayment delegate to get payment status
openPaymentOBj.delegate = self
To start the payment, just call startPayment() method of OpenPayment and after that transaction will get started.
onPaymentCompleted() - This method is invoked when a transaction is completed. It may either captured, failed , pending and cancelled.
onPaymentError(): - Integration errors.
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 :
Call the webhook URL to get the complete response of the transactions.