HTTP 402
   HOME

TheInfoList



OR:

HTTP Status Code 402, also known as "Payment Required," is a standard response code in the Hypertext Transfer Protocol (HTTP). It is part of the HTTP/1.1 protocol defined by the Internet Engineering Task Force (IETF) in the RFC 7231 specification.


Description

The HTTP 402 status code indicates that the client must make a payment to access the requested resource. It is typically used in situations where the server requires payment before granting access to the content or service. This code serves as a reminder that financial transaction or authorization is needed to proceed further. The 402 status code is considered non-standard and was introduced to extend the HTTP protocol's capabilities beyond the standard set of status codes. It provides a clear indication to the client that they need to take action to complete the payment process before they can access the requested resource.


Examples

Client request: GET /index.php HTTP/1.1 Host: www.example.org Server response: HTTP/1.1 402 Payment Required Location: https://www.example.org/index.asp


Usage

The HTTP 402 status code is typically used in e-commerce and subscription-based systems where access to content or services is restricted until the user completes a payment. It can be employed in various scenarios, such as: *Subscription Renewal: When a user's subscription plan expires, and they attempt to access premium content, the server may respond with a 402 status code to prompt the user to renew their subscription. *Paywalls: Websites that require users to make a payment to access specific articles, news content, or premium features can utilize the 402 status code to indicate that payment is required to proceed. *Digital Products: Online platforms selling digital goods, software licenses, or digital media downloads may employ the 402 status code to enforce payment before granting access to the purchased item.


Experimental

The HTTP status code 402 is currently classified as an experimental code within the
HTTP protocol The Hypertext Transfer Protocol (HTTP) is an application layer protocol in the Internet protocol suite model for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web, w ...
. Such experimental codes are introduced to assess new features or ideas and determine their practical application. The designation of the 402 status implies that a payment is mandated to obtain a particular resource or service. However, its tentative status indicates limited mainstream adoption. Web developers and institutions are advised to adhere to recognized HTTP norms and employ stable, thoroughly documented status codes. Even though the 402 code might be used on an experimental basis, caution is recommended because of potential discrepancies and compatibility challenges.


Response representation

The HTTP 402 response is accompanied by an entity body that provides additional information to the client regarding the payment requirements. This entity body can be in various formats, including
HTML The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScri ...
,
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. T ...
, or
JSON JSON (JavaScript Object Notation, pronounced ; also ) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other ser ...
, and typically includes details such as the payment amount, payment methods accepted, and instructions on how to complete the transaction.Fielding, R., Gettys, J., Mogul, J., et al. (1999). " fc:2616 Hypertext Transfer Protocol -- HTTP/1.1. RFC 2616. IETF. The server may also include relevant headers in the response, such as Retry-After, which indicates the time duration the client should wait before retrying the request after completing the payment process.


Relationship with other status codes

The HTTP 402 status code should not be confused with the more commonly used
403 Year 403 ( CDIII) was a common year starting on Thursday (link will display the full calendar) of the Julian calendar. At the time, it was known as the Year of the Consulship of Theodosius and Rumoridus (or, less frequently, year 1156 '' Ab ...
Forbidden status code. While both codes indicate that access to a resource is restricted, the distinction lies in the reason for the restriction. The 402 code specifically implies that payment is required, whereas the 403 code implies that access is forbidden due to other reasons, such as insufficient permissions or authentication failure. In cases where the server requires payment but also wants to convey additional information about why access is denied, it is common to include the 402 status code alongside a 403 status code. This combination helps communicate the payment requirement while providing more context to the client.The difference between HTTP status code 402 and 403
/ref>


References


External links


HTTP status code 402 Payment Required
at ''http-statuscode.com''
402 Payment Required
at ''developer.mozilla.org'' {{DEFAULTSORT:Http 402 Computer errors Hypertext Transfer Protocol status codes