{
  "page": "payment",
  "version": 2,
  "contract": {
    "api_base_url": "https://api.replynodes.com",
    "web_v1": {
      "network": "eip155:8453",
      "chain_id": 8453,
      "asset": "USDC",
      "asset_address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
      "wallet": "EIP-1193 EVM wallet",
      "payment": "x402 exact EIP-3009 TransferWithAuthorization"
    }
  },
  "flows": {
    "create_onboarding_intent": {
      "method": "POST",
      "url": "https://api.replynodes.com/v1/billing/onboarding/intents",
      "auth": "none",
      "body": { "wallet_address": "0x...", "amount_micros": 5000000, "network": "eip155:8453" },
      "returns": { "intent_id": "...", "status": "awaiting_proof", "proof_message": "...", "expires_at": "..." }
    },
    "prove_onboarding_wallet": {
      "method": "POST",
      "url": "https://api.replynodes.com/v1/billing/onboarding/intents/{intent_id}/proof",
      "auth": "none",
      "body": { "signature": "0x..." },
      "note": "The signature is personal_sign over the exact proof_message returned for this intent."
    },
    "settle_onboarding_payment": {
      "method": "POST",
      "url": "https://api.replynodes.com/v1/billing/onboarding/intents/{intent_id}/x402",
      "auth": "none",
      "first_response": "HTTP 402 with PAYMENT-REQUIRED requirements",
      "payment_header": "PAYMENT-SIGNATURE or X-PAYMENT: base64(JSON x402 v2 EIP-3009 payload)",
      "success": { "status": "redeemed", "api_key": "rn_live_..." },
      "retry": "HTTP 200 status already_redeemed without api_key; no second settlement or disclosure"
    },
    "authenticated_topup": {
      "method": "POST",
      "url": "https://api.replynodes.com/v1/billing/topup/intents",
      "auth": "Authorization: Bearer <api_key>",
      "body": { "amount_micros": 5000000, "network": "eip155:8453" },
      "settlement_url": "https://api.replynodes.com/v1/billing/topup/x402/{intent_id}",
      "note": "Existing-key top-up remains separate from web onboarding."
    },
    "check_balance": {
      "method": "GET",
      "url": "https://api.replynodes.com/v1/me/balance",
      "auth": "Authorization: Bearer <api_key>"
    }
  },
  "http_402_recovery": [
    "1. The onboarding page creates an intent bound to wallet, amount, network, and expiry.",
    "2. Sign the returned proof_message with personal_sign.",
    "3. POST the x402 endpoint without payment to read PAYMENT-REQUIRED.",
    "4. Sign the exact Base Mainnet USDC EIP-3009 requirement with eth_signTypedData_v4.",
    "5. Retry with PAYMENT-SIGNATURE or X-PAYMENT and save the api_key immediately; it is shown once."
  ],
  "notes": [
    "No account system: the API key is the account.",
    "Only an API-key hash is stored; plaintext is not written to localStorage or logs.",
    "Web V1 is Base Mainnet only. Do not send USDC to a shared address; every payment uses a short-lived intent.",
    "x402 pay-per-call is separate and does not silently credit prepaid balance."
  ]
}
