---
page_title: Create an Order to Open Payment Page
product: SmartGateway SDK Integration
platform: Web
page_source: https://smartgateway.hdfc.bank.in/docs/hypercheckout-mobile-sdk/web/how-to-integrate-sdks/create-an-order-to-open-payment-page
llms_txt: https://smartgateway.hdfc.bank.in/docs/llms.txt
product_llms_txt: https://smartgateway.hdfc.bank.in/docs/hypercheckout-mobile-sdk/llms.txt
---


# Create an Order to Open Payment Page




### Step 1 Add Session Create function in your backend


Expose `/initiateJuspayPayment` API endpoint in your backend that calls the `Create` function of nodejs SDK. This API endpoint will be called from your frontend to open the payment page.

For ease of implementation, you can refer to order session function from ‘index.js’ file and update the following parameters:


| First Column | Second Column | Third Column |
|---|---|---|
| order_id | Mandatory | Each order created by Merchant in Smartgateway's System is identified via a Unique Order ID, which should be:  1. Should be less than 21 Characters length 2. Should not contain any Special Characters 3. Can be Alphanumeric 4. Should be Non-Sequential.  |
| customer_id | Optional | It is the unique ID with which merchant refers to a customer object.  This id is used to access the stored payment methods, allow EMI transactions and setup subscriptions. In case of guest login it should be an empty string. |
| amount | Mandatory | Amount that the customer has to pay. Will accept stringified double or integer values with upto two decimal places (Example: "100.15" and "100" are valid input but "100.1532" is not valid) |
| return_url | Optional | A fully qualified URL on which the customer will be redirected after payment completion |
| payment_page_client_id | Mandatory | For Sandbox, add 'hdfcmaster' as your client_id |
| merchant_id | Optional | Add the Merchant_ID provided by the bank |


> **Warning**
> Please update ‘merchant_id’ and ‘customer_id’ in both ‘$params’ and ‘$requestOption’ variables





#### Code Snippets: -

#### NodeJS Code Snippet:

```nodejs
app.post('/initiateJuspayPayment', async (req, res) => {
    const orderId = `order_${Date.now()}`
    const amount = 1 + Math.random() * 100 | 0

    // makes return url
    const returnUrl = `${req.protocol}://${req.hostname}:${port}/handleJuspayResponse`

    try {
        const sessionResponse = await juspay.orderSession.create({
            order_id: orderId,
            amount: amount,
            payment_page_client_id: paymentPageClientId,                    // [required] shared with you, in config.json
            customer_id: 'hdfc-testing-customer-one',                       // [optional] your customer id here
            action: 'paymentPage',                                          // [optional] default is paymentPage
            return_url: returnUrl,                                          // [optional] default is value given from dashboard
            currency: 'INR'                                                 // [optional] default is INR
        })

        // removes http field from response, typically you won't send entire structure as response
        return res.json(makeJuspayResponse(sessionResponse))
    } catch (error) {
        if (error instanceof APIError) {
            // handle errors comming from juspay's api
            return res.json(makeError(error.message))
        }
        return res.json(makeError())
    }
})
```



### Step 1 Add Session Create function in your backend


Expose `/initiateJuspayPayment` API endpoint in your backend that calls the `Create` function of PHP SDK. This API endpoint will be called from your frontend to open the payment page.

For ease of implementation, you can refer to session( ) function from ‘Program.php’ file and update the following parameters:


| Parameters | Type  | Description |
|---|---|---|
| order_id | Mandatory  | Each order created by Merchant in Smartgateway's System is identified via a Unique Order ID, which should be:  1. Should be less than 21 Characters length 2. Should not contain any Special Characters 3. Can be Alphanumeric 4. Should be Non-Sequential.  |
| customer_id | Optional | It is the unique ID with which merchant refers to a customer object.  This id is used to access the stored payment methods, allow EMI transactions and setup subscriptions. In case of guest login it should be an empty string. |
| amount | Mandatory | Amount that the customer has to pay. Will accept stringified double or integer values with upto two decimal places (Example: "100.15" and "100" are valid input but "100.1532" is not valid) |
| return_url | Optional  | A fully qualified URL on which the customer will be redirected after payment completion |
| payment_page_client_id | Mandatory  | For Sandbox, add 'hdfcmaster' as your client_id |
| merchant_id  | Optional   | Add the Merchant_ID provided by the bank |


> **Warning**
> Please update ‘merchant_id’ and ‘customer_id’ in both ‘$params’ and ‘$requestOption’ variables





#### Code Snippets: -

#### PHP Code Snippet:

```php
public function session() {
        try {
            $params = array();
            $params['amount'] = 1;
            $params['order_id'] = $this->orderId;
            $params["merchant_id"] = $this->config["MERCHANT_ID"]; # Add merchant id
            $params['customer_id'] = "testing-customer-one";
            $params['payment_page_client_id'] = $this->config["MERCHANT_ID"];
            $params['action'] = "paymentPage";
            $params['return_url'] = "http://0.0.0.0:5000/handleResponse";
            $requestOption = new RequestOptions();
            $requestOption->withCustomerId("testing-customer-one");
            $session = OrderSession::create($params, $requestOption);
            echo "id: " . $session->id . PHP_EOL;
            echo "order id: ". $session->orderId . PHP_EOL;
            echo "status" . $session->status . PHP_EOL;
            echo "payment link: " . $session->paymentLinks["web"] . PHP_EOL;
            echo "sdk payload" . json_encode($session->sdkPayload) . PHP_EOL;
        } catch ( JuspayException $e ) {
            echo "error code" . $e->getHttpResponseCode() . PHP_EOL;
            echo "error message: " . $e->getErrorMessage() . PHP_EOL;
            echo "error code" . $e->getErrorCode() . PHP_EOL;
        }
    }
