Skip to content

Affordability

| View as Markdown

The airpay Affordability Widget lets you showcase affordable payment options like EMI, Cardless EMI, and Pay Later directly on your product pages. Easily customisable and integrated with airpay’s checkout, it enhances your customers’ shopping experience.

Steps

Step 1: Include the JavaScript File
Add the following JavaScript file inside the <head> section of your webpage:
<script type="text/javascript"src=" https://payments.airpay.co.in/widget/affordability/v1/js/affordability.min.js">
</script>
Step 2: Add a Widget Placeholder
Insert a <div> element with a unique id at the location where you want the widget to be displayed:
<div id="widget_id"></div>
Step 3: Initialize the Widget
Use the script below to load and initialize the airpay Affordability Widget:
<script type="text/javascript">
const affordability= new AirpayAffordability(
{
"merchant_id": "18999",
"amount": "2000.00",
"currency": "INR",
"key": "2c95bd5cb720c85634de0267b7ec4345ad20f194",
"merchant_domain": "aHR0cDovL2xvY2FsaG9zdA==",
"styleConfig": {
"backgroundColor": "#ffbf80",
"textColor": "#003366"
},
"buy_now": {
"kit_type": "",
"url": "http://localhost/airpay_php_v2/sendtoairpay2.php",
"additional_params": {
"product_id": "1234",
"product_name": "xyz"
},
"iframeStyle": {
"paymentIframWidth": "400",
"paymentIframHeigt": "400"
}
}
}
);
affordability.init('widget_id');
</script>
ParameterType ValueDescriptionValue Like
merchant_id requiredAlphanumericA unique merchant ID provided by airpay.18999
amount requiredAlphanumericThe payment amount must be specified with exactly two decimal places2000.00
currency requiredAlphanumericThe three-letter currency code following ISO standardsINR
key requiredAlphanumericA secure key provided by airpay to authenticate the merchant.2c95bd5cb720c85634de0267b7ec4345ad20f194
merchant_domain optionalAlphanumericThe merchant’s domain must be Base64 encodedaHR0cDovL2xvY2FsaG9zdA== for http://localhost
StyleConfig.backgroundColor optionalAlphanumericA hex code or color value to customize the widget background#FFFFFF
StyleConfig.textColor optionalAlphanumericA hex code or color value to customize the widget’s text color#000000
buy_now.url optionalAlphanumericTo load the payment page from the widget, specify a redirect URL. airpay will redirect to this URL, where the merchant can integrate the airpay payment logic.
buy_now.kit_type optionalAlphanumericTo load the payment page in an iframe, pass kit_type=IFrame.IFrame
buy_now.additional_params optionalAlphanumericIf any extra parameters are required in the buy_now.url, they should be passed accordingly.
buy_now.IframeStyle.paymentIframWidth optionalAlphanumericSpecify the desired width of the payment iframe500px or 100%
buy_now.IframeStyle.paymentIframHeigt optionalAlphanumericSpecify the desired height of the payment iframe600px or 100%