Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. HTTP
  3. Reference
  4. HTTP response status codes
  5. 402 Payment Required

402 Payment Required

The HTTP402 Payment Requiredclient error response status code is anonstandard response status code reserved for future use.

This status code was created to enable digital cash or (micro) payment systems and would indicate that requested content is not available until the client makes a payment.No standard use convention exists and different systems use it in different contexts.

Status

http
402 Payment Required

Examples

Payment API failure

Some payment APIs use the 402 response as a generic catch-all for failed payment requests.The following example tries to make a call to a payment API using a POST request to initiate a transaction:

http
POST /merchant/transfers/payment HTTP/1.1Host: payments.example.comContent-Type: application/jsonContent-Length: 402{  "payment_transfer": {    "reference": "PAYMENT123456",    "amount": "1337",    "currency": "EUR",    "sender_account_uri": "pan:5299920000000149;exp=2020-08;cvc=123",    "sender": {      "first_name": "Amelia",      "middle_name": "Rosenburg",      "email": "test123@sender.example.com"    },    "recipient": {      "first_name": "Tyrone",      "middle_name": "Johnston",      "email": "test123@example.com",      "merchant_id": "123"    },    "authentication_value": "ucaf:jJJLtQa+Iws8AREAEbjsA1MAAAA",  }}

The server responds to the request with a 402 if there is a problem with the transaction, in this case, the card is expired:

http
HTTP/1.1 402 Payment RequiredDate: Tue, 02 Jul 2024 12:56:49 GMTContent-Type: application/jsonContent-Length: 175{  "error": {    "code": "expired_card",    "doc_url": "https://example.com/error-codes#expired-card",    "message": "The card has expired. Verify expiration or use a different card.",  }}

Specifications

Specification
HTTP Semantics
# status.402

Compatibility notes

This status code isreserved but not defined.Actual implementations vary in the format and contents of the response.No browser supports a 402, and an error will be displayed as a generic4xx status code.

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp