In Game Purchases
Skill Profile
(Select at least one profile to enable specific modules)
Overview
In-game purchases enable monetization through virtual goods and currencies. This guide covers virtual economy, store implementation, and payment integration for building monetization systems that provide value to players while generating revenue.
Why This Matters
- Revenue Generation: In-game purchases are a primary monetization strategy for modern games
- Player Engagement: Well-designed virtual economies increase player retention and engagement
- Compliance: Proper implementation ensures compliance with app store policies and payment regulations
Core Concepts & Rules
1. Core Principles
- Follow established patterns and conventions
- Maintain consistency across codebase
- Document decisions and trade-offs
2. Implementation Guidelines
- Start with the simplest viable solution
- Iterate based on feedback and requirements
- Test thoroughly before deployment
Inputs / Outputs / Contracts
- Inputs:
- Player ID, Item ID, Purchase Type (soft/hard currency/real money)
- Receipt data for IAP validation
- Platform (iOS/Android/Web)
- Entry Conditions:
- Database initialized with currencies, items, and inventory tables
- Payment provider credentials configured (Apple/Google/Stripe)
- Player accounts system implemented
- Outputs:
- Purchase confirmation with transaction ID
- Updated player inventory and currency balances
- Transaction records for analytics
- Artifacts Required (Deliverables):
- Database schema (currencies, items, inventory, transactions)
- Store service implementation
- Payment service with receipt validation
- Inventory service for item management
- Acceptance Evidence:
- Successful purchase flow test results
- Receipt validation test coverage
- Analytics dashboard showing purchase metrics
- Success Criteria:
- Purchase success rate ≥ 99%
- Receipt validation latency < 500ms
- Test coverage ≥ 80%
Skill Composition
- Depends on: Authentication system, Database setup
- Compatible with: Game Analytics, Achievements, User Profiles
- Conflicts with: None
- Related Skills: game-analytics, achievements, payment-gateways
Quick Start / Implementation Example
- Review requirements and constraints
- Set up development environment
- Implement core functionality following patterns
- Write tests for critical paths
- Run tests and fix issues
- Document any deviations or decisions
# Example implementation following best practices
def example_function():
# Your implementation here
pass
Assumptions / Constraints / Non-goals
- Assumptions:
- Development environment is properly configured
- Required dependencies are available
- Team has basic understanding of domain
- Constraints:
- Must follow existing codebase conventions
- Time and resource limitations
- Compatibility requirements
- Non-goals:
- This skill does not cover edge cases outside scope
- Not a replacement for formal training
Compatibility & Prerequisites
- Supported Versions:
- Python 3.8+
- Node.js 16+
- Modern browsers (Chrome, Firefox, Safari, Edge)
- Required AI Tools:
- Code editor (VS Code recommended)
- Testing framework appropriate for language
- Version control (Git)
- Dependencies:
- Language-specific package manager
- Build tools
- Testing libraries
- Environment Setup:
.env.example keys: API_KEY, DATABASE_URL (no values)
Test Scenario Matrix (QA Strategy)
| Type |
Focus Area |
Required Scenarios / Mocks |
| Unit |
Core Logic |
Must cover primary logic and at least 3 edge/error cases. Target minimum 80% coverage |
| Integration |
DB / API |
All external API calls or database connections must be mocked during unit tests |
| E2E |
User Journey |
Critical user flows to test |
| Performance |
Latency / Load |
Benchmark requirements |
| Security |
Vuln / Auth |
SAST/DAST or dependency audit |
| Frontend |
UX / A11y |
Accessibility checklist (WCAG), Performance Budget (Lighthouse score) |
Technical Guardrails & Security Threat Model
1. Security & Privacy (Threat Model)
- Top Threats: Injection attacks, authentication bypass, data exposure
2. Performance & Resources
3. Architecture & Scalability
4. Observability & Reliability
Agent Directives & Error Recovery
(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)
- Thinking Process: Analyze root cause before fixing. Do not brute-force.
- Fallback Strategy: Stop after 3 failed test attempts. Output root cause and ask for human intervention/clarification.
- Self-Review: Check against Guardrails & Anti-patterns before finalizing.
- Output Constraints: Output ONLY the modified code block. Do not explain unless asked.
Definition of Done (DoD) Checklist
Anti-patterns
Reference Links & Examples
- Internal documentation and examples
- Official documentation and best practices
- Community resources and discussions
Versioning & Changelog
- Version: 1.0.0
- Changelog:
- 2026-02-22: Initial version with complete template structure
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: in-game-purchases3description: In-game purchases enable monetization through virtual goods and currencies. Use when this capability is needed.4---56# In Game Purchases78## Skill Profile9*(Select at least one profile to enable specific modules)*10- [ ] **DevOps**11- [x] **Backend**12- [ ] **Frontend**13- [ ] **AI-RAG**14- [ ] **Security Critical**1516## Overview17In-game purchases enable monetization through virtual goods and currencies. This guide covers virtual economy, store implementation, and payment integration for building monetization systems that provide value to players while generating revenue.1819## Why This Matters20- **Revenue Generation**: In-game purchases are a primary monetization strategy for modern games21- **Player Engagement**: Well-designed virtual economies increase player retention and engagement22- **Compliance**: Proper implementation ensures compliance with app store policies and payment regulations2324---2526## Core Concepts & Rules2728### 1. Core Principles29- Follow established patterns and conventions30- Maintain consistency across codebase31- Document decisions and trade-offs3233### 2. Implementation Guidelines34- Start with the simplest viable solution35- Iterate based on feedback and requirements36- Test thoroughly before deployment373839## Inputs / Outputs / Contracts40* **Inputs**:41 - Player ID, Item ID, Purchase Type (soft/hard currency/real money)42 - Receipt data for IAP validation43 - Platform (iOS/Android/Web)44* **Entry Conditions**:45 - Database initialized with currencies, items, and inventory tables46 - Payment provider credentials configured (Apple/Google/Stripe)47 - Player accounts system implemented48* **Outputs**:49 - Purchase confirmation with transaction ID50 - Updated player inventory and currency balances51 - Transaction records for analytics52* **Artifacts Required (Deliverables)**:53 - Database schema (currencies, items, inventory, transactions)54 - Store service implementation55 - Payment service with receipt validation56 - Inventory service for item management57* **Acceptance Evidence**:58 - Successful purchase flow test results59 - Receipt validation test coverage60 - Analytics dashboard showing purchase metrics61* **Success Criteria**:62 - Purchase success rate ≥ 99%63 - Receipt validation latency < 500ms64 - Test coverage ≥ 80%6566## Skill Composition67* **Depends on**: Authentication system, Database setup68* **Compatible with**: Game Analytics, Achievements, User Profiles69* **Conflicts with**: None70* **Related Skills**: [game-analytics](38-gaming-features/game-analytics/SKILL.md), [achievements](38-gaming-features/achievements/SKILL.md), [payment-gateways](30-ecommerce/payment-gateways/SKILL.md)7172---7374## Quick Start / Implementation Example75761. Review requirements and constraints772. Set up development environment783. Implement core functionality following patterns794. Write tests for critical paths805. Run tests and fix issues816. Document any deviations or decisions8283```python84# Example implementation following best practices85def example_function():86 # Your implementation here87 pass88```899091## Assumptions / Constraints / Non-goals9293* **Assumptions**:94 - Development environment is properly configured95 - Required dependencies are available96 - Team has basic understanding of domain97* **Constraints**:98 - Must follow existing codebase conventions99 - Time and resource limitations100 - Compatibility requirements101* **Non-goals**:102 - This skill does not cover edge cases outside scope103 - Not a replacement for formal training104105106## Compatibility & Prerequisites107108* **Supported Versions**:109 - Python 3.8+110 - Node.js 16+111 - Modern browsers (Chrome, Firefox, Safari, Edge)112* **Required AI Tools**:113 - Code editor (VS Code recommended)114 - Testing framework appropriate for language115 - Version control (Git)116* **Dependencies**:117 - Language-specific package manager118 - Build tools119 - Testing libraries120* **Environment Setup**:121 - `.env.example` keys: `API_KEY`, `DATABASE_URL` (no values)122123124## Test Scenario Matrix (QA Strategy)125126| Type | Focus Area | Required Scenarios / Mocks |127| :--- | :--- | :--- |128| **Unit** | Core Logic | Must cover primary logic and at least 3 edge/error cases. Target minimum 80% coverage |129| **Integration** | DB / API | All external API calls or database connections must be mocked during unit tests |130| **E2E** | User Journey | Critical user flows to test |131| **Performance** | Latency / Load | Benchmark requirements |132| **Security** | Vuln / Auth | SAST/DAST or dependency audit |133| **Frontend** | UX / A11y | Accessibility checklist (WCAG), Performance Budget (Lighthouse score) |134135136## Technical Guardrails & Security Threat Model137138### 1. Security & Privacy (Threat Model)139* **Top Threats**: Injection attacks, authentication bypass, data exposure140- [ ] **Data Handling**: Sanitize all user inputs to prevent Injection attacks. Never log raw PII141- [ ] **Secrets Management**: No hardcoded API keys. Use Env Vars/Secrets Manager142- [ ] **Authorization**: Validate user permissions before state changes143144### 2. Performance & Resources145- [ ] **Execution Efficiency**: Consider time complexity for algorithms146- [ ] **Memory Management**: Use streams/pagination for large data147- [ ] **Resource Cleanup**: Close DB connections/file handlers in finally blocks148149### 3. Architecture & Scalability150- [ ] **Design Pattern**: Follow SOLID principles, use Dependency Injection151- [ ] **Modularity**: Decouple logic from UI/Frameworks152153### 4. Observability & Reliability154- [ ] **Logging Standards**: Structured JSON, include trace IDs `request_id`155- [ ] **Metrics**: Track `error_rate`, `latency`, `queue_depth`156- [ ] **Error Handling**: Standardized error codes, no bare except157- [ ] **Observability Artifacts**:158 - **Log Fields**: timestamp, level, message, request_id159 - **Metrics**: request_count, error_count, response_time160 - **Dashboards/Alerts**: High Error Rate > 5%161162163## Agent Directives & Error Recovery164*(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)*165166- **Thinking Process**: Analyze root cause before fixing. Do not brute-force.167- **Fallback Strategy**: Stop after 3 failed test attempts. Output root cause and ask for human intervention/clarification.168- **Self-Review**: Check against Guardrails & Anti-patterns before finalizing.169- **Output Constraints**: Output ONLY the modified code block. Do not explain unless asked.170171172## Definition of Done (DoD) Checklist173174- [ ] Tests passed + coverage met175- [ ] Lint/Typecheck passed176- [ ] Logging/Metrics/Trace implemented177- [ ] Security checks passed178- [ ] Documentation/Changelog updated179- [ ] Accessibility/Performance requirements met (if frontend)180181182## Anti-patterns183#184185## Reference Links & Examples186187* Internal documentation and examples188* Official documentation and best practices189* Community resources and discussions190191192## Versioning & Changelog193194* **Version**: 1.0.0195* **Changelog**:196 - 2026-02-22: Initial version with complete template structure197198---199> Converted and distributed by [TomeVault](https://tomevault.io/claim/amnadtaowsoam) — claim your Tome and manage your conversions.200<!-- tomevault:4.0:skill_md:2026-04-13 -->