mirror of
https://github.com/hanzoai/commerce.git
synced 2026-11-23 16:49:29 +00:00
* wip: stripe stablecoin + grant adapter * Headless agentic commerce through Stripe: shared payment tokens, stablecoin top-ups, token-backed subscriptions - GET /v1/billing/catalog and /discovery: a USD catalog of plans and credit packs, the payment types the account can take now, and the checkout verbs. - Checkouts an agent creates, updates and completes in JSON (POST/PATCH/GET /v1/billing/checkouts, POST .../complete with an Idempotency-Key, GET /v1/billing/orders/:id). The charge is bound to the checkout, the buyer and the key; completing twice is one purchase. - Shared payment tokens: the granted token is read and validated (seller, mode, currency, expiry, what is left on it, revocation) before any charge, then charged through the card adapter with payment_method_data[shared_payment_granted_token]. Refusals are typed (token_expired, token_revoked, token_over_limit, token_wrong_currency, token_wrong_merchant, token_not_recurring); a bank's authentication step is authentication_required with the intent and client secret, never a success. - Subscriptions: a token whose usage limits carry a recurring interval is the subscription's payment method and renews it; a one-time token pays the first period and is dropped. A renewal the token cannot cover leaves the subscription past due and announces renewal.action_required with a code and the path to supply a fresh token (POST /v1/billing/invoices/:id/agent-token). - Stablecoins through Stripe only, headless: POST /v1/billing/topup/crypto opens a deposit-mode PaymentIntent and returns the address per network (base, solana, tempo); USD only; credited once on payment_intent.succeeded. Crypto rails default to Stripe stablecoins, and a crypto method is shown only where the account can take stablecoins now. Testing: go test ./api/... ./payment/... (non-live); live Stripe test mode with the sandbox token helpers: top-up credits once and a replayed webhook adds nothing; over-limit, wrong currency, revoked, expired and another seller's tokens are refused with no credit and the checkout stays usable; 3-D Secure is a typed step; a subscription renews on a recurring token, fails over its limit and when revoked with the renewal action, is paid by a fresh token, and a one-time token never renews. Risk: new endpoints; crypto rails default to Stripe stablecoins only. How to revert: git revert this commit.