```



### Step 1 Add OrderSession.Create() function in your backend


Expose `/initiateJuspayPayment` API endpoint on your server that calls the `OrderSession.create()` function of Java SDK. This API endpoint will be called from your frontend to open the payment page.

For ease of implementation, you can refer to `InitiateJuspayPayment` class and update the following parameters:


| Parameter | Type  | Description |
|---|---|---|
| order_id | Mandatory  | Each order created by Merchant in Smartgateway's System is identified via a Unique Order ID, which should be:  1. Should be less than 21 Characters length 2. Should not contain any Special Characters 3. Can be Alphanumeric 4. Should be Non-Sequential.  |
| customer_id | Optional  | It is the unique ID with which merchant refers to a customer object.  This id is used to access the stored payment methods, allow EMI transactions and setup subscriptions. In case of guest login it should be an empty string. |
| payment_page_client_id | Mandatory  | For Sandbox, add 'hdfcmaster' as your client_id |
| amount | Mandatory  | Amount that the customer has to pay. Will accept stringified double or integer values with upto two decimal places. (Example, "100.15" and "100" are valid input but "100.1532" is not valid) |
| return_url | Optional  | A fully qualified URL on which the customer will be redirected after payment completion |
| merchant_id  | Optional  | Add the Merchant_ID provided by the bank |


> **Warning**
> Please update ‘customer_id’ in both ‘params’ and ‘requestOptions’ variables





#### Code Snippets: -

#### Java Code Snippet:

```java
public class InitiateJuspayPayment extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        String orderId = "order_" + UUID.randomUUID().toString().substring(12);
        int amount = new Random().nextInt(100) + 1;

        String serverName = req.getServerName();
        int serverPort = req.getServerPort();
        String contextPath = req.getContextPath();

        String paymentPageClientId = JuspayConfig.payment_page_client_id;
        String customerId = "hdfc-testing-customer-one";
        String scheme = req.getScheme();
        String returnUrl = scheme + "://" + serverName + ":" + serverPort + contextPath + "/handleJuspayResponse";

        try {
            Map<String, Object> params = new LinkedHashMap<>();
            params.put("order_id", orderId);
            params.put("payment_page_client_id", paymentPageClientId);
            params.put("amount", amount);
            params.put("customer_id", customerId);
            params.put("action", "paymentPage");
            params.put("return_url", returnUrl);
            params.put("currency", "INR");
            RequestOptions requestOptions = RequestOptions.createDefault().withCustomerId(customerId);
            OrderSession orderSession = OrderSession.create(params, requestOptions);
            resp.setStatus(HttpServletResponse.SC_OK);
            resp.setContentType("application/json");
            String responseString = new Gson().toJson(orderSession);
            resp.getWriter().write(responseString);
        } catch (JuspayException e) {
            e.printStackTrace();
            resp.setStatus(e.getHttpResponseCode());
            resp.setContentType("application/json");
            resp.getWriter().write(makeErrorMsg(e.getErrorMessage()));
        }
    }

    private String makeErrorMsg(String msg) {
        return "{\n  \"message\": \"" + msg + "\"\n}";
    }
}
```



### Step 1 Add OrderSession( ) function in your backend


Expose `/initiateJuspayPayment` API endpoint on your server that calls the `OrderSession()` function of .NET SDK. This API endpoint will be called from your frontend to open the payment page.

For ease of implementation, you can refer to `OrderSession()` class and update the following parameters:


| Parameter | Type | Description |
|---|---|---|
| orderId | Mandatory | Each order created by Merchant in Smartgateway's System is identified via a Unique Order ID, which should be:  1. Should be less than 21 Characters length 2. Should not contain any Special Characters 3. Can be Alphanumeric 4. Should be Non-Sequential.  |
| customerId | Optional | It is the unique ID with which merchant refers to a customer object.  This id is used to access the stored payment methods, allow EMI transactions and setup subscriptions. In case of guest login it should be an empty string. |
| amount | Mandatory | Amount that the customer has to pay. Will accept stringified double or integer values with upto two decimal places. (Example, "100.15" and "100" are valid input but "100.1532" is not valid) |
| payment_page_client_id | Mandatory | For Sandbox, add 'hdfcmaster' as your client_id |
| return_url | Optional | A fully qualified URL on which the customer will be redirected after payment completion |


> **Warning**
> Please update ‘customerId’ in both ‘CreateOrderSessionInput’ and ‘requestOptions’ variables





#### Code Snippets: -

#### .NET Code Snippet:

```.net
string orderId = $"order_{new Random().Next()}";
                int amount = new Random().Next(0, 100);
                string customerId = "testing-customer-one";
                RequestOptions requestOptions = new RequestOptions{ CustomerId = customerId };
                CreateOrderSessionInput createOrderSessionInput = new CreateOrderSessionInput(new Dictionary<string, object>{{ "amount", amount}, { "order_id",  orderId}, { "customer_id", customerId }, { "payment_page_client_id", Init.Config.PaymentPageClientId }, { "action", "paymentPage" }, { "return_url", "http://localhost:5000/handleJuspayResponse" } });
                JuspayResponse sessionRes = new OrderSession().Create(createOrderSessionInput, requestOptions);
                Dictionary<string, object> res = new Dictionary<string, object> {
                    { "orderId", sessionRes.Response.order_id },
                    { "id", sessionRes.Response.id },
                    { "status", sessionRes.Response.status },
                    { "paymentLinks", sessionRes.Response.payment_links },
                    { "sdkPayload", sessionRes.Response.sdk_payload },
                };
