# How do I accept MPP payments on my API?

> Add MPP middleware to your server, tell it which payment methods you take and who receives the money, and wrap each paid route with a charge. The reference library, mppx, has middleware for Next.js, Hono, Elysia and Express. Start on the test network, validate with the command-line tool, then switch to live. Stripe users can accept MPP through Stripe.

## What you need

- **A recipient**: the address or account that receives payments.
- **A secret key** for your server.
- **Middleware** for your framework.
- **At least one payment method** you want to accept.

## A minimal server

This follows the official quickstart. It uses Hono and the Tempo payment method on the test network, and charges 0.10 in the network's default stablecoin for `GET /resource`.

```typescript
import { Hono } from 'hono'
import { Mppx, tempo } from 'mppx/hono'

const app = new Hono()

const mppx = Mppx.create({
  methods: [tempo.charge({
    recipient: '0xYourAddress',
    testnet: true,
  })],
  secretKey: process.env.MPP_SECRET_KEY!,
})

app.get(
  '/resource',
  mppx.charge({ amount: '0.1' }),
  (c) => c.json({ data: '...' }),
)
```

Generate the secret with `openssl rand -hex 32`. Keep it on the server and out of your logs.

Unpaid requests to `/resource` now get a 402 with a challenge. Paid requests reach your handler.

## Frameworks

| Mode | Works with |
|---|---|
| Middleware | Next.js, Hono, Elysia, Express |
| Manual | Anything built on the Fetch API, including Cloudflare Workers, Deno and Bun |
| Node.js listeners | Wrap your handler with `Mppx.toNodeListener` |

## Test it

The `mppx` command-line tool checks your work without real money.

```bash
npx mppx validate https://your-server.example
curl -i https://your-server.example/resource
npx mppx account create --network testnet
npx mppx account fund --network testnet
npx mppx https://your-server.example/resource --network testnet
```

The first command validates your implementation. The second shows the raw 402. The last three make a paid request with test tokens.

You can also paste your endpoint into the [402 checker](https://www.ask402.ai/tools/402-checker) to see the challenge decoded the way a client reads it.

## Going live

1. **Remove `testnet: true`.**
2. **Add a shared store.** The quickstart warns that in production, and on platforms that run several copies of your server, the Tempo charge method needs a shared store such as Postgres. Without one it refuses to start.
3. **Use your real recipient address** and check you control it.
4. **Mark paid routes as not cacheable.** The protocol requires `Cache-Control: no-store` on 402 replies.

## Choosing payment methods

Each method reaches different buyers.

- **Tempo** reaches agents holding stablecoins on Tempo.
- **Card and Stripe** reach buyers without crypto.
- **Lightning** reaches buyers holding bitcoin.

You can list several, and the client picks one. The full list, with which are in production, is in [MPP payment methods](https://www.ask402.ai/x402/mpp-payment-methods).

## Accepting MPP through Stripe

If you already use Stripe, its announcement says you can accept MPP payments "in a few lines of code" through the PaymentIntents API, taking stablecoins as well as cards and buy now, pay later methods.

## Offering x402 as well

You do not have to choose. A server can put x402's header and MPP's header in the same 402 reply, and each kind of client reads its own. MPP's documentation has a guide to serving both, and its `evm` method is described as compatible with x402's `exact` payments.

Doing both costs little and widens who can pay you. See [how to accept x402 payments](https://www.ask402.ai/x402/how-to-accept-x402-payments) and [x402 vs MPP](https://www.ask402.ai/x402/x402-vs-mpp).

## Pricing

MPP has more ways to charge than a flat fee: `session` for streams of small payments and `subscription` for recurring access. See [how an MPP payment works](https://www.ask402.ai/x402/how-mpp-works). General advice on setting a price is in [how to price an x402 API](https://www.ask402.ai/x402/how-to-price-an-x402-api), most of which applies to either protocol.

## Sources

- [MPP server quickstart, mpp.dev](https://mpp.dev/quickstart/server)
- [MPP payment methods](https://mpp.dev/payment-methods)
- [Stripe, introducing the Machine Payments Protocol (March 18, 2026)](https://stripe.com/blog/machine-payments-protocol)
- [Using MPP with x402, mpp.dev](https://mpp.dev/guides/use-mpp-with-x402)

---

Facts checked against the sources above on 2026-11-20. Canonical page: https://www.ask402.ai/x402/how-to-accept-mpp-payments
