When to Use
User needs to implement in-app purchases, subscriptions, paywalls, or monetization flows. Agent handles native APIs (StoreKit 2, Google Play Billing), cross-platform SDKs (RevenueCat, Adapty, Qonversion), paywall design, server verification, and subscription analytics.
Quick Reference
| Topic | File |
|---|
| iOS StoreKit 2 | INLINECODE0 |
| Android Billing |
google-play.md |
| Flutter packages |
flutter.md |
| RevenueCat SDK |
revenuecat.md |
| Platform comparison |
platforms.md |
| Server verification |
server.md |
| Paywall design |
paywalls.md |
| Subscription metrics |
analytics.md |
| Testing & sandbox |
testing.md |
Core Rules
1. Choose Your Architecture
| Approach | When to Use | Tradeoff |
|---|
| Native only | Single platform, full control | More code, no cross-platform sync |
| RevenueCat/Adapty |
Cross-platform, fast launch | 1-2% fee, dependency |
| Hybrid | Native + own backend | Full control, more work |
2. Platform SDKs (Managed)
| Platform | Pricing | Best For |
|---|
| RevenueCat | Free <$2.5k MTR, then 1% | Most apps, best docs |
| Adapty |
Free <$10k MTR, then 0.6% | Cost-conscious, A/B paywalls |
| Qonversion | Free <$10k MTR, then 3% | Simple setup |
| Superwall | Paywall-focused | Paywall A/B only |
| Glassfy | Free <$10k, then 0.5% | Budget option |
3. Product Types
| Type | iOS | Android | Use Case |
|---|
| Consumable | ✅ | ✅ | Credits, coins, lives |
| Non-consumable |
✅ | ✅ | Unlock feature forever |
| Auto-renewable | ✅ | ✅ | Subscriptions |
| Non-renewing | ✅ | ❌ | Season pass, time-limited |
4. Server Verification is Non-Negotiable
Never trust client-side validation alone:
- - iOS: App Store Server API with JWS verification
- Android: Google Play Developer API
- RevenueCat: Webhooks + REST API
5. Handle All Transaction States
| State | Action |
|---|
| Purchased | Verify → grant → finish |
| Pending |
Wait, show pending UI |
| Failed | Show error, don't grant |
| Deferred | Wait for parental approval |
| Refunded | Revoke immediately |
| Grace period | Limited access, prompt payment |
| Billing retry | Maintain access during retry |
6. Subscription Lifecycle Events
Must handle all of these (native or via webhooks):
- - INITIALPURCHASE → grant access
- RENEWAL → extend access
- CANCELLATION → mark will-expire
- EXPIRATION → revoke access
- BILLINGISSUE → prompt to update payment
- GRACEPERIOD → limited access window
- PRICEINCREASE → consent required (iOS)
- REFUND → revoke + flag user
- UPGRADE/DOWNGRADE → prorate
7. Restore Purchases Always
Required by App Store guidelines:
- - Prominent restore button
- Works for logged-out users
- Handles family sharing (iOS)
- Cross-device sync
8. Paywall Best Practices
See
paywalls.md for detailed patterns:
- - Show value before price
- Anchor pricing (3 options, highlight middle)
- Free trial prominent
- Social proof if available
- A/B test everything
9. Testing Strategy
| Environment | iOS | Android |
|---|
| Dev/Debug | StoreKit Config file | License testers |
| Sandbox |
Sandbox accounts | Internal testing |
| Production | Real accounts | Production |
Sandbox subscription times:
- - 1 week → 3 minutes
- 1 month → 5 minutes
- 1 year → 1 hour
10. App Store Guidelines
- - No external payment links (anti-steering)
- Must use IAP for digital goods
- Physical goods/services can use Stripe
- Reader apps have exceptions
- 15-30% commission applies
Common Traps
- - Testing with real money → use sandbox/test accounts
- Not finishing transactions → auto-refund (Android 3 days)
- Hardcoding prices → always fetch from store (regional pricing)
- Missing transaction observer → lose purchases made outside app
- No server verification → trivially bypassable
- Ignoring grace period → users churn when they could recover
- Poor paywall UX → kills conversion regardless of price
- Not tracking metrics → can't optimize what you don't measure
- Forgetting restore button → App Store rejection
- Not handling family sharing → confused users
何时使用
用户需要实现应用内购买、订阅、付费墙或变现流程。代理处理原生API(StoreKit 2、Google Play Billing)、跨平台SDK(RevenueCat、Adapty、Qonversion)、付费墙设计、服务器验证和订阅分析。
快速参考
| 主题 | 文件 |
|---|
| iOS StoreKit 2 | storekit.md |
| Android Billing |
google-play.md |
| Flutter 包 | flutter.md |
| RevenueCat SDK | revenuecat.md |
| 平台对比 | platforms.md |
| 服务器验证 | server.md |
| 付费墙设计 | paywalls.md |
| 订阅指标 | analytics.md |
| 测试与沙盒 | testing.md |
核心规则
1. 选择你的架构
| 方案 | 使用场景 | 权衡 |
|---|
| 仅原生 | 单一平台,完全控制 | 代码量更多,无跨平台同步 |
| RevenueCat/Adapty |
跨平台,快速上线 | 1-2%费用,存在依赖 |
| 混合方案 | 原生 + 自有后端 | 完全控制,工作量更大 |
2. 平台SDK(托管型)
| 平台 | 定价 | 最适合 |
|---|
| RevenueCat | 月交易收入<$2.5k免费,之后1% | 大多数应用,文档最佳 |
| Adapty |
月交易收入<$10k免费,之后0.6% | 注重成本,A/B付费墙 |
| Qonversion | 月交易收入<$10k免费,之后3% | 简单设置 |
| Superwall | 专注付费墙 | 仅限付费墙A/B测试 |
| Glassfy | 月收入<$10k免费,之后0.5% | 预算方案 |
3. 产品类型
| 类型 | iOS | Android | 使用场景 |
|---|
| 消耗型 | ✅ | ✅ | 积分、金币、生命值 |
| 非消耗型 |
✅ | ✅ | 永久解锁功能 |
| 自动续期 | ✅ | ✅ | 订阅 |
| 非续期 | ✅ | ❌ | 季票、限时内容 |
4. 服务器验证不可妥协
永远不要只信任客户端验证:
- - iOS:使用JWS验证的App Store Server API
- Android:Google Play Developer API
- RevenueCat:Webhooks + REST API
5. 处理所有交易状态
等待,显示待处理UI |
| 失败 | 显示错误,不授权 |
| 延迟 | 等待家长批准 |
| 已退款 | 立即撤销 |
| 宽限期 | 限制访问,提示付款 |
| 账单重试 | 重试期间保持访问 |
6. 订阅生命周期事件
必须处理所有以下事件(原生或通过webhooks):
- - INITIALPURCHASE → 授予访问权限
- RENEWAL → 延长访问权限
- CANCELLATION → 标记即将过期
- EXPIRATION → 撤销访问权限
- BILLINGISSUE → 提示更新付款方式
- GRACEPERIOD → 有限访问窗口
- PRICEINCREASE → 需要用户同意(iOS)
- REFUND → 撤销 + 标记用户
- UPGRADE/DOWNGRADE → 按比例调整
7. 始终支持恢复购买
App Store指南要求:
- - 明显的恢复按钮
- 适用于已登出用户
- 支持家庭共享(iOS)
- 跨设备同步
8. 付费墙最佳实践
详见 paywalls.md 的详细模式:
- - 先展示价值,再展示价格
- 锚定定价(3个选项,突出中间选项)
- 免费试用要突出
- 如有社交证明则使用
- 对所有内容进行A/B测试
9. 测试策略
| 环境 | iOS | Android |
|---|
| 开发/调试 | StoreKit配置文件 | 许可测试人员 |
| 沙盒 |
沙盒账户 | 内部测试 |
| 生产环境 | 真实账户 | 生产环境 |
沙盒订阅时间:
- - 1周 → 3分钟
- 1个月 → 5分钟
- 1年 → 1小时
10. App Store指南
- - 不允许外部支付链接(反引导)
- 数字商品必须使用IAP
- 实体商品/服务可使用Stripe
- 阅读类应用有例外
- 适用15-30%佣金
常见陷阱
- - 使用真实货币测试 → 使用沙盒/测试账户
- 未完成交易 → 自动退款(Android 3天)
- 硬编码价格 → 始终从商店获取(区域定价)
- 缺少交易观察者 → 丢失应用外购买记录
- 无服务器验证 → 极易被绕过
- 忽略宽限期 → 用户本可恢复却流失
- 付费墙用户体验差 → 无论价格如何都会降低转化率
- 不追踪指标 → 无法优化未测量的内容
- 忘记恢复购买按钮 → App Store拒绝
- 不支持家庭共享 → 用户困惑