Skip to main content
Execute payment for a 402-protected resource without attempting a direct call first. Directly calls the HTTPayer router (proxy mode) or relay endpoint (relay mode) to pay the invoice and retrieve the protected resource.

Signature

client.pay_invoice(api_method: str, api_url: str, api_payload: Optional = None, api_params: Optional = None, api_headers: Optional = None, network: Optional = None)

Parameters

  • api_method: HTTP method (GET, POST, PUT, DELETE, etc.).
  • api_url: Target API URL to access.
  • api_payload: JSON payload for POST/PUT requests.
  • api_params: Query parameters to include.
  • api_headers: Custom headers to send with the request.
  • network: Network override for relay mode payments.

Returns

Response from the target API after successful payment.

Raises

  • ValueError: If network is incompatible with wallet type or not supported.

Examples

>>> client = HTTPayerClient()
>>> response = client.pay_invoice("GET", "https://api.example.com/data")
>>> print(response.json())