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 com.phonepe.sdk.pg.Env;
import com.phonepe.sdk.pg.payments.v2.StandardCheckoutClient;
import com.phonepe.sdk.pg.common.models.response.CallbackResponse;
String clientId = "<clientId>";
String clientSecret = "<clientSecret>";
Integer clientVersion = 1; //insert your client version here
Env env = Env.SANDBOX; //change to Env.PRODUCTION when you go live
StandardCheckoutClient client = StandardCheckoutClient.getInstance(clientId, clientSecret,
clientVersion, env);
String username = "<username>";
String password = "<password>";
String authorization = "<authorization>";
String responseBody = "<responseBody>";
CallbackResponse callbackResponse = client.validateCallback(username, password, authorization, responseBody);
String callbackType = callbackResponse.getType();
String merchantRefundId = callbackResponse.getPayload()
.getMerchantRefundId();
String state = callbackResponse.getPayload()
.getState();
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 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_REFUND_ACCEPTED | PhonePe has acknowledged the Refund request is valid |
PG_REFUND_COMPLETED | Refund request is successfully completed |
PG_REFUND_FAILED | 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 in Paisa 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 | Additional Information about the order |
paymentDetails | List<PaymentDetail> | Contain list of details of each transaction attempt made corresponding to this particular order |
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. COMPLETED 2. FAILED 3. PENDING |
errorCode | String | Error code present only when the transaction state is Failed |
| String | Detailed Error Code present only when transaction state is Failed |