Search code examples
c#json.netstripe-paymentshttphandler

How to process response from Stripe


I am making a payment to the Stripe gateway which returns as a successful payment.

I have setup the CLI to listen and forward the response to my localhost handler.

I have the below code in my Handler

    public void ProcessRequest(HttpContext context)
    {
        var reques = context.Request;
    }

However when the successful response comes back in, the breakpoint is hit and i analyse it. Im looking for a JSON response but i cant seem to find anything related to the feedback of this transaction. Nothing in Response, nothing in reques.Form.

How do i retrieve the response to take action for database related tasks?


Solution

  • Try setting up a Stripe webhook. The bottom of this page contains some next steps. Additionally, the Dashboard has a section under Developer for managing webhooks.

    By using a webhook, you can let Stripe call you with all sorts of event types. For example, after a charge you can receive notification of the pending charge and success (usually milliseconds behind). This is also a good way to learn of disputes being opened.

    These messages will have the JSON you are looking for. Your handler can then take action on your database.