```



### Step 2 (Optional) Additional params for Order Session function


You may add these below mentioned **optional params**  in your order session function added in the previous step as per your usecase:


| Parameters | Description |
|---|---|
| customer_email | Email address of the customer. If the backend gateway requires it, then you must send this value. |
| customer_phone | Mobile number or fixed line number of the customer. If the backend gateway requires it, then you must send this value. We recommend passing a 10-digit number without including the "+91" or any mobile country code at the beginning. |
| first_name | First Name of customer. This value will be used for customer identification. |
| last_name | Last name of customer. This value will be used for customer identification. |
| description | Description for order to be displayed to the user on amountBar. |
| currency | Currency for the order. It should only be passed when supported by the Payment Gateway and enabled in the SmartGateway Dashboard within EC Operations → PGCC → Select PG → Edit → Supported Currencies. |
| udf1, udf2, udf3, udf4, udf5 (No Special Characters Supported) | User Defined Parameter (UDF) field can be used to send any user defined parameters and it can be seen in the SmartGateway dashboard under each order. Example - abc5349       |
| udf6, udf7, udf8, udf9, udf10 (Special Characters Supported) | User Defined Parameter (UDF) field can be used to send any user defined parameters and it can be seen in the SmartGateway dashboard under each order. Example - abc5349       |




> **Note**
> Please pass parameters given above in **String**  format




### Sample Response




#### Sample Response of OrderSession.create Function Code Snippet:

```sample response of ordersession.create function
{
  "status": "NEW",
  "id": "ordeh_xxxxxxxxxxxxxxxxxxxx",
  "order_id": "testing-order-one",
  "payment_links": {
      "web": "https://smartgateway.hdfcuat.bank.in/merchant/ipay/ordeh_57dfd768bb7d4896bc042y0b90bc9ad77/payment-page"
  },
  "sdk_payload": {
      "requestId": "12398b5571d74c3388a74004bc24370c",
      "service": "in.juspay.hyperpay",
      "payload": {
          "clientId": "yourClientId",
          "amount": "1.0",
          "merchantId": "yourMerchantId",
          "clientAuthToken": "tkn_xxxxxxxxxxxxxxxxxxxxx",
          "clientAuthTokenExpiry": "2022-03-12T20:29:23Z",
          "environment": "production",
          "options.getUpiDeepLinks": "true",
          "lastName": "wick",
          "action": "paymentPage",
          "customerId": "testing-customer-one",
          "returnUrl": "https://shop.merchant.com",
          "currency": "INR",
          "firstName": "John",
          "customerPhone": "9876543210",
          "customerEmail": "test@mail.com",
          "orderId": "testing-order-one",
          "description": "Complete your payment"
      }
  }
}

