gplay-iap-setup

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

In-App Purchase Setup for Google Play

Google Play 应用内购买设置

Use this skill when you need to set up monetization for your Android app.
当你需要为你的Android应用设置变现方案时,可以使用本技能。

Product Types

产品类型

  1. In-App Products - One-time or consumable purchases
  2. Subscriptions - Recurring billing with base plans and offers
  1. 应用内商品(IAP) - 一次性购买或可消耗型购买
  2. 订阅服务 - 包含基础方案和优惠的周期性计费

In-App Products (IAP)

应用内商品(IAP)

List products

列出商品

bash
gplay iap list --package com.example.app
bash
gplay iap list --package com.example.app

Create product

创建商品

bash
gplay iap create \
  --package com.example.app \
  --sku premium_upgrade \
  --json @product.json
bash
gplay iap create \
  --package com.example.app \
  --sku premium_upgrade \
  --json @product.json

product.json

product.json

json
{
  "sku": "premium_upgrade",
  "status": "active",
  "purchaseType": "managedUser",
  "defaultPrice": {
    "priceMicros": "990000",
    "currency": "USD"
  },
  "prices": {
    "US": {
      "priceMicros": "990000",
      "currency": "USD"
    },
    "GB": {
      "priceMicros": "799000",
      "currency": "GBP"
    }
  },
  "listings": {
    "en-US": {
      "title": "Premium Upgrade",
      "description": "Unlock all premium features"
    },
    "es-ES": {
      "title": "Actualización Premium",
      "description": "Desbloquea todas las funciones premium"
    }
  }
}
json
{
  "sku": "premium_upgrade",
  "status": "active",
  "purchaseType": "managedUser",
  "defaultPrice": {
    "priceMicros": "990000",
    "currency": "USD"
  },
  "prices": {
    "US": {
      "priceMicros": "990000",
      "currency": "USD"
    },
    "GB": {
      "priceMicros": "799000",
      "currency": "GBP"
    }
  },
  "listings": {
    "en-US": {
      "title": "Premium Upgrade",
      "description": "Unlock all premium features"
    },
    "es-ES": {
      "title": "Actualización Premium",
      "description": "Desbloquea todas las funciones premium"
    }
  }
}

Update product

更新商品

bash
gplay iap update \
  --package com.example.app \
  --sku premium_upgrade \
  --json @product-updated.json
bash
gplay iap update \
  --package com.example.app \
  --sku premium_upgrade \
  --json @product-updated.json

Batch operations

批量操作

bash
undefined
bash
undefined

Update multiple products

更新多个商品

gplay iap batch-update
--package com.example.app
--json @products.json
gplay iap batch-update
--package com.example.app
--json @products.json

Get multiple products

获取多个商品

gplay iap batch-get
--package com.example.app
--skus "premium,coins_100,coins_500"
undefined
gplay iap batch-get
--package com.example.app
--skus "premium,coins_100,coins_500"
undefined

Delete product

删除商品

bash
gplay iap delete \
  --package com.example.app \
  --sku premium_upgrade \
  --confirm
bash
gplay iap delete \
  --package com.example.app \
  --sku premium_upgrade \
  --confirm

Subscriptions

订阅服务

List subscriptions

列出订阅

bash
gplay subscriptions list --package com.example.app
bash
gplay subscriptions list --package com.example.app

Create subscription

创建订阅

bash
gplay subscriptions create \
  --package com.example.app \
  --json @subscription.json
bash
gplay subscriptions create \
  --package com.example.app \
  --json @subscription.json

subscription.json

subscription.json

json
{
  "productId": "premium_monthly",
  "basePlans": [
    {
      "basePlanId": "monthly",
      "state": "ACTIVE",
      "regionalConfigs": [
        {
          "regionCode": "US",
          "price": {
            "priceMicros": "4990000",
            "currency": "USD"
          }
        }
      ],
      "autoRenewingBasePlanType": {
        "billingPeriodDuration": "P1M"
      }
    },
    {
      "basePlanId": "yearly",
      "state": "ACTIVE",
      "regionalConfigs": [
        {
          "regionCode": "US",
          "price": {
            "priceMicros": "49990000",
            "currency": "USD"
          }
        }
      ],
      "autoRenewingBasePlanType": {
        "billingPeriodDuration": "P1Y"
      }
    }
  ],
  "listings": {
    "en-US": {
      "title": "Premium Subscription",
      "description": "Get all premium features"
    }
  }
}
json
{
  "productId": "premium_monthly",
  "basePlans": [
    {
      "basePlanId": "monthly",
      "state": "ACTIVE",
      "regionalConfigs": [
        {
          "regionCode": "US",
          "price": {
            "priceMicros": "4990000",
            "currency": "USD"
          }
        }
      ],
      "autoRenewingBasePlanType": {
        "billingPeriodDuration": "P1M"
      }
    },
    {
      "basePlanId": "yearly",
      "state": "ACTIVE",
      "regionalConfigs": [
        {
          "regionCode": "US",
          "price": {
            "priceMicros": "49990000",
            "currency": "USD"
          }
        }
      ],
      "autoRenewingBasePlanType": {
        "billingPeriodDuration": "P1Y"
      }
    }
  ],
  "listings": {
    "en-US": {
      "title": "Premium Subscription",
      "description": "Get all premium features"
    }
  }
}

