---
page_title: Checkout flow
product: LotusPay
platform: Web
page_source: https://juspay.io/in/docs/lotuspay/web/lotuspayjs/checkout-flow
llms_txt: https://juspay.io/in/docs/llms.txt
product_llms_txt: https://juspay.io/in/docs/lotuspay/llms.txt
---


# Checkout flow



Building a custom payment page with Element to create NACH Debit eMandates requires these steps:


### Step 1:  Create your payment page


NACH Debit Bank Element is available as part of LotusPay.js. To get started, include the script `<script src="https://js.lotuspay.com/"></script>` on your payment page — it should always be loaded directly from [https://js.lotuspay.com](https://js.lotuspay.com).

To collect the NACH Debit bank details from your customers, Element creates a UI component for you that is hosted by LotusPay. It is then placed into your payment page, rather than you creating it directly. When the customer clicks on the `myLpBtn` button, Element loads as a lightbox on the page.

Here is a sample HTML payment page.


#### html Code Snippet:

```html
<!DOCTYPE html>
<html>

<head>
    <script src="https://js.lotuspay.com/"></script>
    <title>Example</title>
</head>

<body>
    <p>This is an example of a simple HTML page with one paragraph.</p>

    <!-- This button triggers the element, and should have id="myLpBtn" -->
    <button id="myLpBtn">LP elem</button>

    <script>
        const config = {
            // Insert your company name here.
            "name": "Merchant Name",
            // Insert your server mandate creation URL here, which you'll get in Step 2.
            "serverUrl": "http://{your_site}/createMandate.php",
            // Insert `test` for the testing environment and `live` for the live environment.
            "env": "test",
            // Insert URL of your small logo to show in the element.
            "image": "https://s3.ap-south-1.amazonaws.com/js.lotuspay.com/logo.png",
            // Insert the source mandate arguments here. See https://docs.lotuspay.com/ for details.
            "mandateDetails": {
                "amount_maximum": 10800,
                "date_first_collection": "2020-01-01",
                "frequency": "MNTH",
                "creditor_agent_code": "HDFC",
                "creditor_utility_code": "NACH00000000005549"
            },
            // Custom styling can be passed to options when creating an Element.
            "theme": {
                "color": "#0b5a87"
            }
        }
        var lotusPay = new lotusPay(config);
    </script>
</body>

</html>
```





### Step 2: Create a source via the Source API


The customer enters their bank account details in Element and clicks on `SUBMIT`. In the token method, LotusPay.js sends the bank account details in Element directly to LotusPay for bank account token creation and then passes that token into source. In the storage method, Element gives you the unmasked bank account details.

The source details in the page and the bank account details collected in Element are then captured by your server.

Your server runs a script to call the LotusPay Source API for `source` creation, and then passes the whole response to Element. Element sends the customer to the `redirect[url]` and the customer begins the redirect flow to authorise the source.

Here is sample code in PHP.

When creating a source, its status is initially set to `pending`. Your customer must authorise the source for it to create a mandate.


#### Shell Code Snippet:

```shell
<?php

$responseData = request();
header('Content-type:application/json;charset=utf-8');
header('Access-Control-Allow-Origin: *');
echo $responseData;

function request() {
    $url = "https://api-test.lotuspay.com/v1/sources";
    // $returnUrl= "https://www.themerchantreturnUrl.com";
    $mandate_details =$_POST["mandate_details"];
    $bank_data =$_POST["bank_data"];
    error_log(print_r($_POST, TRUE));

    $nach_debit;
    $redirect;

    $nach_debit["amount_maximum"]=$mandate_details["amount_max"];
    $nach_debit["date_first_collection"]=$mandate_details["date_first_collection"];
    $nach_debit["frequency"]=$mandate_details["frequency"];

    $nach_debit["creditor_utility_code"]=$mandate_details["creditor_utility_code"];
    $nach_debit["creditor_agent_code"]=$mandate_details["creditor_agent_code"];


    $nach_debit["debtor_agent_code"]=$bank_data["ifsc"];   
    $nach_debit["debtor_account_name"]=$bank_data["debtor_account_name"];
    $nach_debit["debtor_account_number"]=$bank_data["debtor_account_number"];
    $nach_debit["debtor_account_type"]=$bank_data["debtor_account_type"];
    $redirect["return_url"]="https://www.lotuspay.com";
    $merchantkey = "sk_test_yGwM9BTxoXOp1wLl7QphSew3";
    $type="nach_debit";


    $data["nach_debit"]=$nach_debit;
    $data["redirect"]= $redirect;
    $data["type"]= $type;

    $final_payload = http_build_query($data);

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_USERPWD, $merchantkey.":");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $final_payload);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);// this should be set to true in production
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $responseData = curl_exec($ch);
    error_log(print_r($responseData, TRUE));
    if(curl_errno($ch)) {
        return curl_error($ch);
    }
    curl_close($ch);
    return $responseData;
}
?>
```




---

## See Also

- [NACH Debit Bank Element](https://juspay.io/in/docs/lotuspay/web/lotuspayjs/nach-debit-bank-element)
- [Other Information](https://juspay.io/in/docs/lotuspay/web/lotuspayjs/other-information)
