Skip to content

Commit bed9fb6

Browse files
committed
docs: enhance x402 payments documentation with clearer flowchart descriptions and error handling details; update configuration import path
1 parent dbfba4d commit bed9fb6

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

docs/core-concepts/x402-payments.md

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,33 @@ Key points:
3737

3838
```mermaid
3939
flowchart TD
40-
A[User task -> SpoonReact agent] --> B[Step 1: http_probe tool<br/>Probe paywalled URL without payment]
40+
A[User task -> SpoonReact agent] --> B[Step 1: http_probe tool<br/>Unauthenticated probe of paywalled URL]
41+
B -->|HTTP 200| J[Step 4: Agent parses body/headers<br/>No payment required]
4142
B -->|HTTP 402| C[Step 2: x402_paywalled_request tool<br/>Parse paywall requirements]
42-
C --> D[X402PaymentService.build_payment_requirements<br/>Merge paywall + config + overrides]
43-
D --> E["Signer selection<br/>PRIVATE_KEY (preferred)<br/>or Turnkey fallback"]
44-
E --> F["Typed-data build (TransferWithAuthorization)<br/>Chain ID + verifying contract"]
43+
C --> D[Merge paywall + config overrides]
44+
D --> E[Signer selection<br/>PRIVATE_KEY preferred, Turnkey fallback]
45+
E --> F[Typed-data build<br/>TransferWithAuthorization payload]
4546
F --> G[Signature via eth_account or Turnkey]
4647
G --> H[Encode header -> X-PAYMENT]
47-
H --> I[Step 3: Paid retry to target URL]
48-
I -->|HTTP 200 + X-PAYMENT-RESPONSE| J[Step 4: Agent parses body + receipt]
49-
J --> K[Memory/log update + ReAct summary output]
48+
H --> I[Step 3: Paid retry with X-PAYMENT header]
49+
I --> P1
5050
51-
subgraph "Paywall server (your FastAPI router)"
52-
P1[Incoming request with X-PAYMENT] --> P2[verify_payment -> Facilitator API]
53-
P2 --> P3[Optional settle_payment]
54-
P3 --> P4[Invoke target agent/tooling]
55-
P4 --> P5[Return result + X-PAYMENT-RESPONSE header]
51+
subgraph "Paywall server (FastAPI /x402)"
52+
P1[Incoming request carrying X-PAYMENT] --> P2[verify_payment -> Facilitator API]
53+
P2 --> P3{Valid payment?}
54+
P3 -- No --> P4[Return HTTP 402 + error]
55+
P3 -- Yes --> P5[Optional settle_payment]
56+
P5 --> P6[Invoke agent/tooling]
57+
P6 --> P7[Return HTTP 200 + X-PAYMENT-RESPONSE]
5658
end
5759
58-
H -.-> P1
59-
P5 -.-> J
60+
P4 -.-> C
61+
P7 --> J
62+
J --> K[Memory/log update + ReAct summary output]
6063
```
6164

65+
If the paid retry fails (for example `verify_payment` rejects the header or the facilitator reports an error), the paywall server immediately returns another `402` or error payload and the agent decides whether to run `x402_paywalled_request` again with corrected parameters. A successful verification moves straight into settlement and target agent execution, so there is no additional retry cycle once the `X-PAYMENT` header is accepted.
66+
6267
## Operational checklist
6368

6469
1. Use [https://faucet.circle.com/](https://faucet.circle.com/) to mint 0.01 USDC for the public demo.

docs/getting-started/configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ Create a `config.json` file for dynamic configuration:
7272
Test your configuration:
7373

7474
```bash
75-
python -c "from spoon_ai.config.manager import ConfigManager; print('✅ Configuration loaded successfully')"
75+
python -c "from spoon_ai.utils.config_manager import ConfigManager; print('✅ Configuration loaded successfully')"
7676
```
7777

7878
The framework automatically validates your configuration and provides helpful error messages if any issues are detected.
7979

8080
## Next Steps
8181

8282
- [Quick Start](./quick-start.md) - Build your first agent
83-
- [Core Concepts](../core-concepts/agents.md) - Learn about agents
83+
- [Core Concepts](../core-concepts/agents.md) - Learn about agents

0 commit comments

Comments
 (0)