UPI COLLECT

Request Details

Parameter NameData TypeMandatoryDescription
merchantOrderIdStringyesUnique order ID generated by merchant
amountlongyesAmount of order in Paisa
contraintsList<InstrumentConstraint>yesDifferent type of constraints that must be applied to the payment
VPAStringYesVPA against which collect request need to be raised

Example :

import {
CustomCheckoutClient, 
Env} 
from 'pg-sdk-node'

import { 
PgPaymentRequest, 
PgPaymentResponse } 
from 'pg-sdk-node';

import {v4 
as uuid} 
from 'uuid';
 

const clientId:string = "<clientId>";

const clientSecret:string = "<clientSecret>";

const clientVersion:number = 1;  //insert your client version here

const env = 
Env.SANDBOX;      //change to Env.PRODUCTION when you go live
 

const client = 
CustomCheckoutClient.
getInstance(clientId, clientSecret, clientVersion, env);
 

const merchantOrderId = 
uuid()

const amount = 100;

const deviceOS = "IOS";

const vpa = "<REPLACE_WITH_REQUIRED_VPA>";
 
cosnt request = 
PgPaymentRequest.
UpiCollectPayViaVpaRequestBuilder()
        .
vpa(vpa)
        .
amount(amount)
        .
deviceOS(deviceOS)
        .
merchantOrderId(merchantOrderId)
        .
message("collect_message")
        .
build();
 
client.
pay(request).
then((response) => {
    
const state = response.state;
})

The function will raise the collect request to the above mentioned vpa.

Response Details

PropertyTypeDescription
orderIdStringOrder Id created by PhonePe
stateStringState of the order. Initially it will be PENDING.
expireAtLongOrder expire date in epoch
Is this article helpful?