NodeJs SDK – Create SDK Order
This is specifically used to generate a token when the user’s backend is in NodeJs and they are using any Mobile SDK.
Merchants can use the CreateSdkOrderRequest Builder to create the request and the following are the attributes that merchant can pass.
SDK Order Request Builder
Parameters
| Parameter name | Data Type | Mandatory | Description |
|---|---|---|---|
merchantOrderId | String | yes | Unique merchant order id generated by merchant |
amount | long | yes | Amount of order in Paisa |
Example :
import {
CreateSdkOrderRequest }
from 'pg-sdk-node';
import { v4
as uuid }
from 'uuid';
const merchantOrderId =
uuid();
const amount = 1000;
const request =
CreateSdkOrderRequest.
CustomCheckoutBuilder()
.
merchantOrderId(merchantOrderId)
.
amount(amount)
.
build();
client.
pay(request).
then((response) => {
const token = response.token;
});Returns :
The function returns a CreateOrderResponse object with the following properties:
| Property | Data Type | Description |
|---|---|---|
orderId | String | Order ID generated by PhonePe |
state | String | State of the Order. Initially it will be PENDING |
expireAt | Long | Expiry time in epoch |
token | String | Token used to access the PG Page. |