```



### Step 3 Load the Payment Link in Browser


You will receive a payment link in response of session create function as shown in the above sample response. Load this URL in your browser to open the payment page.



---

## Complete Code Reference

The following code files are referenced in the steps above:

### index.js

```
const fs = require('fs')
const express = require('express')
// block:start:importing-sdk
const { Juspay, APIError } = require('expresscheckout-nodejs')
// block:end:importing-sdk

/**
 * Setup expresscheckout-node sdk
 */
const SANDBOX_BASE_URL = "https://smartgateway.hdfcuat.bank.in"
const PRODUCTION_BASE_URL = "https://smartgateway.hdfc.bank.in"


/**
 * Read config.json file
 */
const config = require('./config.json')
const path = require('path')
const publicKey = fs.readFileSync(config.PUBLIC_KEY_PATH)
const privateKey = fs.readFileSync(config.PRIVATE_KEY_PATH)
const paymentPageClientId = config.PAYMENT_PAGE_CLIENT_ID // used in orderSession request

/*
Juspay.customLogger = Juspay.silentLogger
*/
const juspay = new Juspay({
    merchantId: config.MERCHANT_ID,
    baseUrl: SANDBOX_BASE_URL,
    jweAuth: {
        keyId: config.KEY_UUID,
        publicKey,
        privateKey
    }
})

/**
 * initialize server
 */
const app = express()
const port = process.env.PORT || 5000

app.use(express.urlencoded({ extended: true }))

/**
 * route:- initiateJuspayPayment
 */

// block:start:session-function
app.post('/initiateJuspayPayment', async (req, res) => {
    const orderId = `order_${Date.now()}`
    const amount = 1 + Math.random() * 100 | 0

    // makes return url
    const returnUrl = `${req.protocol}://${req.hostname}:${port}/handleJuspayResponse`

    try {
        const sessionResponse = await juspay.orderSession.create({
            order_id: orderId,
            amount: amount,
            payment_page_client_id: paymentPageClientId,                    // [required] shared with you, in config.json
            customer_id: 'hdfc-testing-customer-one',                       // [optional] your customer id here
            action: 'paymentPage',                                          // [optional] default is paymentPage
            return_url: returnUrl,                                          // [optional] default is value given from dashboard
            currency: 'INR'                                                 // [optional] default is INR
        })

        // removes http field from response, typically you won't send entire structure as response
        return res.json(makeJuspayResponse(sessionResponse))
    } catch (error) {
        if (error instanceof APIError) {
            // handle errors comming from juspay's api
            return res.json(makeError(error.message))
        }
        return res.json(makeError())
    }
})
 // block:end:session-function

// block:start:order-status-function
app.post('/handleJuspayResponse', async (req, res) => {
    const orderId = req.body.order_id || req.body.orderId

    if (orderId == undefined) {
        return res.json(makeError('order_id not present or cannot be empty'))
    }

    try {
        const statusResponse = await juspay.order.status(orderId)
        const orderStatus = statusResponse.status
        let message = ''
        switch (orderStatus) {
            case "CHARGED":
                message = "order payment done successfully"
                break
            case "PENDING":
            case "PENDING_VBV":
                message = "order payment pending"
                break
            case "AUTHORIZATION_FAILED":
                message = "order payment authorization failed"
                break
            case "AUTHENTICATION_FAILED":
                message = "order payment authentication failed"
                break
            default:
                message = "order status " + orderStatus
                break
        }

        // removes http field from response, typically you won't send entire structure as response
        return res.send(makeJuspayResponse(statusResponse))
    } catch(error) {
        if (error instanceof APIError) {
            // handle errors comming from juspay's api,
            return res.json(makeError(error.message))
        }
        return res.json(makeError())
    }
})
// block:end:order-status-function


