Callback verification
For verifying if the callback received is valid or not.
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 :
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:
Property | Data Type | Description |
---|---|---|
type | CallbackType | Contains event type of callback received at the merchant end. |
payload | CallbackData | Contains callback details. |
Callback Types
Callback Type | Context |
---|---|
CHECKOUT_ORDER_COMPLETED | Order completed |
CHECKOUT_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
object has the following properties:
Attribute | 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 has the following properties:
Attribute | Data Type | Description |
---|---|---|
transactionId | String | The merchant from which request was initiated. |
paymentMode | String | Order id generated by PhonePe. (Only present in case of order callbacks) |
timestamp | Long | Order id generated by merchant. (Only present in case of order callbacks) |
state | String | Attempted transaction state. It can be any one of the following states: 1. COMPLETED 2. FAILED 3. PENDING |
errorCode | String | Error code. (Only present when state is failed) |
detailedErrorCode | String | Detailed error code. (Only present when state is failed) |