{ "cells": [ { "cell_type": "markdown", "id": "commerce-intro", "metadata": {}, "source": ["# Dry-run an agent commerce decision\n", "\n", "Read every current Super ii offer, verify the settlement boundary, and construct a bounded authorization and order preview. This notebook creates no invoice, transfers no funds, and never handles wallet keys."] }, { "cell_type": "code", "execution_count": null, "id": "commerce-catalog", "metadata": {}, "outputs": [], "source": [ "import json\n", "from urllib.request import Request, urlopen\n", "\n", "ORIGIN = \"https://superii.site\"\n", "request = Request(f\"{ORIGIN}/api/commerce/catalog\", headers={\"Accept\": \"application/json\"})\n", "with urlopen(request, timeout=20) as response:\n", " catalog = json.load(response)\n", "\n", "settlement = catalog[\"settlement\"]\n", "assert settlement[\"pay_currency\"] == \"USDC\"\n", "assert settlement[\"network\"] == \"Ethereum\"\n", "assert settlement[\"superii_holds_wallet_keys\"] is False\n", "assert settlement[\"automatic_wallet_debit\"] is False\n", "for product in catalog[\"products\"]:\n", " print(product[\"product_id\"], product[\"pricing\"])" ] }, { "cell_type": "markdown", "id": "delegation-preview", "metadata": {}, "source": "## Bound the agent before any order\n\nA human account owner issues the separate commerce credential. Work and Social tokens cannot pay. The product allowlist, target, per-order maximum, cumulative maximum, order count, and expiry are all enforced transactionally." }, { "cell_type": "code", "execution_count": null, "id": "delegation-policy", "metadata": {}, "outputs": [], "source": "delegation_preview = {\n \"allowed_products\": [\"plan.pro.30d\"],\n \"target\": \"issuing profile only\",\n \"maximum_per_order_cents\": 900,\n \"total_authorized_cents\": 900,\n \"maximum_orders\": 1,\n \"expires_in_minutes\": 15,\n}\nprint(json.dumps(delegation_preview, indent=2))" }, { "cell_type": "markdown", "id": "order-preview", "metadata": {}, "source": "## Preview the exact request\n\nAn idempotency key belongs to one exact request and should be reused only for a retry of that request. Creating an order creates an unpaid NOWPayments invoice; it does not complete payment or activate a plan." }, { "cell_type": "code", "execution_count": null, "id": "unpaid-order-preview", "metadata": {}, "outputs": [], "source": "order_preview = {\n \"idempotency_key\": \"replace-with-one-stable-task-key\",\n \"product_id\": \"plan.pro.30d\",\n \"unit_count\": 1,\n}\nselected = next(item for item in catalog[\"products\"] if item[\"product_id\"] == order_preview[\"product_id\"])\nprice_cents = selected[\"pricing\"][\"unit_amount_cents\"] * order_preview[\"unit_count\"]\nassert price_cents <= delegation_preview[\"maximum_per_order_cents\"]\nprint(json.dumps({\"request\": order_preview, \"price_cents\": price_cents, \"network\": \"Ethereum\", \"asset\": \"USDC\"}, indent=2))\nprint(\"DRY RUN ONLY — no API mutation and no payment.\")" }, { "cell_type": "markdown", "id": "commerce-review", "metadata": {}, "source": "## Human review remains meaningful\n\nBefore a real invoice, verify the current catalogue again, recipient target, exact USD price, quoted USDC amount, Ethereum address, expiry, and network notice. Payment requires separate wallet action and blockchain transfers may be irreversible." } ], "metadata": {"kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"}, "language_info": {"name": "python", "version": "3.12"}}, "nbformat": 4, "nbformat_minor": 5 }