I am trying to integrate phonepe API, I have a problem in callbackurl

532 views Asked by At

In callbackurl when we try to receive the response which is sent by them , I am unable to receive when I try in webhook it is working. I am receiving the result in post but, when I try in my website to receive in POST I am getting 404, when I use GET I am getting null.

The Code in callback URL

[HttpPost]
public ActionResult samplepayment()
{
    // Verify the X-VERIFY header.
    var xVerifyHeader = Request.Headers["X-VERIFY"];
    if (xVerifyHeader == null || !VerifyXVerifyHeader(xVerifyHeader))
    {
        // Invalid callback request.
        return Content("dgggg");
    }

    // Parse the JSON body of the request to get the notification details.
    string jsonBody;
    using (var reader = new StreamReader(Request.InputStream))
    {
        jsonBody = reader.ReadToEnd();
    }

    // Deserialize the JSON data into your model or dynamic object
    dynamic jsonObject = JsonConvert.DeserializeObject(jsonBody);screenshot

    // Get the notification details.
    var merchantId = jsonObject["merchantId"];
    var merchantTransactionId = jsonObject["merchantTransactionId"];
    var amount = jsonObject["amount"];
    var status = jsonObject["status"];

    // Process the notification details as needed.
    // For example, you could save the notification details to a database or send an email notification.

    // Return a success response.
    return Content("Callback Successful");
}

private bool VerifyXVerifyHeader(string xVerifyHeader)
{
    // TODO: Implement the logic to verify the X-VERIFY header.
    return true;
}

Screenshot after redirection to the callback URL:

enter image description here

0

There are 0 answers