12 Commits

Author SHA1 Message Date
534e0e418f fix: create guest customer row before claiming payment
payments.customer_id has an FK to customers; guest checkouts used a
synthetic cus_<session> id that was never inserted, so every live
on-chain confirmation failed with 23503 and the status route 502'd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 19:56:15 +03:00
dea78f6eeb test: pin checkout test clock and cover x402_nonces in schema test
Checkout fixtures are dated 2026-09-29 but expiry reads the wall clock, so
24 tests started failing once the real date passed the checkout window.
The schema test predated the x402_nonces table, which is keyed by the
claimed authorization instead of id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 19:36:07 +03:00
1d92fa23f2 feat: branded hosted storefront per merchant (G12)
Merchants can publish a store (slug, title, tagline, https logo, accent
colour, search description, optional custom domain) through settings or
the dashboard. The checkout app serves it at /store/<slug> with SEO and
Open Graph metadata, listing active products (invoice products hidden)
that each open their payment link, and a middleware rewrites '/' on a
merchant's custom domain to its store when CHECKOUT_PRIMARY_HOSTS is set.
Slugs and domains are unique; public data at /v1/public/stores. Carts of
several products stay out of scope because hosted checkout fulfils one
product per session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 06:32:06 +03:00
f1647a5a81 feat: embeddable checkout overlay (embed.js) with allow-listed success callback (G6, part 1)
apps/checkout/public/embed.js opens a payment link, checkout or invoice
from the same checkout origin in an overlay iframe on any site; links
marked data-settlekit-checkout bind automatically, SettleKit.open() is
available from code, and there is an open-in-new-tab fallback for
wallets that block iframes. The success page posts settlekit:success
only to a site the seller listed under Settings > Embedding
(org embedOrigins, validated https origins), and embed.js only accepts
messages from its checkout frame. Payment requests gain sendEmail and
successUrl so store plugins can redirect buyers and bring them back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 04:52:19 +03:00
a4d0f3f5cb feat: tax at checkout and tax-grade receipts (G4)
Sellers can turn on checkout tax in settings (label, own country and tax
ID, legal name, per-country rates, default rate, EU reverse charge).
Sessions add tax on top of the net price after any promo, so onchain
verification expects the tax-inclusive total. Buyers set billing country
and VAT ID via the API (billingCountry, vatId) or on the hosted checkout
until a payment is recorded; EU cross-border B2B with a VAT ID of the
right shape is zero-rated. Settled checkouts get a PDF receipt (pdfkit)
with the seller's tax ID, buyer country / VAT ID, tax rate and the
settlement transaction, linked from the success page, the receipt email
and the customer portal. packages/tax calculateTax is now used at
checkout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 04:30:53 +03:00
4e97fcc409 feat: promo codes at checkout (G3)
Coupons now reach checkout. POST /v1/checkout-sessions takes an optional
couponCode, payment links accept ?promo=CODE (a refused code falls back to
full price with a notice), and the hosted checkout gets a promo field
while the session is open and unpaid. The discounted total becomes the
session amount before network bindings, so onchain verification expects
the discounted amount and a locked Zcash quote is re-priced. Codes are
tenant-scoped, product-scoped codes discount only their products, and
free-trial or 100% codes are refused. The redemption is counted once
after the payment confirms (API confirm and hosted checkout).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 04:09:54 +03:00
466c662ac3 feat: payable invoices and payment requests (G2)
Invoices can now be paid onchain. POST /v1/invoices/:id/send issues the
invoice, binds a public pay page (/i/<token> on the hosted checkout),
opens a checkout session for the invoice total on the merchant's
networks and emails the link. POST /v1/invoices/requests sends an
ad-hoc amount + memo to an email. The invoice turns paid only when a
confirmed onchain payment exists for one of its sessions (on read in the
API and in the new worker invoice-settle job) and emits invoice.paid.
Invoice and receipt PDFs render with pdfkit (MIT). Voiding cancels open
sessions. Dashboard gets a request-a-payment form, send buttons, pay
links and PDF downloads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 03:35:06 +03:00
ae216e213b fix(checkout): require a wallet signature to bind the EVM payer
The evm/payer route bound any address without proof, so anyone holding the
session URL could lock the buyer out. The buyer's wallet now personal_signs
a short-lived message naming the session, network and payer; the server
verifies it with viem (ECDSA locally, EIP-1271/6492 through the chain RPC
for smart wallets). Unsigned requests never bind or rebind a payer; a new
valid signature may rebind so the real buyer can always recover.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 19:59:00 +03:00
11c91fd1b2 feat(checkout): pay with any token, HyperCore usdSend and Tempo memo enforcement
Any token (replaces the BridgePay/LocalAppKitSdk simulation, now deleted):
- lib/any-token.ts: Relay/LI.FI router from ROUTING_* env, per-session
  destination (the token the verifier checks), policy-checked EXACT_OUTPUT
  quotes stored as session.route, status polling that settles ONLY through
  recordAndConfirm on the destination fill (routed fills skip the payer and
  memo bindings, never payTo/amount/token/time); provider success without a
  qualifying transfer is reported as unverified and stays unpaid
