engineering-stripe-game-payments

Use when implementing game payments, in-app purchases, subscriptions, Stripe webhooks, or monetization flows. Triggers: payments, IAP, subscription, Stripe, checkout, webhooks, monetization.

6 stars

Best use case

engineering-stripe-game-payments is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Use when implementing game payments, in-app purchases, subscriptions, Stripe webhooks, or monetization flows. Triggers: payments, IAP, subscription, Stripe, checkout, webhooks, monetization.

Teams using engineering-stripe-game-payments should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/stripe-game-payments/SKILL.md --create-dirs "https://raw.githubusercontent.com/fcsouza/agent-skills/main/plugins/game-dev/engineering/stripe-game-payments/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/stripe-game-payments/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How engineering-stripe-game-payments Compares

Feature / Agentengineering-stripe-game-paymentsStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Use when implementing game payments, in-app purchases, subscriptions, Stripe webhooks, or monetization flows. Triggers: payments, IAP, subscription, Stripe, checkout, webhooks, monetization.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Stripe Game Payments

## Purpose

In-app purchases, subscriptions, consumables, webhooks, idempotency, and fraud prevention for games using Stripe.

## When to Use

Trigger: payments, Stripe, IAP, in-app purchase, subscription, premium, battle pass, virtual currency, webhook, checkout, monetization

## Prerequisites

- `postgres-game-schema` (player accounts, inventory, currency tables)
- `betterauth-integration` (authenticated player sessions)

## Core Principles

> Sid Meier: "A game is a series of interesting decisions." Monetization should enable interesting decisions, not replace them.

1. **Payments are server-side only** — never trust the client with price, quantity, or entitlement logic
2. **Idempotency keys on every mutation** — prevent double-charges on retries or network failures
3. **Webhook-first fulfillment** — deliver purchases via webhook events, not checkout completion callbacks
4. **Two-phase fulfillment** — record the purchase first, then queue reward delivery separately
5. **Support both one-time and recurring** — consumables (currency packs, items) and subscriptions (battle pass, premium membership)
6. **Currency abstraction** — players buy premium currency, then spend it on items; never sell game items directly for real money
7. **Refund handling** — revoke rewards on chargebacks and refunds automatically
8. **Fraud signals** — velocity checks, suspicious purchase patterns, geographic anomalies

## Step-by-Step Instructions

### 1. Install Dependencies

```bash
bun add stripe
```

### 2. Configure Stripe Client

Use `boilerplate/stripe-setup.ts` to initialize the Stripe SDK, sync your product catalog, and link Stripe customers to player accounts.

### 3. Define Product Catalog

Start with `templates/product-catalog.ts` to define your product types (consumable, subscription, currency bundle, cosmetic) and map them to Stripe price IDs and game rewards.

### 4. Create Checkout Sessions

Use `boilerplate/checkout.ts` to create Stripe Checkout sessions for one-time purchases, subscriptions, and premium currency bundles. Always attach player metadata.

### 5. Handle Webhooks

Implement `boilerplate/webhooks.ts` for signature verification, idempotent event processing, and two-phase fulfillment. Route events to typed handlers defined in `templates/webhook-events.ts`.

### 6. Queue Reward Delivery

After recording a purchase, dispatch a fulfillment job via BullMQ (see `bullmq-game-queues`). The worker grants the items, currency, or subscription entitlement.

### 7. Handle Refunds & Chargebacks

Listen for `charge.refunded` and `charge.dispute.*` events. Revoke granted rewards, deduct premium currency, and flag the player account for review.

### 8. Monitor & Audit

Log every payment event with an audit trail. Track fulfillment status (pending, fulfilled, revoked) and alert on anomalies.

## Code Examples

### Creating a checkout for a currency bundle

```typescript
import { createCurrencyBundleCheckout } from './checkout';

const session = await createCurrencyBundleCheckout({
  playerId: 'player_123',
  priceId: 'price_premium_1000',
  quantity: 1,
  successUrl: 'https://game.example.com/store/success',
  cancelUrl: 'https://game.example.com/store',
});
```

### Creating a subscription checkout

```typescript
import { createSubscriptionCheckout } from './checkout';

const session = await createSubscriptionCheckout({
  playerId: 'player_123',
  priceId: 'price_battle_pass_monthly',
  successUrl: 'https://game.example.com/pass/success',
  cancelUrl: 'https://game.example.com/pass',
});
```

### Processing a webhook event

```typescript
import { handleStripeWebhook } from './webhooks';

app.post('/webhooks/stripe', async ({ request }) => {
  const sig = request.headers.get('stripe-signature')!;
  const body = await request.text();
  await handleStripeWebhook(body, sig);
  return new Response('ok', { status: 200 });
});
```

See `boilerplate/stripe-setup.ts` for client configuration, `boilerplate/checkout.ts` for session creation, `boilerplate/webhooks.ts` for event handling, and `templates/product-catalog.ts` for product definitions.

## Cross-References

