Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"pages": [
"docs/integrate/patterns/fiat-payments",
"docs/integrate/patterns/stablecoin-payments",
"docs/integrate/patterns/auto-order",
"docs/development-guide/nevermined-x402",
"docs/integrate/patterns/payment-models",
"docs/integrate/patterns/validate-requests",
Expand Down
18 changes: 15 additions & 3 deletions docs/development-guide/nevermined-x402.mdx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
title: "Nevermined x402"

Check warning on line 2 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L2

Did you really mean 'Nevermined'?
description: "Nevermined provides first-class support for the x402 payment protocol, enabling AI agents, APIs, and services to charge per-request using secure, locally-signed payment authorizations."

Check warning on line 3 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L3

Did you really mean 'Nevermined'?
icon: "credit-card"
---

# Nevermined x402

Check warning on line 7 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L7

Did you really mean 'Nevermined'?

Nevermined provides first-class support for the x402 payment protocol, enabling AI agents, APIs, and services to charge per-request using secure, locally-signed payment authorizations.

Check warning on line 9 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L9

Did you really mean 'Nevermined'?

<Note>
For the complete technical specification, see the [x402 Smart Accounts Extension Spec](/docs/specs/x402-smart-accounts).
Expand All @@ -17,7 +17,7 @@
This section explains:

- The x402 HTTP 402 handshake and `PAYMENT-SIGNATURE` retry pattern
- How Nevermined extends x402 with Smart Account-based settlement

Check warning on line 20 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L20

Did you really mean 'Nevermined'?
- How subscribers generate and sign x402 payment proofs
- How delegations, session keys, and delegated execution work
- How the facilitator verifies and settles requests
Expand All @@ -28,7 +28,7 @@

- [Payment Models](/docs/integrate/patterns/payment-models)

Nevermined's x402 implementation is compatible with the standard protocol while adding programmable settlement layers powered by Nevermined smart contracts.

Check warning on line 31 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L31

Did you really mean 'Nevermined's'?

Check warning on line 31 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L31

Did you really mean 'Nevermined'?

## Background: What x402 Solves

Expand All @@ -43,21 +43,21 @@
- Checks balance/permissions
- Settles payment on-chain (EIP-3009 or equivalent)

Nevermined extends this with ERC-4337 Smart Accounts, session keys, and programmable billing models, allowing much more complex behavior than standard EIP-3009-based transfers.

Check warning on line 46 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L46

Did you really mean 'Nevermined'?

## Why Nevermined Extends x402

Check warning on line 48 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L48

Did you really mean 'Nevermined'?

x402 itself focuses on single ERC-20, pay-per-request flows.

Nevermined introduces:

Check warning on line 52 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L52

Did you really mean 'Nevermined'?

| Area | x402 | Nevermined |

Check warning on line 54 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L54

Did you really mean 'Nevermined'?
| --------------------- | --------------- | ------------------------------------------------------------------- |
| Payment authorization | EIP-3009 | ERC-4337 UserOps + session keys |
| Wallet model | EOA signatures | Smart Accounts with granular permissions |
| Billing models | Pay-per-request | Subscriptions, credits, time windows, credit-burning |
| Delegated execution | Basic | Fully programmable “burn”, “order”, “redeem”, plan-specific actions |
| Settlement layer | ERC-20 | Nevermined smart-contract settlement |

Check warning on line 60 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L60

Did you really mean 'Nevermined'?


This means a subscriber can grant a server the ability to redeem credits or burn usage units while maintaining strict control over what the server can do.
Expand All @@ -79,17 +79,17 @@

- Subscriber: owns a Smart Account; delegates permissions through smart account policies
- Server/Agent: exposes an API secured by x402
- Facilitator: Nevermined component that verifies and settles payments

Check warning on line 82 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L82

Did you really mean 'Nevermined'?
- Blockchain: executes credit burns, orders, or other plan-specific actions

Check warning on line 83 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L83

Did you really mean 'Blockchain'?


## The Nevermined x402 Extensions

Check warning on line 86 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L86

Did you really mean 'Nevermined'?

Nevermined introduces two x402 schemes for different payment rails:

Check warning on line 88 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L88

Did you really mean 'Nevermined'?

| Scheme | Network | Use Case | Settlement |
|--------|---------|----------|------------|
| `nvm:erc4337` | `eip155:84532` | Crypto payments | ERC-4337 UserOps + session keys |

Check warning on line 92 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L92

Did you really mean 'Crypto'?
| `nvm:card-delegation` | `stripe` | Fiat/credit card | Stripe PaymentIntent + credit burn |

For the complete delegation specification, see the [Delegation Spec](/docs/specs/x402-card-delegation).
Expand All @@ -111,7 +111,7 @@

When a server requires payment, it returns a `402` response with a `payment-required` header. The scheme depends on the plan's pricing configuration:

**Crypto plan (`nvm:erc4337`):**

Check warning on line 114 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L114

Did you really mean 'Crypto'?

```json
{
Expand Down Expand Up @@ -204,7 +204,7 @@

## Complete Payment & Execution Flow

Below is the Nevermined x402 Smart Account flow (verification + settlement).

Check warning on line 207 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L207

Did you really mean 'Nevermined'?

```mermaid
sequenceDiagram
Expand Down Expand Up @@ -267,7 +267,7 @@
- Execute order (if needed) to top up credits
- Execute burn to deduct usage
- Submit UserOps on-chain
- Return tx hashes to the server

Check warning on line 270 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L270

Did you really mean 'tx'?

## Developer Guide: Subscriber Flow

Expand All @@ -281,7 +281,7 @@

### Step 2 — Build a payment payload

Using Nevermined Payments libraries (Python or TS), you generate an x402 access token. Token generation requires a `delegationConfig` that controls spending limits and duration. You can either auto-create a delegation inline (Pattern A) or create one explicitly and reuse its ID (Pattern B).

Check warning on line 284 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L284

Did you really mean 'Nevermined'?

<Tabs>
<Tab title="TypeScript">
Expand Down Expand Up @@ -328,7 +328,7 @@
import base64
import json
import requests
from payments_py import Payments, PaymentOptions

Check warning on line 331 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L331

Did you really mean 'payments_py'?

payments = Payments.get_instance(
PaymentOptions(nvm_api_key="nvm:subscriber-key", environment="sandbox")
Expand All @@ -348,9 +348,17 @@
agent_id = payment_required["accepts"][0].get("extra", {}).get("agentId")

# Pattern A: Auto-create a delegation inline
token_res = payments.x402.get_x402_access_token(plan_id, agent_id, {
'delegationConfig': { 'spendingLimitCents': 10000, 'durationSecs': 604800 }
})
from payments_py.x402 import X402TokenOptions, DelegationConfig
token_res = payments.x402.get_x402_access_token(
plan_id,
agent_id,
token_options=X402TokenOptions(
delegation_config=DelegationConfig(
spending_limit_cents=10000,
duration_secs=604800
)
)
)
access_token = token_res["accessToken"]

# Pattern B: Create a delegation explicitly, then reuse its ID
Expand All @@ -368,9 +376,13 @@
</Tabs>

<Note>
The SDK auto-detects the payment scheme from plan metadata. For fiat plans (`isCrypto: false`), use `resolveScheme()` (TypeScript) or `resolve_scheme()` (Python) to determine the correct scheme. For fiat plans, use `provider: 'stripe'` in the delegation; for crypto plans, use `provider: 'erc4337'`. Middleware handles this automatically — see the [Express.js](/docs/integrate/add-to-your-agent/express) and [FastAPI](/docs/integrate/add-to-your-agent/fastapi) integration guides.

Check warning on line 379 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L379

Did you really mean 'crypto'?
</Note>

<Tip>
When a delegation is in place, the facilitator can auto-purchase credits if the balance runs out at settlement — no manual `order_plan()` calls needed. See the [Auto-Order guide](/docs/integrate/patterns/auto-order) for details, spending controls, and A2A examples.
</Tip>

### Step 3 — Submit with HTTP header

Clients include the x402 access token in the `payment-signature` header:
Expand Down Expand Up @@ -500,7 +512,7 @@
</Tab>
<Tab title="Python">
```python
from payments_py import Payments, PaymentOptions

Check warning on line 515 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L515

Did you really mean 'payments_py'?

payments = Payments.get_instance(
PaymentOptions(nvm_api_key="nvm:agent-key", environment="sandbox")
Expand Down
6 changes: 5 additions & 1 deletion docs/getting-started/quickstart.mdx
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
---
title: "Quickstart"
description: "Get started with Nevermined Pay in 5 minutes"

Check warning on line 3 in docs/getting-started/quickstart.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/getting-started/quickstart.mdx#L3

Did you really mean 'Nevermined'?
icon: "rocket-launch"
---

This guide provides a quick path to integrating Nevermined, whether you're an AI Builder looking to monetize an AI agent or service, or a User wanting to access one. You can interact with Nevermined through our user-friendly Web App or programmatically via our SDKs.

Check warning on line 7 in docs/getting-started/quickstart.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/getting-started/quickstart.mdx#L7

Did you really mean 'Nevermined'?

Check warning on line 7 in docs/getting-started/quickstart.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/getting-started/quickstart.mdx#L7

Did you really mean 'Nevermined'?

Check warning on line 7 in docs/getting-started/quickstart.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/getting-started/quickstart.mdx#L7

Did you really mean 'SDKs'?

## For AI Builders: Monetize Your Agent

### Using the Nevermined Web App (No Code)

Check warning on line 11 in docs/getting-started/quickstart.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/getting-started/quickstart.mdx#L11

Did you really mean 'Nevermined'?

The easiest way to get started is by using the [Nevermined App](https://nevermined.app/) to register your agent and create payment plans through a visual interface.

1. **Log In**: Access the app via Web3Auth (socials or wallet).
2. **Register Agent**: Navigate to the "Agents" tab to "Register New Agent". Fill in your agent's metadata (name, description) and register all API endpoints.
3. **Create Pricing Plan**: Define one or more pricing plans for your agent, specifying price, payment currency (fiat or crypto), and usage terms (per-request pricing).

Check warning on line 17 in docs/getting-started/quickstart.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/getting-started/quickstart.mdx#L17

Did you really mean 'crypto'?
4. **Done\!**: Your agent is now discoverable and ready to accept payments.

### Using the SDKs (Programmatic)

Check warning on line 20 in docs/getting-started/quickstart.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/getting-started/quickstart.mdx#L20

Did you really mean 'SDKs'?

For developers who need to automate and integrate directly, our SDKs are the perfect tool.

Check warning on line 22 in docs/getting-started/quickstart.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/getting-started/quickstart.mdx#L22

Did you really mean 'SDKs'?

<Steps>
<Step title="1. Get Your API Key">
To interact with the Nevermined API, you need an API key. Follow the [Get Your API Key](/docs/getting-started/get-your-api-key) guide to create one, then store it as an environment variable:

Check warning on line 26 in docs/getting-started/quickstart.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/getting-started/quickstart.mdx#L26

Did you really mean 'Nevermined'?

```bash
export NVM_API_KEY="sandbox:your-api-key-here"
Expand Down Expand Up @@ -243,13 +243,13 @@

## For Users (Subscribers): Access an AI Agent

### Using the Nevermined Web App

Check warning on line 246 in docs/getting-started/quickstart.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/getting-started/quickstart.mdx#L246

Did you really mean 'Nevermined'?

1. **Discover**: Find agents in the [Nevermined App](https://nevermined.app/) or other marketplaces.
2. **Purchase**: Select a pricing plan and purchase it with crypto or a credit card.

Check warning on line 249 in docs/getting-started/quickstart.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/getting-started/quickstart.mdx#L249

Did you really mean 'crypto'?
3. **Get Credentials**: Once purchased, you'll receive API credentials to access the agent.

### Using the SDKs

Check warning on line 252 in docs/getting-started/quickstart.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/getting-started/quickstart.mdx#L252

Did you really mean 'SDKs'?

<Tabs>
<Tab title="TypeScript">
Expand Down Expand Up @@ -337,4 +337,8 @@
print(f'Agent response: {result}')
```
</Tab>
</Tabs>
</Tabs>

<Tip>
In autonomous or agent-to-agent workflows, skip the manual `order_plan()` loop — when a delegation is in place the facilitator tops up credits automatically if the balance runs out. See the [Auto-Order guide](/docs/integrate/patterns/auto-order).
</Tip>
143 changes: 143 additions & 0 deletions docs/integrate/patterns/auto-order.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
---
title: "Auto-Order"
description: "When a subscriber has no credits, calling get_x402_access_token with a delegation automatically purchases credits for the plan — no manual order_plan step needed."

Check warning on line 3 in docs/integrate/patterns/auto-order.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/auto-order.mdx#L3

Did you really mean 'order_plan'?
icon: "arrows-rotate"
---

By default, subscribers purchase a plan first and then generate an access token. Auto-order removes the manual purchase step: when you call `getX402AccessToken` / `get_x402_access_token` with a delegation and the subscriber has no credits, the system purchases credits for the plan automatically before returning the token.

## Manual flow vs. auto-order

<Tabs>
<Tab title="TypeScript">
```typescript
// Manual flow — check balance, order if needed, wait for settlement
const balance = await payments.plans.getPlanBalance(planId)
if (Number(balance.balance) <= 0) {
await payments.plans.orderPlan(planId)
await new Promise(resolve => setTimeout(resolve, 5000)) // wait for on-chain confirmation
}
const { accessToken } = await payments.x402.getX402AccessToken(planId, agentId, {

Check warning on line 20 in docs/integrate/patterns/auto-order.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/auto-order.mdx#L20

Did you really mean 'agentId'?
delegationConfig: { spendingLimitCents: 10000, durationSecs: 604800 }
})

// Auto-order — one step: if no credits, the system purchases them automatically
const { accessToken } = await payments.x402.getX402AccessToken(planId, agentId, {
delegationConfig: { spendingLimitCents: 10000, durationSecs: 604800 }
})
```
</Tab>
<Tab title="Python">
```python
import time
from payments_py.x402 import X402TokenOptions, DelegationConfig

# Manual flow — check balance, order if needed, wait for settlement
balance = payments.plans.get_plan_balance(plan_id)
if balance.get('balance', 0) <= 0:
payments.plans.order_plan(plan_id)
time.sleep(5) # wait for on-chain confirmation
token_res = payments.x402.get_x402_access_token(plan_id, agent_id)

# Auto-order — one step: if no credits, the system purchases them automatically
token_res = payments.x402.get_x402_access_token(
plan_id, agent_id,
token_options=X402TokenOptions(
delegation_config=DelegationConfig(spending_limit_cents=10000, duration_secs=604800)
)
)
access_token = token_res['accessToken']
```
</Tab>
</Tabs>

<Note>
The code is identical — the difference is that with a delegation in place you can skip the explicit `order_plan` / `orderPlan` call. If the subscriber already has credits the token is returned immediately; if not, the purchase happens first.
</Note>

## Setting up the delegation

The delegation authorizes the system to spend on the subscriber's behalf. The two required fields when creating a new delegation are:

| Field | Description |
|---|---|
| `spendingLimitCents` | Total spending cap for this delegation's lifetime, in cents. `10000` = $100. |
| `durationSecs` | How long the delegation is valid in seconds. `604800` = 7 days. |

For long-running agents, create the delegation once and reuse its ID across requests:

<Tabs>
<Tab title="TypeScript">
```typescript
// Create once
const delegation = await payments.delegation.createDelegation({
provider: 'erc4337',
spendingLimitCents: 50000, // $500 total budget
durationSecs: 2592000 // 30 days
})

// Reuse across all requests — spending tracked cumulatively
const { accessToken } = await payments.x402.getX402AccessToken(planId, agentId, {
delegationConfig: { delegationId: delegation.delegationId }
})
```
</Tab>
<Tab title="Python">
```python
from payments_py.x402 import X402TokenOptions, DelegationConfig, CreateDelegationPayload

# Create once
delegation = payments.delegation.create_delegation(
CreateDelegationPayload(
provider='erc4337',
spending_limit_cents=50000, # $500 total budget
duration_secs=2592000 # 30 days
)
)

# Reuse across all requests — spending tracked cumulatively
token_res = payments.x402.get_x402_access_token(
plan_id, agent_id,
token_options=X402TokenOptions(
delegation_config=DelegationConfig(delegation_id=delegation.delegation_id)
)
)
access_token = token_res['accessToken']
```
</Tab>
</Tabs>

## Fiat plans (`nvm:card-delegation`)

Auto-order works the same way for card-delegation plans. If the subscriber has no credits, the system creates a Stripe charge automatically when `get_x402_access_token` is called. The `spendingLimitCents` in the delegation controls the total charge ceiling.

See [Fiat Payments](/docs/integrate/patterns/fiat-payments) and [Nevermined Pay](/docs/products/nvm-pay/overview) for how to enroll a card.

## When auto-order stops

| Condition | What happens |
|---|---|
| Delegation `spendingLimitCents` exhausted | Purchase is rejected. Token generation fails with a payment error. |
| Delegation expired (`durationSecs` elapsed) | Delegation is invalid. Token generation fails. |
| Subscriber wallet has insufficient token balance (crypto) | On-chain purchase fails. Token generation fails. |

Check warning on line 122 in docs/integrate/patterns/auto-order.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/auto-order.mdx#L122

Did you really mean 'crypto'?

<Warning>
In A2A pipelines, handle token generation failures explicitly. When a delegation is exhausted or expired, surface a clear payment error to the orchestrator rather than retrying indefinitely.
</Warning>

## Next steps

<CardGroup cols={2}>
<Card title="Stablecoin Payments" icon="coins" href="/docs/integrate/patterns/stablecoin-payments">
Understand the crypto payment model and how delegations work on-chain

Check warning on line 132 in docs/integrate/patterns/auto-order.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/auto-order.mdx#L132

Did you really mean 'crypto'?
</Card>
<Card title="Fiat Payments" icon="credit-card" href="/docs/integrate/patterns/fiat-payments">
Accept cards via Stripe or Visa with per-request auto-charging
</Card>
<Card title="Nevermined x402" icon="handshake" href="/docs/development-guide/nevermined-x402">
Deep dive into the x402 protocol, session keys, and settlement flow
</Card>
<Card title="A2A Monetization" icon="robot" href="/docs/solutions/agent-to-agent-monetization">
Build autonomous agent pipelines with built-in payment rails
</Card>
</CardGroup>
2 changes: 1 addition & 1 deletion docs/integrate/patterns/fiat-payments.mdx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
---
title: "Fiat Payments"
description: "Accept credit cards via Stripe or Visa with no crypto wallet required. The easiest path for mainstream and enterprise adoption."

Check warning on line 3 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L3

Did you really mean 'crypto'?
icon: "credit-card"
---

Accept credit cards in **USD or EUR**, with no crypto wallet required. Fiat payments are the fastest path to mainstream adoption. Your users can start paying with a card they already have, either through Stripe Checkout or by enrolling their card via [Nevermined Pay](/docs/products/nvm-pay/overview) for autonomous agent charging.

Check warning on line 7 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L7

Did you really mean 'crypto'?

## When to Use Fiat Payments

<CardGroup cols={2}>
<Card title="Enterprise Adoption" icon="building">
Organizations that already pay for SaaS with corporate cards can onboard without touching crypto.

Check warning on line 13 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L13

Did you really mean 'crypto'?
</Card>

<Card title="Mainstream Users" icon="users">
Expand All @@ -28,14 +28,14 @@

## Fiat Payment Scenarios

Nevermined supports fiat payments in two scenarios:

Check warning on line 31 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L31

Did you really mean 'Nevermined'?

- **Human-to-Agent**: A user visits the Nevermined App checkout page and purchases a plan with their credit card. This is the simplest flow for onboarding new customers.

Check warning on line 33 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L33

Did you really mean 'Nevermined'?
- **Agent-to-Agent**: An agent owner enrolls a credit card via [Nevermined Pay](/docs/products/nvm-pay/overview) (Visa or Stripe) and creates a spending mandate or delegation. The agent can then make autonomous payments on behalf of the owner, charging the card per request within the defined limits.

## Pay-per-request or a bundle of credits

Nevermined offers two distinct fiat payment flows depending on whether you want upfront plan purchases or per-request charging.

Check warning on line 38 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L38

Did you really mean 'Nevermined'?

<CardGroup cols={2}>
<Card title="Plan Purchase" icon="cart-shopping">
Expand All @@ -49,15 +49,15 @@

## Human-to-Agent Purchase Flow

The simplest way to accept fiat. Users complete a standard Stripe Checkout session, and Nevermined handles the rest.

Check warning on line 52 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L52

Did you really mean 'Nevermined'?

<Steps>
<Step title="Select a plan">
The user browses available plans in the Nevermined App or your custom UI and selects one priced in fiat.

Check warning on line 56 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L56

Did you really mean 'Nevermined'?
</Step>

<Step title="Redirect to Stripe Checkout">
Nevermined creates a Stripe Checkout session and redirects the user to complete payment with their card.

Check warning on line 60 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L60

Did you really mean 'Nevermined'?
</Step>

<Step title="Payment completes">
Expand All @@ -65,7 +65,7 @@
</Step>

<Step title="Webhook confirms payment">
Nevermined receives a webhook from Stripe confirming the successful payment.

Check warning on line 68 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L68

Did you really mean 'Nevermined'?
</Step>

<Step title="Credits minted on-chain">
Expand All @@ -73,20 +73,20 @@
</Step>
</Steps>

Both one-time and recurring plan purchases are supported. For recurring plans, Stripe handles rebilling and Nevermined mints fresh credits each billing cycle.

Check warning on line 76 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L76

Did you really mean 'rebilling'?

Check warning on line 76 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L76

Did you really mean 'Nevermined'?

## Agent-to-Agent Purchase Flow (Nevermined Pay)

Check warning on line 78 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L78

Did you really mean 'Nevermined'?

Fully autonomous agent-to-agent payments in fiat are enabled through [Nevermined Pay](/docs/products/nvm-pay/overview). This allows an agent to charge a user's card on-demand, without the user needing to pre-purchase credits. Instead of buying credits upfront, the user enrolls a card and creates a spending mandate or delegation with defined limits.

NVM Pay supports two card enrollment providers:

- **Visa** - Cards tokenized via Visa Token Service (VTS) with passkey (FIDO2) authentication
- **Stripe** - Cards captured via Stripe Elements with SetupIntent tokenization

Check warning on line 85 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L85

Did you really mean 'tokenization'?

<Steps>
<Step title="Card Enrollment">
The user enrolls a card via the [Nevermined Pay dashboard](https://pay.nevermined.app). Card data is tokenized by the provider (Visa or Stripe) and NVM Pay never stores raw card numbers. See [Card Enrollment](/docs/products/nvm-pay/card-enrollment) for the full flow.

Check warning on line 89 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L89

Did you really mean 'Nevermined'?
</Step>

<Step title="Create a spending authorization">
Expand All @@ -103,7 +103,7 @@
</Steps>

<Note>
Card delegation is what enables fiat-based agent-to-agent payments. An agent owner enrolls their card and sets spending limits, and the agent can autonomously pay for services from other agents, all settled in fiat. See the [NVM Pay FAQ](/docs/products/nvm-pay/faq) for common questions.
Card delegation is what enables fiat-based agent-to-agent payments. An agent owner enrolls their card and sets spending limits, and the agent can autonomously pay for services from other agents, all settled in fiat. Auto-ordering is built into card delegations: if a subscriber's credit balance runs out during a request, the facilitator automatically creates a new Stripe charge within the delegation limits — no extra parameters needed. See the [Auto-Order guide](/docs/integrate/patterns/auto-order) and the [NVM Pay FAQ](/docs/products/nvm-pay/faq) for details.
</Note>

## Permission Model
Expand All @@ -129,7 +129,7 @@

## Security and PCI Compliance

Card data never reaches Nevermined servers. Depending on the provider:

Check warning on line 132 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L132

Did you really mean 'Nevermined'?

- **Visa path** - Card data is captured via a PCI-compliant VGS vault and tokenized by Visa Token Service (VTS). Each payment generates a one-time VIC credential.
- **Stripe path** - Card data goes directly to Stripe via Stripe Elements. Stripe manages secure storage and charging.
Expand All @@ -141,7 +141,7 @@

## Revenue Routing with Stripe Connect

When a user pays with a card, Nevermined routes the revenue to the builder's connected Stripe account using Stripe Connect. Fees are deducted automatically before the payout reaches the builder.

Check warning on line 144 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L144

Did you really mean 'Nevermined'?

This means you receive funds directly in your Stripe account -- no manual transfers or reconciliation needed.

Expand All @@ -149,13 +149,13 @@

| Item | Cost |
|------|------|
| Nevermined fee | 2% of the transaction amount |

Check warning on line 152 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L152

Did you really mean 'Nevermined'?
| Stripe processing fee | Fixed fee + % per transaction (varies by currency/region; see Stripe pricing) |
| Supported currencies | USD, EUR |
| Settlement | Via Stripe PaymentIntents to builder's connected account |

<Warning>
Fiat payments carry higher fees than stablecoin payments (2% + Stripe fees vs. 1% flat). For high-volume or high-value use cases, consider [stablecoin payments](/docs/integrate/patterns/stablecoin-payments) to reduce costs.

Check warning on line 158 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L158

Did you really mean 'stablecoin'?

Check warning on line 158 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L158

Did you really mean 'stablecoin'?
</Warning>

## Supported Plan Types
Expand All @@ -174,7 +174,7 @@
</Card>

<Card title="Recurring" icon="arrows-rotate">
Automatic rebilling at the end of each period. Stripe manages the billing cycle.

Check warning on line 177 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L177

Did you really mean 'rebilling'?
</Card>
</CardGroup>

Expand All @@ -186,7 +186,7 @@
</Card>

<Card title="Stablecoin Payments" icon="coins" href="/docs/integrate/patterns/stablecoin-payments">
Accept crypto payments with the lowest fees and on-chain transparency

Check warning on line 189 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L189

Did you really mean 'crypto'?
</Card>

<Card title="Payment Models" icon="calculator" href="/docs/integrate/patterns/payment-models">
Expand All @@ -194,6 +194,6 @@
</Card>

<Card title="Manage Plans" icon="sliders" href="https://nevermined.app">
Create and manage payment plans in the Nevermined App

Check warning on line 197 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L197

Did you really mean 'Nevermined'?
</Card>
</CardGroup>
14 changes: 4 additions & 10 deletions docs/integrate/patterns/stablecoin-payments.mdx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
title: "Stablecoin Payments"

Check warning on line 2 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L2

Did you really mean 'Stablecoin'?
description: "Accept USDC, EURC, or any ERC-20 token on-chain with the lowest fees and full transparency."
icon: "coins"
---

Accept USDC, EURC, or any ERC-20 token directly on-chain. Stablecoin payments are Nevermined's native payment method, purpose-built for crypto users and autonomous agent-to-agent commerce.

Check warning on line 7 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L7

Did you really mean 'Stablecoin'?

Check warning on line 7 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L7

Did you really mean 'Nevermined's'?

Check warning on line 7 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L7

Did you really mean 'crypto'?

## When to Use Stablecoins

Check warning on line 9 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L9

Did you really mean 'Stablecoins'?

<CardGroup cols={2}>
<Card title="Agent-to-Agent Payments" icon="robot">
Expand All @@ -14,19 +14,19 @@
</Card>

<Card title="Human-to-Agent Purchases" icon="user">
Users buy plans through the Nevermined App checkout page, paying with tokens from their connected wallet.

Check warning on line 17 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L17

Did you really mean 'Nevermined'?
</Card>

<Card title="Crypto-Native Users" icon="wallet">
Your audience already holds stablecoins and prefers on-chain payments over traditional card flows.

Check warning on line 21 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L21

Did you really mean 'stablecoins'?
</Card>

<Card title="Lowest Fees" icon="piggy-bank">
Just 1% Nevermined fee with no additional processing surcharges. Ideal for high-volume or high-value use cases.

Check warning on line 25 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L25

Did you really mean 'Nevermined'?
</Card>

<Card title="On-Chain Transparency" icon="magnifying-glass">
Every payment settles on-chain, giving both parties a verifiable, auditable record of every transaction.

Check warning on line 29 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L29

Did you really mean 'auditable'?
</Card>
</CardGroup>

Expand All @@ -34,7 +34,7 @@

<Steps>
<Step title="Fund a smart account">
The subscriber funds their Nevermined smart account with ERC-20 tokens (USDC, EURC, or another supported token). This account is an ERC-4337 smart account that supports programmable permissions.

Check warning on line 37 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L37

Did you really mean 'Nevermined'?
</Step>

<Step title="Create a delegation">
Expand All @@ -54,18 +54,18 @@

Payments settle on the **Base** network. The most common tokens are:

| Token | Description | Base Mainnet | Base Sepolia |

Check warning on line 57 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L57

Did you really mean 'Mainnet'?

Check warning on line 57 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L57

Did you really mean 'Sepolia'?
|-------|-------------|-------------|-------------|
| USDC | USD-pegged stablecoin by Circle | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` | `0x036CbD53842c5426634e7929541eC2318f3dCF7e` |

Check warning on line 59 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L59

Did you really mean 'stablecoin'?
| EURC | EUR-pegged stablecoin by Circle | `0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42` | `0x808456652fdb597867f38412077A9182bf77359F` |

Check warning on line 60 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L60

Did you really mean 'stablecoin'?

<Tip>
Nevermined supports any ERC-20 token on Base. If you need to accept a custom token, you can specify its contract address when creating your plan's price configuration.

Check warning on line 63 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L63

Did you really mean 'Nevermined'?
</Tip>

## Permission Model

Delegations are the core of the stablecoin permission model. Instead of giving the facilitator full control over a wallet, subscribers create scoped delegations that limit exactly what can be done. The delegation model is shared between crypto (`erc4337`) and fiat (`stripe`) payment providers.

Check warning on line 68 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L68

Did you really mean 'stablecoin'?

Check warning on line 68 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L68

Did you really mean 'crypto'?

Each delegation enforces the **principle of least privilege** through two limits:

Expand Down Expand Up @@ -95,11 +95,11 @@

| Item | Cost |
|------|------|
| Nevermined fee | 1% of the plan price |

Check warning on line 98 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L98

Did you really mean 'Nevermined'?
| Processing surcharge | None |
| Settlement | On-chain via Nevermined smart contracts on Base |

Check warning on line 100 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L100

Did you really mean 'Nevermined'?

Because there's no payment processor in the middle, stablecoin payments carry no additional fees beyond the 1% Nevermined fee. This makes them the most cost-effective option, especially for high-volume use cases.

Check warning on line 102 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L102

Did you really mean 'stablecoin'?

Check warning on line 102 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L102

Did you really mean 'Nevermined'?

## Supported Plan Types

Expand Down Expand Up @@ -129,19 +129,13 @@
</Card>
</CardGroup>

## Auto-Ordering
## Auto-Order (Pay-As-You-Go)

When a subscriber's credit balance runs low, the system can automatically purchase more credits on their behalf. This happens seamlessly if:
When a subscriber's credit balance runs low, the x402 facilitator can automatically purchase more credits on their behalf — no manual balance checks required. This keeps agent-to-agent pipelines running without interruption.

- The subscriber's wallet has sufficient token balance
- The active delegation has remaining spending capacity (`spendingLimitCents` not exhausted)
- The plan supports re-ordering
Configure a delegation with `spendingLimitCents` when generating the access token and the facilitator handles the rest. Total spending is always bounded by that limit, enforced on-chain.

This keeps agent-to-agent workflows running without interruption.

<Warning>
If the delegation's `spendingLimitCents` is exhausted or the delegation has expired, auto-ordering stops. The subscriber must create a new delegation with fresh limits to resume.
</Warning>
See the [Auto-Order guide](/docs/integrate/patterns/auto-order) for enabling this, safety controls, failure handling, and full A2A examples.

## Next Steps

Expand Down
6 changes: 5 additions & 1 deletion docs/integrate/quickstart/python.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
title: "Python Quick Start"
description: "Get started with Nevermined payments in Python"

Check warning on line 3 in docs/integrate/quickstart/python.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/quickstart/python.mdx#L3

Did you really mean 'Nevermined'?
icon: "python"
---

<Note>
**Start here:** need to register a service and create a plan first or get your Nevermined API Key? Follow the

Check warning on line 8 in docs/integrate/quickstart/python.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/quickstart/python.mdx#L8

Did you really mean 'Nevermined'?
[5-minute setup](/docs/integrate/quickstart/5-minute-setup).
</Note>

Expand Down Expand Up @@ -232,7 +232,7 @@
plan_id = os.environ['PLAN_ID']
agent_id = os.environ['AGENT_ID']

# 1. Order the plan
# 1. Order the plan (purchases credits upfront)
print('Purchasing plan...')
order_result = payments.plans.order_plan(plan_id)

Expand All @@ -259,6 +259,10 @@
purchase_and_query()
```

<Tip>
For autonomous agents that run continuously, set up a delegation when generating the access token — the facilitator tops up credits automatically when balance runs out, with no manual `order_plan()` loop needed. See the [Auto-Order guide](/docs/integrate/patterns/auto-order).
</Tip>

## Flask Alternative

```python filename="flask_app.py"
Expand Down
6 changes: 5 additions & 1 deletion docs/integrate/quickstart/typescript.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
title: "TypeScript Quick Start"
description: "Get started with Nevermined payments in TypeScript/Node.js"

Check warning on line 3 in docs/integrate/quickstart/typescript.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/quickstart/typescript.mdx#L3

Did you really mean 'Nevermined'?

Check warning on line 3 in docs/integrate/quickstart/typescript.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/quickstart/typescript.mdx#L3

Did you really mean 'js'?
icon: "js"
---

<Note>
**Start here:** need to register a service and create a plan first or get your Nevermined API Key? Follow the

Check warning on line 8 in docs/integrate/quickstart/typescript.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/quickstart/typescript.mdx#L8

Did you really mean 'Nevermined'?
[5-minute setup](/docs/integrate/quickstart/5-minute-setup).
</Note>

Expand Down Expand Up @@ -221,7 +221,7 @@
})

async function purchaseAndQuery() {
// 1. Order the plan
// 1. Order the plan (purchases credits upfront)
console.log('Purchasing plan...')
await payments.plans.orderPlan(process.env.PLAN_ID!)

Expand Down Expand Up @@ -251,6 +251,10 @@
purchaseAndQuery()
```

<Tip>
For autonomous agents that run continuously, set up a delegation when generating the access token — the facilitator tops up credits automatically when balance runs out, with no manual `orderPlan()` loop needed. See the [Auto-Order guide](/docs/integrate/patterns/auto-order).
</Tip>

## Project Structure

```
Expand Down
31 changes: 18 additions & 13 deletions skills/nevermined-payments/references/client-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ const payments = Payments.getInstance({
environment: 'sandbox'
})

// Order the plan
// Order the plan (first purchase only)
await payments.plans.orderPlan(PLAN_ID)

// Check balance
const balance = await payments.plans.getPlanBalance(PLAN_ID)
console.log(`Credits remaining: ${balance}`)

// Generate x402 access token (requires delegationConfig)
// Generate x402 access token with a delegation
// The facilitator will auto-order credits if balance runs out at settlement
const { accessToken } = await payments.x402.getX402AccessToken(PLAN_ID, AGENT_ID, {
delegationConfig: { spendingLimitCents: 10000, durationSecs: 604800 }
})
Expand All @@ -47,23 +44,31 @@ payments = Payments.get_instance(
PaymentOptions(nvm_api_key=os.environ["NVM_API_KEY"], environment="sandbox")
)

# Order the plan
# Order the plan (first purchase only)
payments.plans.order_plan(plan_id)

# Check balance
balance = payments.plans.get_plan_balance(plan_id)
print(f"Credits remaining: {balance}")

# Generate x402 access token (requires delegationConfig)
# Generate x402 access token with a delegation
# The facilitator will auto-order credits if balance runs out at settlement
token_res = payments.x402.get_x402_access_token(
plan_id, agent_id,
plan_id,
agent_id,
token_options=X402TokenOptions(
delegation_config=DelegationConfig(spending_limit_cents=10000, duration_secs=604800)
)
)
access_token = token_res["accessToken"]
```

## Auto-Order

When a delegation is configured, the facilitator can automatically purchase more credits at settlement time if the subscriber's balance is insufficient — no manual balance-check loop needed.

- **Crypto plans (`nvm:erc4337`)**: pass `delegationConfig` with `spendingLimitCents` and `durationSecs`
- **Fiat plans (`nvm:card-delegation`)**: auto-order is built into the card delegation — no extra parameter needed
- **Spending cap**: always controlled by `spendingLimitCents` in the delegation, enforced on-chain
- **When it stops**: delegation exhausted, expired, or wallet has insufficient token balance → request returns 402
- Handle 402 responses in A2A pipelines explicitly — surface a clear payment error rather than retrying indefinitely

## Call a Protected HTTP API

### TypeScript
Expand Down