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 nameData TypeMandatoryDescription
merchantOrderIdStringyesUnique merchant order id generated by merchant
amountlongyesAmount 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:

PropertyData TypeDescription
orderIdStringOrder ID generated by PhonePe
stateStringState of the Order. Initially it will be PENDING
expireAtLongExpiry time in epoch
tokenStringToken used to access the PG Page.
Is this article helpful?