---
page_source: https://docs.hdfcbank.juspay.in/docs/hypercheckout-mobile-sdk/web/move-to-production-environment/prerequisites-for-production
page_title: Pre-Requisites for Production
---


# Pre-Requisites for Production 



In order to move from Sandbox to Production, you need to update identifier params and URLs in the frontend and backend setup.

Following sections describe how to move from Sandbox to Production:


### Step 1 Generate Public-Private Keys 


Generate a new Public-Private key pair for production (Refer to [Backend Setup](/hypercheckout-mobile-sdk/web/sample-project-setup/backend-setup#1.-Generate-the-Keys) for detailed steps to generate the keys)




### Step 2 Update file path for Public-Private Keys


Please update the file path for Public and Private Keys for production environment



#### Code Snippets: -

#### PHP Code Snippet:

```php
$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"]);
```

#### Java Code Snippet:

```java
private static String readFileAsString(String filePath) throws IOException {
        return new String(Files.readAllBytes(Paths.get(filePath)), Charset.defaultCharset());
    }
```



### Step 3 Update Base URL and Key UUID 


Please update the following in ‘init.php’ file:

* Update Base URL to [https://smartgateway.hdfc.bank.in](https://smartgateway.hdfc.bank.in)
* Update Key UUID to the latest Key UUID obtained from SmartGateway Dashboard upon uploading your production public key



#### Code Snippets: -

#### PHP Code Snippet:

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



### Step 4 Update Session Create function


Update params **merchant_id**  and **payment_page_client_id**  to the Merchant ID provided by the bank in ‘initiateJuspayPayment.php’ file



#### Code Snippets: -

#### PHP Code Snippet:

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

$config = ServerEnv::$config;

$inputJSON = file_get_contents('php://input');
$input = json_decode($inputJSON, true);
header('Content-Type: application/json');
$orderId = uniqid();
$amount = mt_rand(1,100);
try {
    $params = array();
    $params['amount'] = $amount;
    $params['currency'] = "INR";
    $params['order_id'] = $orderId;
    $params["merchant_id"] = $config["MERCHANT_ID"]; # Add merchant id
    $params['customer_id'] = "testing-customer-one";
    $params['payment_page_client_id'] = $config["PAYMENT_PAGE_CLIENT_ID"];
    $params['action'] = "paymentPage";
    $params['return_url'] = "http://localhost:5000/handleJuspayResponse";
    $requestOption = new RequestOptions();
    $requestOption->withCustomerId("testing-customer-one");
    $session = OrderSession::create($params, $requestOption);
    if ($session->status == "NEW") {
        $response = array("orderId" => $session->orderId, "id" => $session->id, "status" => $session->status, "paymentLinks" =>  $session->paymentLinks, "sdkPayload" => $session->sdkPayload );
    } else {
        http_response_code(500);
        $response = array("message" => "session status: " . $session->status);
    }
} catch ( JuspayException $e ) {
    http_response_code($e->getHttpResponseCode());
    $response = array("message" => $e->getErrorMessage());
    error_log($e->getErrorMessage());
}
echo json_encode($response);
?>
```



### Step 3 Update Base URL and Key UUID


Please update the following in ‘JuspayConfig.java’ file:

* Update Base URL to [https://smartgateway.hdfc.bank.in](https://smartgateway.hdfcbank.in)
* Update Key UUID to the latest Key UUID obtained from SmartGateway Dashboard upon uploading your production public key



#### Code Snippets: -

#### Java Code Snippet:

```java
JweJwsEncryptionKeys jweJwsEncryptionKeys = new JweJwsEncryptionKeys(keyUUID, publicKey, privateKey);
            JuspayEnvironment.withMerchantId(merchantId);
            JuspayEnvironment.withJweJwsEncryption(jweJwsEncryptionKeys);
            JuspayEnvironment.withBaseUrl(JuspayConfig.SANDBOX_BASE_URL);
```



### Step 4 Update OrderSession.Create( )


Update params **merchant_id**  and **payment_page_client_id**  to the Merchant ID provided by the bank in ‘InitiateJuspayPayment.java’ file



#### Code Snippets: -

#### Java Code Snippet:

```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

```



### Step 3 Update Base URL and Key UUID


Please update the following in ‘init.cs’ file:

* Update Base URL to [https://smartgateway.hdfc.bank.in](https://smartgateway.hdfc.bank.in)
* Update Key UUID to the latest Key UUID obtained from SmartGateway Dashboard upon uploading your production public key



#### Code Snippets: -

#### .NET Code Snippet:

```.net
JuspayEnvironment.Instance.JuspayJWT = new JuspayJWTRSA(Config.KeyUuid, Config.PublicKey, Config.PrivateKey);
                JuspayEnvironment.Instance.MerchantId = Config.MerchantId;
                JuspayEnvironment.Instance.BaseUrl = "https://smartgateway.hdfcuat.bank.in";
```



### Step 2 Update file path for Public-Private Keys


Please update the file path for Public and Private Keys for production environment



#### Code Snippets: -

#### Node JS Code Snippet:

```node js
{"MERCHANT_ID":"YOUR_MERCHANT_ID", "PRIVATE_KEY_PATH":"privateKey.pem","PUBLIC_KEY_PATH":"publicKey.pem","KEY_UUID":"YOUR_KEY_ID", "PAYMENT_PAGE_CLIENT_ID": "YOUR_PAYMENY_PAGE_CLIENT_ID"}
```



### Step 3 Update Base URL and Key UUID 


Please update the following in ‘index.js’ file:

* Update Base URL to [https://smartgateway.hdfc.bank.in](https://smartgateway.hdfc.bank.in)
* Update Key UUID to the latest Key UUID obtained from SmartGateway Dashboard upon uploading your production public key



#### Code Snippets: -

#### Node JS Code Snippet:

```node 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
}

```



### Step 4 Update Session Create function


Update params **merchant_id**  and **payment_page_client_id**  to the Merchant ID provided by the bank in InitiateJuspayPaymentController.cs.



#### Code Snippets: -

#### .NET Code Snippet:

```.net
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);
            }
        }


    }

}

```



### Step 4 Update Session Create function


Update params **merchant_id**  and **payment_page_client_id**  to the Merchant ID provided by the bank in the index.js file.



#### Code Snippets: -

#### Node JS Code Snippet:

```node js
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())
    }
})
```
