The Checkout SDK provides a convenient way for developers to integrate and interact with various APIs related to checkout and payment processing. This documentation will guide you through the usage of the Checkout class and its associated methods.
- You can refer to the Nimbbl Sonic Shop to learn how the SDK has been integrated. Nimbbl Sonic Shop
- View Demo Shop in action at https://sonicshop.nimbbl.tech/ :::
Compatibilities and Dependencies
- Node version
18.x.x
or higher.
Install Nimbbl Sonic Checkout
$ npm i nimbbl_sonic --save
Import / Add the Checkout library
Import the nimbbl_sonic library to your file where checkout will be initiated.
import Checkout from "nimbbl_sonic";
Launching the Nimbbl Checkout
Checkout Class
The Checkout class is the main module of the SDK, providing access to different APIs related to checkout and payment processing. It contains methods for authentication, working with banks, payment processing, order management, and more.
Note: Create order using
/v3/create-order
api
import Checkout from "nimbbl_sonic";
const launchNimbblSonicCheckout = async () => {
try {
// data will be stored here from create order api
const responseFromCreateOrderAPI = await response.json();
// pass the token we get from create order to this Checkout Constructor
const checkout = new Checkout({
token: responseFromCreateOrderAPI.token,
});
await checkout.open({
// pass `callback_handler` if you want to open the Sonic Checkout in a modal.
callback_handler: function (response) {
alert(response);
},
// pass `callback_url` and `redirect` if you want to open Sonic Checkout in the same window.
callback_url: string
redirect: boolean // true should be passed in case of redirection
// 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,
});
} catch (error) {
// handle error
console.error("Error:", error.message);
}
};
Properties related to Payment Mode
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.
Properties | Type | Mandatory? | Description |
---|---|---|---|
payment_mode_code | string | false | In 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_code | string | false | Only 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_code | string | false | Only 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_flow | string | false | Only 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_id | string | false | Only 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_code | string | false | Only 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 |
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){
/**
* send the response to your server for processing
* /
}
Checkout with Callback URL
When you use a Callback URL with redirect true, you will redirected to that callback_url
with a base64 encoded payload response appended to it.
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.
- 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 :::