# Accept Base USDC in Next.js and grant an access pass with a webhook

Buy a pass for 0.01 test USDC on Base Sepolia. A Next.js server creates the order, the buyer signs in their wallet, and a worker grants access after the payment is confirmed.

## Prepare a project and a test wallet

Sign in to the dashboard, create a test project, issue a test server key under API keys, then copy the Merchant ID and Project ID for the selected project from Project settings → Project details. Use Node.js 22.20 or newer, PostgreSQL 16 or newer and a browser wallet with Base Sepolia test ETH for gas and test USDC. Prepare one merchant recipient address per order.

## Download and configure the example

Set DATABASE_URL, ZERO_TO_ONE_PAY_API_KEY, MERCHANT_ID, PROJECT_ID and APP_ORIGIN in .env. APP_ORIGIN is the address your buyers open. WEBHOOK_URL defaults to APP_ORIGIN/api/webhooks/0to1pay. For local development, forward that route to a publicly reachable HTTPS URL and set WEBHOOK_URL accordingly. Keep the test key, webhook secret and .merchant/ on your server.

```
curl -fLO https://0to1pay.com/examples/nextjs-base-usdc.zip
unzip nextjs-base-usdc.zip
cd nextjs-base-usdc
npm ci
cp .env.example .env
```

## Register the recipient and webhook

Setup prepares the database and registers a Base Sepolia connection, a test recipient and a signed webhook endpoint. Run the web app and worker in separate terminals with the same database and .merchant/ configuration. Use npm run recipient to add an unused address for the next order.

```
npm run setup
npm run dev
# In a second terminal in nextjs-base-usdc/
npm run worker
```

## Pay on Base Sepolia

Select the test pass in the app. The server creates a payment and quote and reserves its recipient. In the wallet, check Base Sepolia (chain ID 84532), the quoted token contract, recipient and amount. Sign the buyer authorization, send 0.01 test USDC and sign the claim containing that transaction hash. If you close the browser after sending, return in the same browser and submit the existing hash.

## Verify fulfillment through the signed webhook

After verifying the on-chain transfer, the platform sends fulfillment.requested. The Next.js handler passes the original bytes and headers to FulfillmentInbox.receive and acknowledges after persistence. The worker claims the command and records the pass and execution result in one PostgreSQL transaction. Check the pass in the same browser. Retrying a webhook for that order leaves a single entitlement. Access is granted only after verified fulfillment.

## Integration resources

- [Accept Base USDC in Next.js and grant an access pass with a webhook](https://0to1pay.com/guides/nextjs-base-usdc)
- [Integration guide (Markdown)](https://0to1pay.com/guides/nextjs-base-usdc.md)
- [Try the 0.01 test USDC demo](https://0to1pay.com/demo/base-usdc)
- [Next.js example source (ZIP)](https://0to1pay.com/examples/nextjs-base-usdc.zip)
- [@0to1pay/server-sdk](https://www.npmjs.com/package/@0to1pay/server-sdk)
- [@0to1pay/fulfillment-sdk](https://www.npmjs.com/package/@0to1pay/fulfillment-sdk)
- [OpenAPI JSON](https://api.0to1pay.com/openapi.json)
- [Find the merchant and project IDs in project settings](https://pay.0to1pay.com/merchant#settings)
- [Test projects and API keys](https://pay.0to1pay.com/merchant)