app.get('/', function(req,res) {
    return res.sendfile(path.join(__dirname, 'index.html'))
});

app.listen(port, () => {
    console.log(`Server is running on http://localhost:${port}`)
})

// Utitlity functions
function makeError(message) {
    return {
        message: message || 'Something went wrong'
    }
}

function makeJuspayResponse(successRspFromJuspay) {
    if (successRspFromJuspay == undefined) return successRspFromJuspay
    if (successRspFromJuspay.http != undefined) delete successRspFromJuspay.http
    return successRspFromJuspay
}

```

### Program.php

```
<?php
date_default_timezone_set('UTC');
use Juspay\RequestOptions;
require realpath(__DIR__ .  '/vendor/autoload.php'); # Required while running it as standalone, not required while integrating into existing project
use Juspay\Exception\JuspayException;
use Juspay\JuspayEnvironment;
use Juspay\Model\JuspayJWT;
use Juspay\Model\Order;
use Juspay\Model\OrderSession;

class PHPKit {

    public $orderId;

    private $config;

    public function __construct($orderId, $config) {
        $this->orderId = $orderId;
        $this->config = $config;
    }

    // block:start:order-status-function
    public function orderStatus() {
       try {
        $params = array();
        $params ['order_id'] = $this->orderId;
        $requestOption = new RequestOptions();
        $requestOption->withCustomerId("testing-customer-one");
        $order = Order::status($params, $requestOption);
        echo "id: ". $order->orderId . PHP_EOL;
        echo "amount: ". $order->amount . PHP_EOL;
        echo "status: " . $order->status . PHP_EOL;
        echo "order env" . getenv("ORDER_ID") . PHP_EOL;
       } catch ( JuspayException $e ) {
            echo "error code" . $e->getHttpResponseCode() . PHP_EOL;
            echo "error message: " . $e->getErrorMessage() . PHP_EOL;
            echo "error code" . $e->getErrorCode() . PHP_EOL;
        }
    }
    // block:end:order-status-function
    
    // block:start:session-function
    public function session() {
        try {
            $params = array();
            $params['amount'] = 1;
            $params['order_id'] = $this->orderId;
            $params["merchant_id"] = $this->config["MERCHANT_ID"]; # Add merchant id
            $params['customer_id'] = "testing-customer-one";
            $params['payment_page_client_id'] = $this->config["MERCHANT_ID"];
            $params['action'] = "paymentPage";
            $params['return_url'] = "http://0.0.0.0:5000/handleResponse";
            $requestOption = new RequestOptions();
            $requestOption->withCustomerId("testing-customer-one");
            $session = OrderSession::create($params, $requestOption);
            echo "id: " . $session->id . PHP_EOL;
            echo "order id: ". $session->orderId . PHP_EOL;
            echo "status" . $session->status . PHP_EOL;
            echo "payment link: " . $session->paymentLinks["web"] . PHP_EOL;
            echo "sdk payload" . json_encode($session->sdkPayload) . PHP_EOL;
        } catch ( JuspayException $e ) {
            echo "error code" . $e->getHttpResponseCode() . PHP_EOL;
            echo "error message: " . $e->getErrorMessage() . PHP_EOL;
            echo "error code" . $e->getErrorCode() . PHP_EOL;
        }
    }
    // block:end:session-function
}


$config = file_get_contents("config.json");
$config = json_decode($config, true);
$privateKey = array_key_exists("PRIVATE_KEY", $config) ? $config["PRIVATE_KEY"] : file_get_contents($config["PRIVATE_KEY_PATH"]);
$publicKey =  array_key_exists("PUBLIC_KEY", $config) ? $config["PUBLIC_KEY"] : file_get_contents($config["PUBLIC_KEY_PATH"]);

if ($privateKey == false || $publicKey == false) {
    if ($privateKey == false) {
        throw new Exception ("private key file not found");
    }
    throw new Exception ("public key file not found");
}

JuspayEnvironment::init()
->withBaseUrl("https://smartgateway.hdfcuat.bank.in")
->withMerchantId($config["MERCHANT_ID"])
->withJuspayJWT(new JuspayJWT($config["KEY_UUID"], $publicKey, $privateKey)); #Add key id

$orderId = uniqid();

echo "order id: " . $orderId . PHP_EOL;

$phpKit = new PHPKit($orderId, $config);

echo "Executing Session" . PHP_EOL;
$phpKit->session();
echo "Executing Order Status:" . PHP_EOL;
$phpKit->orderStatus();

