Callback Verification

Callback verification

For verifying if the callback received is valid or not.

Parameter NameData TypeMandatoryDescription
usernameStringYesUnique username configured for the callback url.
passwordStringYesUnique password configured for the callback url.
authorizationStringYesValue of the Authorization header under the callback response.
responseBodyStringYesCallback response body as string.

Example :

import { StandardCheckoutClient, Env } from 'pg-sdk-node'; 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 authorizationHeaderData = "ef4c914c591698b268db3c64163eafda7209a630f236ebf0eebf045460df723a" // received in the response headers const phonepeS2SCallbackResponseBodyString = "{\"type\": \"PG_ORDER_COMPLETED\",\"payload\": {}}" // callback body as string const usernameConfigured = "<MERCHANT_USERNAME>" const passwordConfigured = "<MERCHANT_PASSWORD>" const callbackResponse = client.validateCallback( usernameConfigured, passwordConfigured, authorizationHeaderData, phonepeS2SCallbackResponseBodyString ); const orderId = callbackResponse.payload.orderId; const state = callbackResponse.payload.state;

Returns :

The function returns a CallbackResponse object with the following properties:

Callback Response:

PropertyData TypeDescription
typeCallbackTypeContains event type of callback received at the merchant end.
payloadCallbackDataContains callback details.

Callback Types

Callback TypeContext
CHECKOUT_ORDER_COMPLETEDOrder completed
CHECKOUT_ORDER_FAILEDOrder failed
PG_REFUND_ACCEPTEDPhonePe has acknowledged the Refund request is valid
PG_REFUND_COMPLETEDRefund request is successfully completed
PG_REFUND_FAILEDRefund request failed

CallbackData object has the following properties:

AttributeData TypeDescription
merchantIdStringThe merchant from which request was initiated.
orderIdStringOrder id generated by PhonePe. (Only present in case of order callbacks)
merchantOrderIdStringOrder id generated by merchant. (Only present in case of order callbacks)
originalMerchantOrderIdStringInternal transaction id for given payment attempt. (Only present in case of refund callback)
refundIdStringRefund id generated by PhonePe. (Only present in case of refund callback)
merchantRefundIdStringRefund id generated by merchant. (Only present in case of refund callback)
stateStringState of the order/refund.
amountLongAmount of the order/refund processed.
expireAtLongExpiry in epoch.
errorCodeStringError code. (Only present when state is failed)
detailedErrorCodeStringDetailed error code. (Only present when state is failed)
metaInfoMetaInfoMetaInfo passed during the init of order.
paymentDetailsList<PaymentDetail>Payment details.

PaymentDetail Object has the following properties:

AttributeData TypeDescription
transactionIdStringThe merchant from which request was initiated.
paymentModeStringOrder id generated by PhonePe. (Only present in case of order callbacks)
timestampLongOrder id generated by merchant. (Only present in case of order callbacks)
stateStringAttempted transaction state. It can be any one of the following states:
1. COMPLETED
2. FAILED
3. PENDING
errorCodeStringError code. (Only present when state is failed)
detailedErrorCodeStringDetailed error code. (Only present when state is failed)