Payment Flow
Charge
sequenceDiagram
participant Buyer
participant Middleware
participant Facilitator
participant App as Seller App
Buyer->>Middleware: Request protected route
Middleware-->>Buyer: 402 + WWW-Authenticate: Payment (charge)
Buyer->>Buyer: Sign XRPL Payment with challenge invoiceId
Buyer->>Middleware: Retry with Authorization: Payment
Middleware->>Facilitator: POST /charge
Facilitator->>Facilitator: Validate and settle XRPL transaction
Facilitator-->>Middleware: PaymentReceipt
Middleware->>App: Forward paid request
App-->>Middleware: Protected response
Middleware-->>Buyer: 200 + Payment-Receipt
- A buyer requests a protected resource.
- The middleware returns
402 Payment Required with WWW-Authenticate: Payment.
- The buyer decodes the challenge request and signs an XRPL
Payment.
- The buyer retries with
Authorization: Payment.
- The middleware forwards the credential to the facilitator.
- The facilitator validates and settles the XRPL transaction.
- The app receives
request.state.mpp_payment, and the response includes Payment-Receipt.
Session
sequenceDiagram
participant Buyer
participant Middleware
participant Facilitator
participant App as Seller App
Buyer->>Middleware: Request session-protected route
Middleware-->>Buyer: 402 + WWW-Authenticate: Payment (session)
Buyer->>Buyer: Sign XRPL prepay with challenge sessionId
Buyer->>Middleware: Authorization: Payment (open) + X-MPP-Session-Id
Middleware->>Facilitator: POST /session (action=open)
Facilitator-->>Middleware: Session receipt + sessionToken
Middleware->>App: Forward paid request
App-->>Middleware: Protected response
Middleware-->>Buyer: 200 + Payment-Receipt
Note over Buyer,Facilitator: Later requests reuse the same session token
Buyer->>Middleware: Authorization: Payment (use)
Middleware->>Facilitator: POST /session (action=use)
Facilitator-->>Middleware: Usage receipt
Middleware->>App: Forward paid request
App-->>Middleware: Protected response
Middleware-->>Buyer: 200 + Payment-Receipt
opt Session balance too low
Buyer->>Middleware: Authorization: Payment (top_up)
Middleware->>Facilitator: POST /session (action=top_up)
Facilitator->>Facilitator: Validate XRPL top-up transaction
Facilitator-->>Middleware: Updated session receipt
Middleware-->>Buyer: 200 + Payment-Receipt
end
opt Session finished
Buyer->>Middleware: Authorization: Payment (close)
Middleware->>Facilitator: POST /session (action=close)
Facilitator-->>Middleware: Closed session receipt
Middleware-->>Buyer: 200 + Payment-Receipt
end
- A buyer requests a session-protected resource.
- The middleware returns a
session challenge.
- The buyer opens the session with a prepaid XRPL transaction.
- Later requests reuse the session with
action="use".
- If balance runs low, the buyer sends
action="top_up".
- When finished, the buyer sends
action="close".