* feat: sell a time-boxed pass through a payment provider, Bitcoin through OrangeCat first - @bitbaum/paykit/checkout: PaymentProvider (createCheckout, status, verifyWebhook), Plan, Checkout, SettledEvent; entitlement helpers and applySettlement, idempotent on the payment id. - @bitbaum/paykit/orangecat: the account-less OrangeCat payment as a provider, and the X-OrangeCat-Signature check. Claude-Session: https://claude.ai/code/session_019MDtmsubNtjznXC5pMf4fD * feat(orangecat): read the payee from OrangeCat payee(id) returns the receiving entity's name, its page and whether it shows an address to pay, so an app can say honestly that nobody can pay it yet. Claude-Session: https://claude.ai/code/session_019MDtmsubNtjznXC5pMf4fD
paykit
Let a website get paid. The website does not hold the money.
pnpm add @bitbaum/paykit
Part of bitbaum. The same behavior ships in OrangeCat today.
Why this exists
A shop, a clinic, or a fundraiser should be able to take a payment without building a wallet, a balance, or a support desk for missing coins. You store where the money should land. The payer uses their own app.
Use
import { classifyPaste, shownRail } from '@bitbaum/paykit';
classifyPaste('bitcoin:bc1q…'); // 'onchain'
classifyPaste('you@coinos.io'); // 'lightning'
classifyPaste('nostr+walletconnect://…'); // 'nwc'
// A code to show. Twint, Monero, anything else. Their app pays it.
shownRail('Twint', qrPayload);
classifyPaste reads the shape of a Bitcoin receive string after stripping the bitcoin: wrapper a wallet copies. It does not check the checksum. A host that moves money still validates before it saves.
A settled rail (Lightning address, Bitcoin address, xpub, wallet-connect) is one the host can ask for a payment. A shown rail is only displayed. paykit does not store keys and does not keep a balance.
Sell a pass
Bitcoin has no recurring charge, so what an app sells is a pass: one payment, a number of days. Paying again before it runs out adds the days to the end.
import { applySettlement, isActive, type Plan } from '@bitbaum/paykit/checkout';
import { orangeCatProvider } from '@bitbaum/paykit/orangecat';
const month: Plan = { id: 'month', days: 30, price: { amount: 21000, currency: 'SAT' }, providerRef: productId };
const provider = orangeCatProvider({ webhookSecret: process.env.ORANGECAT_WEBHOOK_SECRET });
// 1. Something the buyer can pay. Store it: it is the only link back to the buyer.
const checkout = await provider.createCheckout({ plan: month, reference: user.id });
// checkout.invoice is the QR code, checkout.payUrl opens a wallet.
// 2. The provider says it settled (webhook), or the app asks (poll). Both end here.
const verdict = provider.verifyWebhook(rawBody, request.headers);
if (verdict.ok && verdict.event) await applySettlement({ event: verdict.event, plans: [month], store });
const { state } = await provider.status(checkout);
// 3. Gate on the pass.
isActive(entitlement);
PaymentProvider is three calls (createCheckout, status, verifyWebhook) and names no provider. applySettlement grants once per payment however often it is reported, and takes what was bought, by whom and for how much from the checkout the app stored, not from the event. The app supplies the store; settleOnce must be one transaction.
Bitcoin through an OrangeCat account
The seller publishes a product on OrangeCat and connects a wallet there. The provider asks OrangeCat for an invoice that pays that product (POST /api/v1/payments/public), so the money goes from the buyer's wallet to the seller's. It needs no API key.
entityTypesays what is being paid (productby default,projectfor an app's own OrangeCat project).provider.payee(id)reads that entity from OrangeCat: its name, its page, and whether it shows an address to pay. The payee is never typed into the app.- The plan is priced in whole
SAT. The caller states the amount;applySettlementchecks what arrived. - A
payment.settledwebhook names only the payment, never the buyer. Without the stored checkout a settlement cannot be matched. - The webhook is authenticated with
X-OrangeCat-Signature(t=<unix>,v1=<HMAC-SHA-256 of "${t}.${rawBody}">, five minutes' tolerance). Pass the body exactly as received. @bitbaum/paykit/orangecatusesnode:cryptoand belongs on the server.@bitbaum/paykit/checkoutand the root entry run anywhere.
Licence
MIT