Base Plans

基础方案

Base plans define the billing period and price for subscriptions.
基础方案定义了订阅服务的计费周期和价格。

Activate base plan

激活基础方案

bash
gplay baseplans activate \
  --package com.example.app \
  --product-id premium_monthly \
  --base-plan monthly
bash
gplay baseplans activate \
  --package com.example.app \
  --product-id premium_monthly \
  --base-plan monthly

Deactivate base plan

停用基础方案

bash
gplay baseplans deactivate \
  --package com.example.app \
  --product-id premium_monthly \
  --base-plan monthly
bash
gplay baseplans deactivate \
  --package com.example.app \
  --product-id premium_monthly \
  --base-plan monthly

Migrate prices

迁移价格

bash
gplay baseplans migrate-prices \
  --package com.example.app \
  --product-id premium_monthly \
  --base-plan monthly \
  --json @migration.json
bash
gplay baseplans migrate-prices \
  --package com.example.app \
  --product-id premium_monthly \
  --base-plan monthly \
  --json @migration.json

Subscription Offers

订阅优惠

Offers provide discounts, free trials, or introductory pricing.
优惠可提供折扣、免费试用或入门定价。

List offers

列出优惠

bash
gplay offers list \
  --package com.example.app \
  --product-id premium_monthly \
  --base-plan monthly
bash
gplay offers list \
  --package com.example.app \
  --product-id premium_monthly \
  --base-plan monthly

Create offer

创建优惠

bash
gplay offers create \
  --package com.example.app \
  --product-id premium_monthly \
  --base-plan monthly \
  --json @offer.json
bash
gplay offers create \
  --package com.example.app \
  --product-id premium_monthly \
  --base-plan monthly \
  --json @offer.json

offer.json (Free trial)

offer.json (免费试用)

json
{
  "offerId": "trial_7day",
  "state": "ACTIVE",
  "phases": [
    {
      "duration": "P7D",
      "pricingType": "FREE_TRIAL"
    }
  ],
  "regionalConfigs": [
    {
      "regionCode": "US"
    }
  ]
}
json
{
  "offerId": "trial_7day",
  "state": "ACTIVE",
  "phases": [
    {
      "duration": "P7D",
      "pricingType": "FREE_TRIAL"
    }
  ],
  "regionalConfigs": [
    {
      "regionCode": "US"
    }
  ]
}

offer.json (Introductory price)

offer.json (入门定价)

json
{
  "offerId": "intro_50_off",
  "state": "ACTIVE",
  "phases": [
    {
      "duration": "P1M",
      "pricingType": "SINGLE_PAYMENT",
      "price": {
        "priceMicros": "2490000",
        "currency": "USD"
      }
    }
  ]
}
json
{
  "offerId": "intro_50_off",
  "state": "ACTIVE",
  "phases": [
    {
      "duration": "P1M",
      "pricingType": "SINGLE_PAYMENT",
      "price": {
        "priceMicros": "2490000",
        "currency": "USD"
      }
    }
  ]
}

Activate/Deactivate offer

激活/停用优惠

bash
undefined
bash
undefined

Activate

激活

gplay offers activate
--package com.example.app
--product-id premium_monthly
--base-plan monthly
--offer-id trial_7day
gplay offers activate
--package com.example.app
--product-id premium_monthly
--base-plan monthly
--offer-id trial_7day

Deactivate

停用

gplay offers deactivate
--package com.example.app
--product-id premium_monthly
--base-plan monthly
--offer-id trial_7day
undefined
gplay offers deactivate
--package com.example.app
--product-id premium_monthly
--base-plan monthly
--offer-id trial_7day
undefined

Regional Pricing

区域定价

Convert prices

转换价格

bash
gplay pricing convert \
  --package com.example.app \
  --json @price-request.json
bash
gplay pricing convert \
  --package com.example.app \
  --json @price-request.json

price-request.json

price-request.json

