To verify that the callback received from PhonePe is valid or not.
Parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
x_verify | str | Yes | x-verify header data received in the callback from PhonePe. |
response | str | Yes | The body of the response data returned from PhonePe. |
For Python SDK Version <= 0.0.3, the imports should be:
from phonepe.sdk.pg.payments
For Python SDK Version > 0.0.3, the imports should be:
from phonepe.sdk.pg.payments.v1
Example – Callback Checksum Verification
from phonepe.sdk.pg.payments.v1.payment_client import PhonePePaymentClient
from phonepe.sdk.pg.env import Env
merchant_id = "<YOUR_MERCHANT_ID>"
salt_key = "<YOUR_SALT_KEY>"
salt_index = 1 # insert your salt index
env = Env.UAT
should_publish_events = True
phonepe_client = PhonePePaymentClient(merchant_id, salt_key, salt_index, env, should_publish_events)
# from response headers
x_verify_header_data = "a005532637c6a6e4a4b08ebc6f1144384353305a9cd253d995067964427cd0bb###1"
# from response data
phonepe_s2s_callback_response_body_string = '{"response": "eyJzdWNjZXNzIjpmYWxzZSwiY29kZSI6IlBBWU1FTlRfRVJST1IiLCJtZXNzYWdlIjoiUGF5bWVudCBGYWlsZWQiLCJkYXRhIjp7Im1lcmNoYW50SWQiOiJtZXJjaGFudElkIiwibWVyY2hhbnRUcmFuc2FjdGlvbklkIjoibWVyY2hhbnRUcmFuc2FjdGlvbklkIiwidHJhbnNhY3Rpb25JZCI6IkZUWDIzMDYwMTE1NDMxOTU3MTYzMjM5IiwiYW1vdW50IjoxMDAsInN0YXRlIjoiRkFJTEVEIiwicmVzcG9uc2VDb2RlIjoiUkVRVUVTVF9ERUNMSU5FX0JZX1JFUVVFU1RFRSIsInBheW1lbnRJbnN0cnVtZW50IjpudWxsfX0="}'
is_valid = phonepe_client.verify_response(x_verify=x_verify_header_data, response=phonepe_s2s_callback_response_body_string)
Returns
True if the x_verify is valid for the given data.