View as Markdown

Take a payment#

The person approves the amount and the payee; any other amount or payee is refused.

Level 2: A person whose identity is verified approves with a passkey.
Class irreversible: Cannot be undone. The app creates the approval for that exact request, and it works once.
routes.append(route("POST", "/payees/{payee}/payments", "payments:send", cls="irreversible", level=2,
                    resource="payee:{payee}", amount_field="/amount", summary="Pay someone",
                    body={"amount": "a decimal string, e.g. 40.00", "currency": "e.g. EUR"}))
templates["payments:send"] = "Pay {amount.max} {amount.currency} to {scope}"


@app.post("/payees/<payee>/payments")
def pay(payee):
    # The payee, the amount and the currency are the ones the person approved.
    payment = request.json
    return {"paid": payment["amount"], "currency": payment["currency"], "to": payee}, 201

Run in 8 languages on this version. See the results

What the test proves#

  • the person approves the amount and the payee, then 201
  • another amount, another payee or a second payment needs another approval
  • an approval to pay is never kept by the agent