json
{
  "basePriceMicros": "4990000",
  "baseCurrency": "USD",
  "targetCurrencies": ["GBP", "EUR", "JPY"]
}
json
{
  "basePriceMicros": "4990000",
  "baseCurrency": "USD",
  "targetCurrencies": ["GBP", "EUR", "JPY"]
}

Common Monetization Patterns

常见变现模式

Pattern 1: Simple IAP

模式1:简单应用内购买

bash
undefined
bash
undefined

One-time premium upgrade

一次性高级解锁

gplay iap create
--package com.example.app
--sku premium_unlock
--json @premium.json
undefined
gplay iap create
--package com.example.app
--sku premium_unlock
--json @premium.json
undefined

Pattern 2: Consumable IAP

模式2:可消耗型应用内购买

bash
undefined
bash
undefined

Coins/gems that can be consumed

可消耗的金币/宝石

gplay iap create
--package com.example.app
--sku coins_100
--json @coins.json
undefined
gplay iap create
--package com.example.app
--sku coins_100
--json @coins.json
undefined

Pattern 3: Subscription with Free Trial

模式3:带免费试用的订阅

bash
undefined
bash
undefined

1. Create subscription

1. 创建订阅

gplay subscriptions create
--package com.example.app
--json @sub.json
gplay subscriptions create
--package com.example.app
--json @sub.json

2. Create free trial offer

2. 创建免费试用优惠

gplay offers create
--package com.example.app
--product-id premium
--base-plan monthly
--json @trial.json
undefined
gplay offers create
--package com.example.app
--product-id premium
--base-plan monthly
--json @trial.json
undefined

Pattern 4: Multi-Tier Subscription

模式4:多档位订阅

json
{
  "productId": "premium",
  "basePlans": [
    {
      "basePlanId": "basic_monthly",
      "price": {"priceMicros": "2990000", "currency": "USD"},
      "billingPeriodDuration": "P1M"
    },
    {
      "basePlanId": "premium_monthly",
      "price": {"priceMicros": "4990000", "currency": "USD"},
      "billingPeriodDuration": "P1M"
    },
    {
      "basePlanId": "premium_yearly",
      "price": {"priceMicros": "49990000", "currency": "USD"},
      "billingPeriodDuration": "P1Y"
    }
  ]
}
json
{
  "productId": "premium",
  "basePlans": [
    {
      "basePlanId": "basic_monthly",
      "price": {"priceMicros": "2990000", "currency": "USD"},
      "billingPeriodDuration": "P1M"
    },
    {
      "basePlanId": "premium_monthly",
      "price": {"priceMicros": "4990000", "currency": "USD"},
      "billingPeriodDuration": "P1M"
    },
    {
      "basePlanId": "premium_yearly",
      "price": {"priceMicros": "49990000", "currency": "USD"},
      "billingPeriodDuration": "P1Y"
    }
  ]
}

Testing

测试

Use test purchases

使用测试购买

In your app code, use test product IDs:
  • android.test.purchased
  • android.test.canceled
  • android.test.refunded
  • android.test.item_unavailable
在你的应用代码中,使用测试商品ID:
  • android.test.purchased
  • android.test.canceled
  • android.test.refunded
  • android.test.item_unavailable

License testing

许可证测试

Add test accounts in Play Console: Settings → License Testing → Add license testers
在Play Console中添加测试账号: 设置 → 许可证测试 → 添加许可证测试人员

Best Practices

最佳实践

  1. Use clear product IDs - e.g.,
    premium_monthly
    , not
    prod_001
  2. Localize descriptions - Provide listings for all supported languages
  3. Set up regional pricing - Don't use same price everywhere
  4. Offer free trials - Increase conversion rates
  5. Test thoroughly - Use test accounts and test product IDs
  6. Monitor conversions - Track which products/offers perform best
  7. Update prices carefully - Price changes affect existing subscribers
  1. 使用清晰的商品ID - 例如
    premium_monthly
    ,而非
    prod_001
  2. 本地化描述 - 为所有支持的语言提供商品列表
  3. 设置区域定价 - 不要在所有地区使用相同价格
  4. 提供免费试用 - 提高转化率
  5. 全面测试 - 使用测试账号和测试商品ID
  6. 监控转化情况 - 追踪哪些商品/优惠表现最佳
  7. 谨慎更新价格 - 价格变动会影响现有订阅用户

Billing Periods

计费周期

  • P1W
    - 1 week
  • P1M
    - 1 month
  • P3M
    - 3 months
  • P6M
    - 6 months
  • P1Y
    - 1 year
  • P1W
    - 1周
  • P1M
    - 1个月
  • P3M
    - 3个月
  • P6M
    - 6个月
  • P1Y
    - 1年