Skip to main content

MPP payments

The Machine Payments Protocol (MPP) enables crypto-native, per-request payments on the Tempo blockchain. MPP is an additive payment method alongside Stripe — you choose which to use on each request.

How it works

MPP uses an HTTP 402 challenge/response flow:
  1. You send a request to the gateway.
  2. The server returns 402 Payment Required with a challenge containing the price, token, and recipient.
  3. You sign a Tempo transaction matching the challenge.
  4. You retry the request with the signed transaction as a credential in the Authorization header.
  5. The server verifies the payment on-chain and returns the response with a Payment-Receipt header.

Supported networks

Set TEMPO_TESTNET=true in your environment to use the testnet during development.

Plugin pricing

Each plugin has a fixed per-request price in USD, settled in pathUSD on Tempo.

Payment credential

After receiving a 402 challenge, build and sign a credential to send with your retry:

Authorization header format

Credential structure

402 challenge structure

When a payment is required, the server responds with:

Challenge fields

Verification

The server verifies your credential by checking:
  1. The transaction is hex-encoded and starts with the 0x76 type marker.
  2. The recipient address matches the expected recipient.
  3. The token address matches the expected currency (pathUSD).
  4. The amount matches the plugin price (within a 0.0001 tolerance).
  5. The nonce matches the original challenge nonce.
If verification fails, the server returns an error with a description of the mismatch.

Receipt

On success, the server returns:
  • A Payment-Receipt response header containing the transaction hash.
  • The payment.receipt field in the JSON response body.

Client usage

Use mppFetch to handle the full 402 flow automatically:

mppFetch options

mppFetch result

Check MPP support

You can check whether an endpoint supports MPP payments:
The function sends an OPTIONS request and checks for a WWW-Authenticate: Payment header.

Troubleshooting

The plugin may not have a configured price. Only plugins listed in the pricing table above support MPP payments.
  • Ensure the challengeNonce matches the nonce from the 402 response.
  • Verify the transaction amount matches the challenge amount exactly.
  • Check that you are using the correct network (mainnet vs. testnet).
The transaction hex must begin with 0x76 (the Tempo transaction type marker). Ensure your signing implementation includes this prefix.