What Is a 402 Status Code?
Reserved for future use.
- Source: RFC7231 Section 6.5.2
402 CODE REFERENCES
Rails HTTP Status Symbol
Go HTTP Status Constant
Symfony HTTP Status Constant
Python2 HTTP Status Constant
Python3+ HTTP Status Constant
Python3.5+ HTTP Status Constant
Apache HttpComponents Core
402 status code example
Here’s an example of a request and response for a 402 status code:
POST /checkout HTTP/1.1
"name": "John Smith",
HTTP/1.1 402 Payment Required
Your account is not active. Please renew your subscription to complete this transaction.
In this example, the client is making a POST request to checkout for a product on the server. The server is indicating that the payment is required for the product and therefore the transaction cannot be completed at this time with a 402 Payment Required status code. The Retry-After header in the response specifies the number of seconds after which the client can retry the request.
The response also includes a message that indicates why the payment cannot be completed, in this case, that the client’s account is not active and the subscription needs to be renewed to complete the transaction.
The 402 status code is a non-standard HTTP status code that is not widely used, but it is intended to indicate that the client needs to make a payment before the request can be completed. It is typically used in situations where the client has an active account but requires additional payment to complete the transaction.
How to fix a 402 status code
A 402 status code indicates that a payment is required to complete the requested action. Therefore, to “fix” a 402 status code, the client must provide the necessary payment information and retry the request.
Here are the general steps to fix a 402 status code:
- Review the response message: The response message typically provides information on why the payment is required. It may be due to an expired subscription, insufficient funds, or other payment-related issues. Review the message to determine the specific issue.
- Provide the necessary payment information: If the issue is related to a payment method, such as an expired credit card, provide the updated payment information.
- Retry the request: After providing the necessary payment information, retry the request to complete the action.
- Verify the payment has been processed: Once the request is successfully completed, verify that the payment has been processed correctly.
If the issue cannot be resolved through providing payment information or retrying the request, contact the service provider or the organization responsible for handling the payment to resolve the issue.
In summary, to fix a 402 status code, the client must provide the necessary payment information and retry the request.
- Learn about web development
- Learn about SEO
- Web development services from WebFX
- SEO services from WebFX
- MDN Web Docs