jsonhttppayment-processing

What HTTP code response to use when payment fails?


What HTTP code to use when processing payments / dealing with credit cards?

For instance:

I am sending a JSON response, so I don't mind too much but I am wondering what's the right code to use.


Solution

  • First, it is important to distinguish between failures that are

    1. caused by the client side and
    2. others that have been caused by problems on the server side

    The latter ones normally describe errors that the client cannot solve on its own.

    The first ones should have a status code in the 400 series. The others, caused by the server side should have a status code on the 500 series.

    My suggestions

    A full list of return codes can be found here.