```

### InitiateJuspayPayment.java

```
package in.juspaybackendkit;

import com.google.gson.Gson;
import in.juspay.exception.JuspayException;
import in.juspay.model.OrderSession;
import in.juspay.model.RequestOptions;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Random;
import java.util.UUID;

// block:start:InitiateJuspayPayment
public class InitiateJuspayPayment extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        String orderId = "order_" + UUID.randomUUID().toString().substring(12);
        int amount = new Random().nextInt(100) + 1;

        String serverName = req.getServerName();
        int serverPort = req.getServerPort();
        String contextPath = req.getContextPath();

        String paymentPageClientId = JuspayConfig.payment_page_client_id;
        String customerId = "hdfc-testing-customer-one";
        String scheme = req.getScheme();
        String returnUrl = scheme + "://" + serverName + ":" + serverPort + contextPath + "/handleJuspayResponse";

        try {
            Map<String, Object> params = new LinkedHashMap<>();
            params.put("order_id", orderId);
            params.put("payment_page_client_id", paymentPageClientId);
            params.put("amount", amount);
            params.put("customer_id", customerId);
            params.put("action", "paymentPage");
            params.put("return_url", returnUrl);
            params.put("currency", "INR");
            RequestOptions requestOptions = RequestOptions.createDefault().withCustomerId(customerId);
            OrderSession orderSession = OrderSession.create(params, requestOptions);
            resp.setStatus(HttpServletResponse.SC_OK);
            resp.setContentType("application/json");
            String responseString = new Gson().toJson(orderSession);
            resp.getWriter().write(responseString);
        } catch (JuspayException e) {
            e.printStackTrace();
            resp.setStatus(e.getHttpResponseCode());
            resp.setContentType("application/json");
            resp.getWriter().write(makeErrorMsg(e.getErrorMessage()));
        }
    }

    private String makeErrorMsg(String msg) {
        return "{\n  \"message\": \"" + msg + "\"\n}";
    }
}
// block:end:InitiateJuspayPayment

```

### InitiateJuspayPaymentController.cs

```
using Microsoft.AspNetCore.Mvc;
using Juspay;
using Newtonsoft.Json;
using System.Collections.Generic;
using System;

namespace dotnet_server.Controllers {

    [ApiController]
    [Route("[controller]")]
    public class InitiateJuspayPaymentController : Controller
    {

        [HttpPost]
        public IActionResult Post()
        {
            try
            {
                // block:start:session-function
                string orderId = $"order_{new Random().Next()}";
                int amount = new Random().Next(0, 100);
                string customerId = "testing-customer-one";
                RequestOptions requestOptions = new RequestOptions{ CustomerId = customerId };
                CreateOrderSessionInput createOrderSessionInput = new CreateOrderSessionInput(new Dictionary<string, object>{{ "amount", amount}, { "order_id",  orderId}, { "customer_id", customerId }, { "payment_page_client_id", Init.Config.PaymentPageClientId }, { "action", "paymentPage" }, { "return_url", "http://localhost:5000/handleJuspayResponse" } });
                JuspayResponse sessionRes = new OrderSession().Create(createOrderSessionInput, requestOptions);
                Dictionary<string, object> res = new Dictionary<string, object> {
                    { "orderId", sessionRes.Response.order_id },
                    { "id", sessionRes.Response.id },
                    { "status", sessionRes.Response.status },
                    { "paymentLinks", sessionRes.Response.payment_links },
                    { "sdkPayload", sessionRes.Response.sdk_payload },
                };
                // block:end:session-function
                if (sessionRes.Response.status == "NEW")
                {
                    return new ContentResult
                    {
                        ContentType = "application/json",
                        Content = JsonConvert.SerializeObject(res)
                    };
                }
                else {
                    throw new Exception($"invalid session status: {sessionRes.Response.status} ");
                }
            }
            catch (Exception ex)
            {

                Console.WriteLine(ex);
                return StatusCode(500, ex.Message);
            }
        }


    }

}

```


---

## See Also

- [Getting the Backend SDK](https://smartgateway.hdfc.bank.in/docs/hypercheckout-mobile-sdk/web/how-to-integrate-sdks/getting-the-backend-sdk)
- [Handle Payment Responses](https://smartgateway.hdfc.bank.in/docs/hypercheckout-mobile-sdk/web/how-to-integrate-sdks/handle-payment-responses)
