> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ababilpay.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Accept your first USDC payment on testnet in under 10 minutes.

<Note>
  Make sure you have an account on the [Ababilpay Dashboard](https://testnetv1.ababilpay.xyz) and a testnet API key before starting.
</Note>

## Before You Begin

1. Sign in to the [Ababilpay Dashboard](https://testnetv1.ababilpay.xyz)
2. Go to **API Keys** and create a new `sk_test_...` key
3. Go to **Wallets** and add at least one testnet wallet on any supported chain (Base Sepolia, Ethereum Sepolia, Arc Testnet, or Solana Devnet)

***

## Option A — Hosted Checkout (Recommended)

The fastest path. You create an intent on your backend, redirect the buyer to Ababil's hosted checkout page, and poll for confirmation. No frontend work required.

<Steps>
  <Step title="Create a payment intent">
    Call `POST /api/v1/x402/intents` from your backend with the amount and redirect URLs.

    ```bash cURL theme={null}
    curl -X POST https://testnetv1.ababilpay.xyz/api/v1/x402/intents \
      -H "Authorization: Bearer sk_test_..." \
      -H "Content-Type: application/json" \
      -d '{
        "amount_usdc":  10.00,
        "description":  "Test Order",
        "order_id":     "order_001",
        "redirect_url": "https://yoursite.com/success",
        "cancel_url":   "https://yoursite.com/cancel"
      }'
    ```

    Response:

    ```json theme={null}
    {
      "success": true,
      "data": {
        "intent_id":    "d03e0751-5a79-4b33-aa0e-d33dee344f27",
        "status":       "pending",
        "amount_usdc":  10.00,
        "checkout_url": "https://testnetv1.ababilpay.xyz/pay/d03e0751-5a79-4b33-aa0e-d33dee344f27",
        "expires_at":   "2026-05-26T13:00:00Z"
      }
    }
    ```
  </Step>

  <Step title="Redirect the buyer">
    Send the buyer to `checkout_url`. Ababil handles wallet connect, chain selection, signing, and on-chain settlement.

    ```javascript theme={null}
    // Express.js example
    res.redirect(data.checkout_url)
    ```
  </Step>

  <Step title="Confirm payment">
    After the buyer lands on your `redirect_url`, poll the intent to verify settlement before fulfilling the order.

    ```javascript theme={null}
    const res = await fetch(
      `https://testnetv1.ababilpay.xyz/api/v1/x402/intents/${intentId}`,
      { headers: { "Authorization": "Bearer sk_test_..." } }
    )
    const { data } = await res.json()

    if (data.status === "paid") {
      console.log("Settled on-chain:", data.tx_hash)
      // fulfil order
    }
    ```

    A confirmed payment response looks like this:

    ```json theme={null}
    {
      "success": true,
      "data": {
        "intent_id":     "d03e0751-5a79-4b33-aa0e-d33dee344f27",
        "status":        "paid",
        "amount_usdc":   10.00,
        "tx_hash":       "0xf4753b209212ece119cb099f8f499efb6a4df031...",
        "buyer_address": "0xBuyerAddress",
        "chain":         "eip155:84532",
        "paid_at":       "2026-05-26T12:05:00Z"
      }
    }
    ```
  </Step>
</Steps>

***

## Option B — Custom Integration (Full Control)

Build your own payment UI or pay programmatically from an AI agent. Your frontend (or agent) signs the EIP-3009 authorization and submits it to Ababil for settlement.

<Steps>
  <Step title="Create a payment intent">
    Same endpoint as above — no `redirect_url` needed for custom flows.

    ```bash theme={null}
    curl -X POST https://testnetv1.ababilpay.xyz/api/v1/x402/intents \
      -H "Authorization: Bearer sk_test_..." \
      -H "Content-Type: application/json" \
      -d '{ "amount_usdc": 10.00, "order_id": "order_001" }'
    ```

    The response includes `payment_requirements` — one entry per chain your merchant wallet supports.
  </Step>

  <Step title="Sign EIP-3009 typed data">
    Pick the `payment_requirement` matching the buyer's chain and sign a `TransferWithAuthorization` message.

    ```typescript theme={null}
    // wagmi (React)
    const signature = await signTypedDataAsync({
      domain: {
        name:              req.usdcDomainName,   // always read from API
        version:           "2",
        chainId:           parseInt(req.network.split(":")[1]),
        verifyingContract: req.asset,
      },
      types: {
        TransferWithAuthorization: [
          { name: "from",        type: "address" },
          { name: "to",          type: "address" },
          { name: "value",       type: "uint256" },
          { name: "validAfter",  type: "uint256" },
          { name: "validBefore", type: "uint256" },
          { name: "nonce",       type: "bytes32" },
        ],
      },
      primaryType: "TransferWithAuthorization",
      message: {
        from:        address,
        to:          req.payTo,
        value:       BigInt(req.maxAmountRequired),
        validAfter:  0n,
        validBefore: BigInt(Math.floor(Date.now() / 1000) + 900),
        nonce:       `0x${crypto.getRandomValues(new Uint8Array(32))
                       .reduce((s, b) => s + b.toString(16).padStart(2,"0"), "")}`,
      },
    })
    ```
  </Step>

  <Step title="Submit settlement">
    Send the signed payload to `/api/v1/x402/pay`. Ababil verifies the signature and submits the on-chain transfer.

    ```bash theme={null}
    curl -X POST https://testnetv1.ababilpay.xyz/api/v1/x402/pay \
      -H "Authorization: Bearer sk_test_..." \
      -H "Content-Type: application/json" \
      -d '{
        "intent_id": "d03e0751-5a79-4b33-aa0e-d33dee344f27",
        "payment_signature": {
          "scheme":      "exact",
          "network":     "eip155:84532",
          "x402Version": 1,
          "payload": {
            "from":        "0xBuyerAddress",
            "to":          "0xMerchantAddress",
            "value":       "10000000",
            "validAfter":  "0",
            "validBefore": "1748300000",
            "nonce":       "0x7752857d...",
            "signature":   "0xacb8e1f5..."
          }
        }
      }'
    ```

    On success, USDC lands directly in your merchant dashboard wallet.
  </Step>
</Steps>

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Hosted Gateway" icon="arrow-up-right-from-square" href="/api-reference/hosted-gateway">
    Full walkthrough of Path A with Node.js and Python examples.
  </Card>

  <Card title="Custom Integration" icon="code" href="/api-reference/custom-integration">
    EIP-3009 signing details, wagmi and viem code, Solana flow.
  </Card>

  <Card title="AI Agent Integration" icon="robot" href="/api-reference/ai-agents">
    Enable autonomous USDC payments from AI agents using a private key.
  </Card>

  <Card title="Errors & Troubleshooting" icon="circle-exclamation" href="/api-reference/errors">
    Common mistakes, error codes, and how to fix them.
  </Card>
</CardGroup>
