Create SDK Order

This is specifically used to generate a order token when the user’s backend is in NodeJs and they are using any Mobile SDK.

SDK setup

Used to fetch the Order token required by the frontend app to init pay requests.

Merchants can use the CreateSdkOrderRequest.StandardCheckoutBuilder() to create the request and the following are the attributes that merchant can pass.

SDK Order Request Builder

Builds SDK order request.

Attributes

Parameter nameData TypeMandatoryDescriptionConstraints
merchantOrderIdStringYesUnique merchant id generated by merchantMax Length = 63 characters
amountNumberYesAmount in paisa Minimum value = 100 (in paise)
redirectUrlStringYesThe URL to which the user should be redirected after the payment is completed

Example :

import { StandardCheckoutClient, Env, CreateSdkOrderRequest } from 'pg-sdk-node'; import { randomUUID } from 'crypto'; const clientId = "<clientId>"; const clientSecret = "<clientSecret>"; const clientVersion = 1; //insert your client version here const env = Env.SANDBOX; //change to Env.PRODUCTION when you go live const client = StandardCheckoutClient.getInstance(clientId, clientSecret, clientVersion, env); const merchantOrderId = randomUUID(); const amount = 1000; const redirectUrl = "https://redirectUrl.com"; const request = CreateSdkOrderRequest.StandardCheckoutBuilder() .merchantOrderId(merchantOrderId) .amount(amount) .redirectUrl(redirectUrl) .build(); client.createSdkOrder(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
expireAtNumberExpiry time in epoch
tokenStringToken to be used by the merchant app to initiate order