You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/payments.md
+31-3Lines changed: 31 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,12 +29,40 @@ Any resource can be payment-gated by adding a `PaymentCondition` to its ACL:
29
29
When a client requests the resource:
30
30
31
31
1. Server evaluates the ACL and finds the `PaymentCondition`
32
-
2. Server responds with `402 Payment Required` and payment details in the body
33
-
3. Client completes payment and retries with proof
34
-
4. Server verifies and grants access
32
+
2. Server checks the agent's balance in the webledger
33
+
3. If balance >= cost — deducts and serves the resource (200)
34
+
4. If balance < cost — responds with `402 Payment Required` and payment details
35
+
36
+
To fund their balance, users deposit via the `/pay/.deposit` endpoint using a TXO URI (currently testnet4 for development). The balance is tracked in the webledger at `/.well-known/webledgers/webledgers.json`.
35
37
36
38
**Design: fail-closed** — if the server encounters a condition type it doesn't support, access is denied. Unsupported conditions are never silently ignored.
37
39
40
+
#### Quick Demo
41
+
42
+
```bash
43
+
# Start JSS with payments (testnet4 by default)
44
+
jss start --pay --pay-cost 10
45
+
46
+
# Create an article and payment-gated ACL
47
+
curl -X PUT http://localhost:3000/premium/article.jsonld \
0 commit comments