- `betterauth-integration` for authenticated player sessions and Stripe customer linking
- `postgres-game-schema` for purchase records, inventory, and currency tables
- `bullmq-game-queues` for async fulfillment job dispatch and processing
- `game-economy-design` for pricing strategy and currency balance design

## Pitfalls & Anti-Patterns

- **Don't fulfill purchases on checkout completion** — always use webhooks; checkout success redirects can be faked or missed
- **Don't skip idempotency keys** — network retries and webhook replays will cause double-charges or double-grants without them
- **Don't store Stripe API keys in client code** — all payment logic must be server-side only
- **Don't sell game items directly for real money** — use a premium currency layer so you can adjust prices without changing Stripe products
- **Don't ignore chargebacks** — unhandled disputes lead to account bans by Stripe; always revoke rewards and flag accounts
- **Don't couple payment processing with reward delivery** — use two-phase fulfillment so a failed reward grant doesn't block payment recording
- **Don't skip webhook signature verification** — unsigned webhooks can be spoofed to grant free items
- **Don't allow unlimited purchase velocity** — rate-limit purchases per player to detect fraud and prevent accidental overspending

## Designer Philosophy

**Sid Meier:** Monetization should enable interesting decisions, not replace them. A well-designed payment system gives players meaningful choices about how they engage with content. Premium currency buys time, not power. A battle pass rewards engagement, not spending. Fair monetization respects player skill and time investment — the best purchases enhance the experience without gating core gameplay.

## Sources

- [Stripe Official Documentation](https://docs.stripe.com)
- [Stripe Checkout Integration Guide](https://docs.stripe.com/payments/checkout)
- [Stripe Webhooks Best Practices](https://docs.stripe.com/webhooks/best-practices)
- [Stripe Gaming & Digital Goods](https://stripe.com/use-cases/gaming)
- [Stripe Idempotent Requests](https://docs.stripe.com/api/idempotent_requests)
- [Stripe Fraud Prevention](https://docs.stripe.com/radar)

Related Skills

game-lore

6
from fcsouza/agent-skills

Adds or updates a single world lore entry (faction, location, NPC, or event) — validates against existing lore for consistency, applies the right template, and updates docs/world-lore.md. Extract the entry type (faction/location/npc/event) and name from the user's message.

game-expand

6
from fcsouza/agent-skills

Adds a new feature to an existing MVP plan — scoped architect interview, scope validation against original plan, and integration into the build sequence. Extract the feature name or description from the user's message. Requires docs/mvp-first-draft.md — run game-architect first.

game-build

6
from fcsouza/agent-skills

Builds a game component from the MVP plan — production TypeScript + Vitest tests + mock dependencies + build registry tracking. Extract the component name from the user's message (or "status" to check progress). Requires docs/mvp-first-draft.md — run game-architect first.

game-balance

6
from fcsouza/agent-skills

Analyzes a game system against design principles — economy health metrics, difficulty curve, reward schedules, and progression cost curves. Flags imbalances with severity levels. Use after creating an MVP plan with game-architect. Extract the analysis scope (economy/difficulty/progression/rewards/all) from the user's message.

game-architect

6
from fcsouza/agent-skills

Comprehensive game MVP interviewer and planner. Interviews you in progressive groups, researches genre conventions and reference games, then produces an actionable MVP First Draft with starter project files. Use when starting a new game project from scratch.

narrative-story-structure-game

6
from fcsouza/agent-skills

Use when designing interactive narratives, branching storylines, player agency systems, non-linear story structures, or act frameworks for games. Triggers: branching narrative, player agency, story arc, interactive story, dialogue.

infrastructure-monitoring-game-ops

6
from fcsouza/agent-skills

Use when implementing game monitoring, structured logging, player telemetry, alerting rules, or performance budgets. Triggers: monitoring, logging, telemetry, alerts, observability, metrics.

infrastructure-claude-code-game-workflow

6
from fcsouza/agent-skills

Use when starting a game project, choosing which skill to read, or navigating the game-dev skill ecosystem. Entry point for AI agents working on game development. Triggers: workflow, which skill, how to start, game project setup.

infrastructure-ci-cd-game

6
from fcsouza/agent-skills

Use when setting up CI/CD pipelines, GitHub Actions workflows, deployment automation, migration safety, or staging environments for game projects. Triggers: CI/CD, GitHub Actions, deployment, pipeline, staging.

engineering-redis-game-patterns

6
from fcsouza/agent-skills

Use when implementing Redis patterns for games — caching, leaderboards, pub/sub messaging, session storage, rate limiting, or ephemeral game state. Triggers: Redis, cache, leaderboard, pub/sub, rate limit, session.

engineering-postgres-game-schema

6
from fcsouza/agent-skills

Use when designing game database schemas, player data models, inventory systems, or working with Drizzle ORM and PostgreSQL for games. Triggers: database, schema, Drizzle, players, inventory, leaderboards, game data.

engineering-matchmaking-system

6
from fcsouza/agent-skills

Use when implementing player matchmaking, skill-based match selection, lobby systems, queue management, or rank-based grouping. Triggers: matchmaking, lobby, queue, ELO, skill-based, rank, match players, pairing, bracket.