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

# x402 Crypto Payments

> Accept cryptocurrency payments on your Crevio storefront using the x402 protocol

Crevio supports cryptocurrency payments through the [x402 protocol](https://www.x402.org/) -- an open standard for HTTP-native micropayments. When enabled, buyers can pay for products with USDC on supported EVM chains, and Crevio creates orders through the same infrastructure as Stripe payments.

## How it works

x402 uses HTTP status code `402 Payment Required` to negotiate payment between a buyer's wallet and your storefront. When a buyer requests access to a paid product via the API:

1. Crevio responds with `402` and includes payment details (amount, wallet address, chain).
2. The buyer's client signs a USDC payment transaction.
3. The payment is verified on-chain.
4. Crevio creates a checkout, charge, and order -- granting the buyer access to the purchased experiences.

x402 payments are first-class citizens alongside Stripe payments. They appear in your orders, trigger webhooks (`order.created`, `order.paid`), and grant experience access identically.

## Supported chains and currency

| Setting      | Value                                      |
| ------------ | ------------------------------------------ |
| **Currency** | USDC                                       |
| **Chains**   | Any EVM-compatible chain supported by x402 |
| **Wallet**   | Must be a valid EVM address (`0x...`)      |

Prices are converted from your variant's cent amount to USDC (e.g., a \$5.00 variant = 5.00 USDC).

## Enabling x402 payments

### Via the API

Use the x402 Configuration endpoint to enable crypto payments:

```bash theme={null}
# Get current configuration
curl https://api.crevio.co/v1/x402_configuration \
  -H "Authorization: Bearer YOUR_API_TOKEN"

# Enable x402 payments
curl -X PATCH https://api.crevio.co/v1/x402_configuration \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "x402_configuration": {
      "x402_enabled": true,
      "x402_wallet_address": "0xYourWalletAddress",
      "x402_chain": "base"
    }
  }'
```

### Configuration fields

| Field                 | Type    | Description                                                            |
| --------------------- | ------- | ---------------------------------------------------------------------- |
| `x402_enabled`        | boolean | Whether x402 payments are active                                       |
| `x402_wallet_address` | string  | Your EVM wallet address for receiving payments. Required when enabled. |
| `x402_chain`          | string  | The blockchain network to use                                          |

<Warning>
  A valid EVM wallet address (`0x` followed by 40 hex characters) is required when enabling x402. The API will reject the update if the address is missing or malformed.
</Warning>

## Requesting paid access to a product

Once x402 is enabled, use the product access endpoint to initiate a payment:

```bash theme={null}
POST /v1/products/{id_or_slug}/x402_access
```

Pass the price variant to purchase:

```bash theme={null}
curl -X POST https://api.crevio.co/v1/products/my-course/x402_access \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "price_variant_id": "price_abc123" }'
```

If the caller has not yet paid, the API responds with `402 Payment Required` including the payment details. After a valid x402 payment is submitted and verified, the response includes the order and access token:

```json theme={null}
{
  "id": "ord_abc123",
  "object": "x402_access",
  "product": "prod_abc123",
  "price_variant": "price_abc123",
  "order": "ord_abc123",
  "access_token": "tok_xyz789",
  "expires_at": null
}
```

## Customer records

x402 payments create customer records using the wallet address as an identifier. The customer's email is set to `{wallet_address}@x402.wallet` and their name is a truncated wallet address (e.g., `0x1234...5678`).

## Limitations

* x402 supports **one-time payments only** -- subscriptions are not available through x402.
* Refunds for x402 payments are not processed on-chain. Contact the buyer directly for refund arrangements.
* x402 payments only support USDC as the payment currency.
