NodeJs SDK – Callback Verification
This is used to verify whether the callback received is valid or not
You need to pass 4 parameters to the validateCallback() function
| Parameter Name | Data Type | Mandatory | Description |
|---|---|---|---|
username | String | Yes | Unique username configured for the callback url. |
password | String | Yes | Unique password configured for the callback url. |
authorization | String | Yes | Value of the Authorization header under the callback response. |
responseBody | String | Yes | Callback response body as string. |
Example usage :
import {CustomCheckoutClient, Env, CallbackResponse}
from 'pg-sdk-node'
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 username = "<username>";
const password = "<password>";
const authorization = "<authorization";
const responseBody = "<responseBody>";
const callbackResponse = client.
validateCallback(username, password, authorization, responseBody);
String orderId = callbackResponse.payload.orderId
String state = callbackResponse.payload.state
Returns :
The function returns a CallbackResponse if the callback is valid, otherwise throws a PhonePeException.
Callback Response:
| Property | Data Type | Description |
|---|---|---|
type | CallbackType | Contains event of callback received at the merchant end. |
payload | CallbackData | Contains callback details. |
Callback Type
| Callback Type | Context |
|---|---|
PG_ORDER_COMPLETED | Order completed |
PG_ORDER_FAILED | Order failed |
PG | PhonePe has acknowledged the Refund request is valid |
PG_REFUND_COMPLETED | Refund request is successfully completed |
PG_ | Refund request failed |
CallbackData Properties :
| Property | Data Type | Description |
|---|---|---|
merchantId | String | The merchant from which request was initiated. |
orderId | String | Order id generated by PhonePe. (Only present in case of order callbacks) |
merchantOrderId | String | Order id generated by merchant. (Only present in case of order callbacks) |
originalMerchantOrderId | String | Internal transaction id for given payment attempt. (Only present in case of refund callback) |
refundId | String | Refund id generated by PhonePe. (Only present in case of refund callback) |
merchantRefundId | String | Refund id generated by merchant. (Only present in case of refund callback) |
state | String | State of the order/refund. |
amount | Long | Amount of the order/refund processed. |
expireAt | Long | Expiry in epoch. |
errorCode | String | Error code. (Only present when state is failed) |
detailedErrorCode | String | Detailed error code. (Only present when state is failed) |
metaInfo | MetaInfo | MetaInfo passed during the init of order. |
paymentDetails | List<PaymentDetail> | Payment details. |
PaymentDetail Object :
| Property | Data Type | Description |
|---|---|---|
transactionId | String | Transaction Id generated by the PhonePe |
paymentMode | String | Mode of Payment. It can be anyone of the following modes: 1.UPI_INTENT 2. UPI_COLLECT 3. UPI_QR 4. CARD 5. TOKEN 6. NET_BANKING |
timestamp | Long | Timestamp of the attempted transaction in epoch |
state | String | Attempted transaction state. It can be any one of the following states: 1. PENDING 2. COMPLETED 3. FAILED |
amount | Long | Amount in Paisa of the order/refund processed |
errorCode | Long | Error code present only when the transaction state is Failed |
| String | Detailed Error Code present only when transaction state is Failed |
splitInstruments | List<InstrumentCombo> | Contains split instrument details of all the transactions made |
NodeJs SDK – Response Models
Below data can be used when you need to access the response details :
PaymentRail :
Different types of rail which will be received at the time of getOrderStatus(). It falls under the rail attribute in PaymentDetail Object.
UPI RAIL
| Property | Type |
|---|---|
type | PaymentRailType |
utr | String |
upiTransactionId | String |
vpa | String |
PG RAIL
| Property | Type |
|---|---|
type | PaymentRailType |
transctionId | String |
authorizationCode | String |
serviceTransactionId | String |
PPI WALLET RAIL
| Property | Type |
|---|---|
type | PaymentRailType |
PPI EGV RAIL
| Property | Type |
|---|---|
type | PaymentRailType |
Payment Instrument V2
ACCOUNT
| Property | Type |
|---|---|
type | PaymentInstrumentType |
ifsc | String |
acountType | String |
maskedAccountNumber | String |
accountHolderName | String |
CREDIT_CARD
| Property | Type |
|---|---|
type | PaymentInstrumentType |
bankTransactionId | String |
bankId | String |
arn | String |
brn | String |
DEBIT_CARD
| Property | Type |
|---|---|
type | PaymentInstrumentType |
bankTransactionId | String |
| String |
arn | String |
brn | String |
NET_BANKING
| Property | Type |
|---|---|
type | PaymentInstrumentType |
| String |
| String |
arn | String |
brn | String |
EGV
| Property | Type |
|---|---|
type | PaymentInstrumentType |
cardNumber | String |
programId | String |
WALLET
| Property | Type |
|---|---|
type | PaymentInstrumentType |
walletId | String |
Instrument Constraints
ACCOUNT
| Property | Type |
|---|---|
type | Account |
accountNumber | String |
ifsc | String |