pay-checkout
Skill2 starsChanged 35 days agoMITView on GitHub
Add a working "Buy" button to an app-foundation site with Creem (merchant of record, handles worldwide sales tax, pays out to banks in 80+ countries including mainland China), test mode first, payments recorded in Postgres via a signed webhook. Use when the user says "let my site take payments", "add a pay button", "start charging", "accept money", or a later skill (orders, membership, courses) requires pay-checkout.
- Reads credentials
In this repository20 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/app-foundation/template/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- skills/app-foundation/template/CLAUDE.mdCLAUDE.md
- app-foundationSkill
- auth-loginSkill
- db-backupSkill
- db-connectSkill
- deploy-cloudflareSkill
- domain-setupSkill
- email-sendSkill
- env-secretsSkill
- file-uploadSkill
- github-vercel-deploySkill
- launch-kitSkill
- ops-dashboardSkill
- pay-subscriptionSkill
- pay-webhookSkill
- uptime-alertSkill
- warehouse-siteSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 21
Don't quote Creem's fees from memory.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
pay-checkout
Goal: a signed-in visitor presses Buy now, pays on Creem's checkout page, comes back to "Payment received", and the payment is in pay_payments with a pay.paid event. Test mode first. Follow ../../STACK.md.
Why Creem
- Merchant of record: Creem sells to the buyer and remits VAT/sales tax worldwide; the owner doesn't register for tax in every country.
- Payouts: local bank transfer in its supported countries, which include mainland China and Hong Kong (https://docs.creem.io/merchant-of-record/supported-countries). Stripe doesn't open accounts for mainland China residents; owners with a US/HK company can use Stripe instead (episode 014).
- No SDK needed:
src/lib/pay.tsuses fetch + Web Crypto, so it runs on Vercel and Cloudflare Workers. - Don't quote Creem's fees from memory; check https://www.creem.io/pricing that day.
Rules
- Vercel Hobby forbids commercial use ("any method of requesting or processing payment"). Test mode is fine anywhere; before live keys, the site must run on Cloudflare (deploy-cloudflare) or Vercel Pro. Say so.
- Creem signup, store details, identity verification (KYC) and payout bank details are the owner's. Never fill them in.
CREEM_API_KEYandCREEM_WEBHOOK_SECRETare pasted by the owner into the host, marked secret. Never read, copy or type them. The product ID is not a secret.- The agent never types a card number, not even the test card: the owner pays the test checkout.
- A payment counts only when Creem says so: the success page asks Creem's API, and the webhook is verified with
creem-signature(HMAC-SHA256 of the raw body). Never mark paid from query parameters.
Steps
1. Add the code
node <skill-dir>/scripts/apply.mjs --dir "<project>" --jsonAdds src/db/schema/pay.ts (pay_payments), src/lib/pay.ts, /pricing (product card, Buy button, "My payments"), /pay/success, /api/pay/webhook, the .env.example block, stack.json → installed, a git save point, and the migration if node_modules exists (else run npm run db:generate -- --name pay_checkout). Push.
2. Owner: Creem in test mode
Everything works from a phone browser:
- https://www.creem.io → Sign up → create a store.
- Turn Test Mode on.
- Products → Create product: one-time, any price → copy the
prod_...ID (send it to the agent; not secret). - Developers → API key (test, starts
creem_test_) → paste into the host as secretCREEM_API_KEY. - Developers → Webhooks → add
https://<domain>/api/pay/webhook→ paste its signing secret as secretCREEM_WEBHOOK_SECRET.
Agent sets CREEM_PRODUCT_ID (plain text) with the owner's OK. Cloudflare redeploys on save; on Vercel, redeploy.
3. Verify
/pricingshows the product name and price with a TEST MODE badge; signed out it says "Sign in to buy".- Owner presses Buy now → Creem checkout → test card
4111 1111 1111 1111, any future date, any CVC → back on/pay/successwith "Payment received". /pricing→ "My payments" shows ✅ Paid with the amount;core_eventshaspay.paid.- Webhook: Creem → Developers → Webhooks shows a 200 delivery. A request with a wrong signature gets 401.
4. Going live (owner, when ready)
Complete Creem's store verification and payout details, switch the product and keys to live mode, update CREEM_API_KEY, CREEM_WEBHOOK_SECRET (live webhook) and CREEM_PRODUCT_ID, and make sure production isn't on Vercel Hobby.
Using it in code
import { startCheckout } from "@/lib/pay";
const url = await startCheckout({ id: user.id, email: user.email }, "prod_...");
redirect(url);Systems that sell things (orders, membership, courses) listen for pay.paid in core_events; its payload has userId, productId, amount, currency, mode.
Troubleshooting
See references/troubleshooting.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

