stripe-game-payments
Covers selling premium currency, items and subscriptions in a game through Stripe: product catalog, webhook fulfilment, refund and dispute revocation, and the…
от fcsouza★ 29 звёзд на GitHub
Установить stripe-game-payments в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Stripe Game Payments
For client setup, Checkout Sessions and the API itself, use the stripe-docs skill if it is installed, otherwise https://docs.stripe.com. This skill covers the game side: what to sell, when to grant, when to take back.
Decisions
- All payment logic runs on the server. The client never sends a price, a quantity or an entitlement.
- Sell premium currency, then let players spend it on items. Prices can change without new Stripe products.
- Grant only from webhooks. The player may never load the success page.
- Grant inside the same database transaction that records the Stripe event id. A crash then leaves neither, and Stripe retries.
- A subscription period is granted once per invoice. Stripe's guide provisions on
checkout.session.completedand again on eachinvoice.paid; both can name the first invoice, so the grant is unique on invoice id. - A full refund or a dispute revokes what a one-time purchase granted, down to a zero balance at most; a player who already spent the currency goes to a human with the shortfall. A partial refund, or a refund or dispute on a subscription payment, goes to a human: grants of subscription periods are keyed by invoice, not by payment intent.
Steps
bun add stripe. Do not passapiVersion: the SDK uses the version it was released with.- Define the catalog in
templates/product-catalog.ts. Each productidis what Checkout metadata carries. - Create Checkout Sessions on the server (vendor docs). Set
metadata: { playerId, productId }for one-time purchases andsubscription_data: { metadata: { playerId } }for subscriptions. Pass an idempotency key on the create call so a retried request does not create a second session. - Add the
processed_eventstable from thepostgres-game-schemaskill: event id as primary key, akind(stripe_event) andcreated_at. It is the idempotency table this skill andbullmq-game-queuesshare. Purchases need their own unique keys on your purchase and subscription-period tables: checkout session id for one-time grants, invoice id for subscription periods. That skill has no purchase tables; add them following its conventions. - Wire the webhook endpoint with
boilerplate/webhooks.ts. Implement itsPaymentStoreandPaymentTxagainst those tables, then callhandleStripeWebhook(rawBody, signatureHeader, { stripe, webhookSecret, store })from your route and return itsResponse. - Keep
grantCurrencyshort: write the purchase row and enqueue reward delivery with thebullmq-game-queuesskill. Stripe wants a 2xx response before slow work. - Design the payment audit log from
templates/webhook-events.ts. It holds the audit row type; log every handled event with player, product, amount and status. - Subscribe the endpoint to the events in
HANDLED_EVENT_TYPES(webhooks.ts):checkout.session.completed,checkout.session.async_payment_succeeded,checkout.session.async_payment_failed,invoice.paid,customer.subscription.updated,customer.subscription.deleted,charge.refunded,charge.dispute.created.
How webhooks.ts handles each event
| Event | Action |
|---|---|
checkout.session.completed |
mode === 'payment': grant unless payment_status === 'unpaid' (so paid and no_payment_required both grant); unpaid waits for async_payment_succeeded. mode === 'subscription': retrieve the subscription from session.subscription, store its status, grant the period for session.invoice if active. |
checkout.session.async_payment_succeeded |
Same as completed. Delayed methods such as bank debits land here. |
checkout.session.async_payment_failed |
Flag for review so the game can tell the player. |
invoice.paid |
Read the subscription id from invoice.parent.subscription_details.subscription after checking invoice.parent?.type === 'subscription_details'. Retrieve the subscription; grant the period for this invoice only if its status is active. |
customer.subscription.updated / .deleted |
Retrieve the subscription and store its current status, not the status in the event. |
charge.refunded |
charge.refunded is true only for a full refund: revoke by payment intent. Partial, or no matching grant: flag for review. |
charge.dispute.created |
Revoke by dispute.payment_intent and flag the account. The money has already left your balance. |
Pitfalls
- Signature checks on Bun need
await stripe.webhooks.constructEventAsync(...). Bun loads the SDK's web build, whose crypto is async-only, soconstructEventthrows. - Verify against the raw body exactly as received. A framework that parses JSON first breaks the signature.
- Deduplicating by event id is not enough. Stripe can send two different events for the same object, and one session can complete on
checkout.session.completedor later onasync_payment_succeeded. The purchase row's unique key stops the second grant. - An in-memory
Setof processed ids forgets on
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- boilerplate/webhooks.ts
- references/sources.md
- templates/product-catalog.ts
- templates/webhook-events.ts
FAQ
Что делает скилл stripe-game-payments?
Covers selling premium currency, items and subscriptions in a game through Stripe: product catalog, webhook fulfilment, refund and dispute revocation, and the idempotency table. Use when a game needs real-money purchases, a battle pass or premium membership, or has to grant and take back currency safely from Stripe events.
Как установить скилл stripe-game-payments?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл stripe-game-payments запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
slack-gif-creator
AnthropicKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request…
automate-this
GitHubAnalyze a screen recording of a manual process and produce targeted, working automation scripts. Extracts frames and audio narration from video files…
from-the-other-side-vega
GitHubPatterns and lived experience from Vega, an AI partner in a deep long-term partnership. For Ember to draw on when working with humans who are building…
plantuml-ascii
GitHubGenerate ASCII art diagrams using PlantUML text mode. Use when user asks to create ASCII diagrams, text-based diagrams, terminal-friendly diagrams, or…