Skip to main content

Module headers

Module headers 

Source
Expand description

HTTP header encoding and decoding for x402 protocol messages.

Handles Base64-encoded JSON payloads in PAYMENT-SIGNATURE, PAYMENT-REQUIRED, PAYMENT-RESPONSE, and legacy X-PAYMENT headers.

Corresponds to Python SDK’s http/x402_http_client_base.py.

Functions§

decode_payment_payload
Decodes a PAYMENT-SIGNATURE or X-PAYMENT header value into a version-tagged payload enum.
decode_payment_required
Decodes a PAYMENT-REQUIRED header value into a version-tagged enum.
decode_payment_response
Decodes a PAYMENT-RESPONSE header value into a SettleResponse.
encode_payment_required
Encodes a PaymentRequired (V2) as a Base64 string for the PAYMENT-REQUIRED header.
encode_payment_required_v1
Encodes a PaymentRequiredV1 as a Base64 string for the PAYMENT-REQUIRED header (V1).
encode_payment_response
Encodes a SettleResponse as a Base64 string for the PAYMENT-RESPONSE header.
encode_payment_signature
Encodes a V2 PaymentPayload as a Base64 string for the PAYMENT-SIGNATURE header.
encode_x_payment
Encodes a V1 PaymentPayloadV1 as a Base64 string for the X-PAYMENT header.