- routes [sessionId]/route/{quote,status} with the same-origin guard
- AnyTokenPay: origin chain + token picker, fees and quote TTL, EIP-6963
  execution of the provider's transactions, deposit-address QR fallback,
  progress, refund notice
- network changes are locked while a route moves funds; a payment confirmed
  by the worker now completes and fulfils the session on the next confirm

HyperCore: runtime (HYPERCORE_*), usdSend params/submit/status routes,
HyperCorePay (wallet signs usdSend, manual hash fallback), verify-payment
case, network options, explorer links.

Tempo: evm params expose memoRequired; sessions with requireMemo only settle
with transferWithMemo(keccak256(sessionId)).

Per-network payment components are lazy-loaded; the Arc demo wallet is
labelled as a simulation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 18:20:35 +03:00
dd2d63e48b feat(checkout): network picker, EVM wallet pay and Zcash pay UI
- NetworkPicker: accepted + verifiable networks grouped Solana / EVM
  chains / Zcash, native radios, asset and honest badges (testnet,
  bridged, transparent)
- EvmPay: EIP-6963 discovery (window.ethereum fallback), payer binding,
  wallet_switchEthereumChain with 4902 -> wallet_addEthereumChain from
  the registry, viem writeContract transfer (TIP-20 transferWithMemo with
  the session memo on Tempo), confirmation polling, explorer link;
  EIP-681 QR + manual transaction-hash fallback
- ZcashPay: ZIP-321 QR (uqr), copy address and exact amount, quote
  countdown and re-quote, 20 s status polling, paste-txid fallback,
  transparent-payment note, late payments shown as under review
- page routes SolanaPay | EvmPay | ZcashPay; Arc demo wallet/bridge cards
  only on Arc; receipt shows the settled asset
- next.config transpiles @settlekit/chains and @settlekit/zcash
- tests for discovery, chain switching, transfer encoding, labels,
  grouping, countdown and ZIP-321 display

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 17:12:13 +03:00
fa072dc24f feat(checkout): network selection, EVM and Zcash payment routes
- POST [sessionId]/network switches between accepted, configured networks
  only while open and unpaid; pins payTo per network, clears the payer,
  adds a Solana reference and locks a ZEC quote (kept while live)
- GET evm/params (registry chain, public RPC for wallet_addEthereumChain,
  exact base units, Tempo memo) and POST evm/payer (payer binding)
- POST zcash/uri (ZIP-321 request) and GET zcash/status (claimed txid or
  cached address scan, confirming / review / paid)
- same-origin guard on state-changing routes; error bodies carry a code
- demo seed sessions accept every chain; the placeholder EVM address is
  only offered on testnets, Solana/Zcash only with configured addresses
- tests: evm-confirm, zcash-confirm, network-select

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 17:03:51 +03:00
56e2121664 test: Solana checkout confirmation, duplicates, idempotency and delivery
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 14:59:16 +03:00