---
page_title: Initiating the SDK
product: HyperCredit
platform: Web
page_source: https://juspay.io/in/docs/hyper-credit/web/hyper-explorer/initiating-the-sdk
llms_txt: https://juspay.io/in/docs/llms.txt
product_llms_txt: https://juspay.io/in/docs/hyper-credit/llms.txt
---


# **Initiating the SDK** 



Before making any interface API calls, you must create an instance of the Affordability Explorer on the same page where the SDK script was loaded.


#### Script Code Snippet:

```script
const affordabilityExplorer = new window.AffordabilityExplorer();
```


**Understanding the User Journey** 

The integration flow is divided into two primary phases:

* **Display Widget on Product Page (Exploration):**  The widget is embedded on your product page, enabling users to discover and select an affordability option. Once the user makes a selection, control is handed back to the merchant application.
* **Completing the payment (Checkout):**  The merchant creates the order on their backend and initiates the checkout process, returning control to the user to finalize the payment.


## **1. Display Widget on Product Page (Exploration)** 



Run this script on the product page to display the widget. A div Id shall be passed as a reference where the widget shall be displayed.


#### Script Code Snippet:

```script
affordabilityExplorer.start(processPayload, explorerCallbackHandler)
```



#### **ProcessPayload**  : 



Payload containing product, customer and authentication related information, [Check here for more information.](/hyper-credit/web/hyper-explorer/payload#payload)


#### **explorerCallbackHandler** : 



A merchant shall handle callbacks that will be used to communicate various actions. The callback will be provided in the below format.


#### Script Code Snippet:

```script
explorerCallbackHandler(eventData);
```


Refer to the below page for handling of callbacks [click here.](https://juspay.io/in/docs/hyper-credit/web/hyper-explorer/handling-callbacks#handling-callbacks-exploration)

The `explorerCallbackHandler` will trigger events based on specific user interactions:

* **User Login Required:**  Triggered when a guest interacts with the widget. The merchant application must prompt the user to log in, retrieve their unique Customer ID, and re-initiate the widget display.
* **EMI Plan Selection:**  Triggered when a user selects an EMI plan. This event returns a payload containing the selected plan details, which must be stored and passed during final checkout or order creation.


#### **Updating the Basket** 



If a user adds more items to their cart while on the page, the affordability options must be recalculated. To update the widget, re-initiate the explorer by calling the `start` method again. Ensure the `processPayload` includes the newly added products and the `action` is set to `startWidget`.


#### Script Code Snippet:

```script
affordabilityExplorer.start(processPayload, explorerCallbackHandler);
```



## **2. Completing the payment (Checkout):** 



Session API should be called with the selected emi plan and payment filter in the payload of callback for checkout when the payment needs to be collected once the user completes all the action (Address / Cart confirmation etc.) .

Session API will return a redirection URL which can be opened either in iFrame or in New Tab. After this, the normal checkout journey will continue. [Click here to know more](/hyper-credit/web/checkout-financing/what-youll-integrate#session-api).

---

## See Also

- [Get/Create Customer API](https://juspay.io/in/docs/hyper-credit/web/hyper-explorer/get-create-customer-api)
- [Order Status](https://juspay.io/in/docs/hyper-credit/web/hyper-explorer/order-status)
