Skip to main content

Our Checkout library provides a simple integration with your website to accept payments. You can open our checkout either as a popup modal window above your page or can simply redirect to our checkout and get control back using a callback URL.

SAMPLE EXPERIENCE
  • To see our checkout in action you can click here and perform a live transaction.
  • Both the popup modal window and redirect experiences are available for you to try out.

Compatibilities and Dependencies

  1. Works for all modern browsers

Import / Add the Checkout library

Import the Nimbbl's Checkout JSSDK in your HTML file within the <head> tag using the defer attribute to ensure it loads asynchronously in each place where you intent to launch the checkout.

  <script defer type="module">
import Checkout from "https://cdn.jsdelivr.net/npm/nimbbl_sonic@latest";
</script>

Initialize Checkout

Initialize the Checkout class by providing your unique token obtained from previous step. This step should be performed on the same page where you intend to launch the checkout.

Option PropertiesTypeMandatory?Description
tokenstringtrueThis would have been generated from your server during order creation using V3 create-order API.
  <script defer type="module">
import Checkout from "https://cdn.jsdelivr.net/npm/nimbbl_sonic@latest";
const checkout = new Checkout({ token: "your_token_here" });
</script>

Launching the Nimbbl Checkout

Understanding Checkout Options

Read more about options object and its properties below.

Nimbbl provides you with two ways of receiving the response from SDK. This mode also determines the way in which your checkout is launched. One of the mode is, callback_handler which launches the Nimbbl Checkout within a popup modal window, alternative to this we have callback_url where the Checkout opens in the same window by redirecting users away from your page.

Option PropertiesTypeMandatory?Description
callback_handlerstringRequired if callback_url is not passed.Handler Function will open Nimbbl checkout in a popup modal window. On successful or failure payment, customer will get the json response with status.
callback_urlstringRequired if callback_handler is not passed.Checkout opens in the same window by redirecting away from your page. On successful or failure payment, customer will be redirected to the specified Callback URL, for example, a payment success page.

Nimbbl lets you enforce a payment mode on the Checkout. This can be done by passing the payment_mode_code property. There are other related properties in to each different payment mode, you can read it in the table below. If you don't pass payment_mode_code the consumer is shown the full Checkout with all available payment modes.

Option PropertiesTypeMandatory?Description
payment_mode_codestringfalseIn case of specific payment mode, this property is mandatory. Possible values net_banking, card, upi, wallet. If you don't pass payment_mode_code the consumer is shown the full Checkout with all available payment modes.
bank_codestringfalseOnly to be passed in case of net_banking. Example: hdfc. To get the full list of banks supported for you, please use this API. If it isn't passed, Checkout will open with a page for the user to choose their bank from enabled banks
wallet_codestringfalseOnly to be passed in case of wallet. Example: jio_money. To get the full list of wallets supported for you, please use this API. If it isn't passed, Checkout will open with a page for the user to choose their wallet from enabled wallets
payment_flowstringfalseOnly to be passed in case of upi to determine the flow. Possible values collect, intent. If it isn't passed, Checkout will open with page for the user to enter their UPI ID or pay using a QR or choose a UPI app
upi_idstringfalseOnly to be passed in case of upi and payment_flow is collect. It is the UPI ID of the customer. Example:wonderwoman@ybl. Checkout will open with the transaction initiated for the upi id passed in the upi_id field. If it isn't passed, Checkout will open with page for the user to enter their UPI ID
upi_app_codestringfalseOnly to be passed in case of upi and payment_flow is intent. Possible values phonepe, gpay. Checkout will open with the transaction initiated for the upi app passed in the upi_app_code field. If it isn't passed, Checkout will show a UPI QR or prompt user to choose a UPI app

Setting the Checkout Options

Set all the relevant properties for your use case in the options object as shown below

var options = {
// pass `callback_handler` if you want to open the Checkout in a popup modal.
callback_handler: function (response) {
alert(response);
},

// only if you want to enforce a specific payment method
payment_mode_code: string,
bank_code: string,
wallet_code: string,
payment_flow: string,
upi_id: string,
upi_app_code: string,
};

Invoking the Checkout

Finally, after setting up the options object with respective parameters, we can now invoke checkout by accessing checkout method.

checkout.open(options);

Capture Transaction Response

The final step in completing the client integration is capturing the response and sending it to your server

Checkout with Handler Function

If you used the sample code with the handler function, then:

"callback_handler": function (response){
// Process the response here and
// send the response to your server for processing
}

Checkout with Callback URL

Provided below is a detailed example that demonstrates all the code that you need to do to accept payments on your web page. Please note this example covers the popup modal flow using the callback_handler.

callback_url?response=base64_payload

You will need to decode the base64 payload. To learn how to decode the payload, you can refer here. The decoded response will need to be sent to your server.

Summary of Changes

Provided below is a detailed example that demonstrates all the code that you need to do to accept payments on your web page. Please note this example covers the popup modal flow using the callback_handler.

  • Integration: To integrate Nimbbl Checkout, include the provided script tag in the head section of your HTML document. This script asynchronously imports the Nimbbl Checkout module from the CDN.
  • Initialization: Create a new instance of the Nimbbl Checkout class with your authentication token.
  • Configuration: Define payment options such as callback handler, payment mode code, bank code, wallet code, payment flow, UPI ID, and UPI app code.
  • Opening Checkout: Call the open() method on the Checkout instance with the configured options to open the checkout.
  • Capturing Response: To finalize client integration, capture transaction response and forward it to your server. If utilizing a handler function, process the response within it. For callback URL usage, decode the base64 payload and transmit the decoded response to your server for processing.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Your_Site_Title</title>
</head>
<body>

<script defer type="module">
import Checkout from "https://cdn.jsdelivr.net/npm/nimbbl_sonic@latest";
const checkout = new Checkout({ token: "your_token_here" });

var options = {
callback_handler: function (response) {
// Process the response here and
// send the response to your server for processing
},
payment_mode_code: "your_payment_mode_code",
bank_code: "your_bank_code",
wallet_code: "your_wallet_code",
payment_flow: "your_payment_flow",
upi_id: "your_upi_id",
upi_app_code: "your_upi_app_code",
};

checkout.open(options);
</script>
</body>
</html>
IMPORTANT
  • Share the response parameters received to your server
  • This will need to be validated on your server before you decide to provide goods or services
  • More details available on processing the response in Completing the Integration