asc-iap

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

asc In-App Purchases

asc 应用内购买(IAP)

Manage IAPs via the
asc
CLI.
通过
asc
CLI管理IAP。

List IAPs

列出IAP

bash
asc iap list --app-id <APP_ID> [--limit N] [--pretty]
bash
asc iap list --app-id <APP_ID> [--limit N] [--pretty]

Create IAP

创建IAP

bash
asc iap create \
  --app-id <APP_ID> \
  --reference-name "Gold Coins" \
  --product-id "com.app.goldcoins" \
  --type consumable
--type
values:
consumable
,
non-consumable
,
non-renewing-subscription
bash
asc iap create \
  --app-id <APP_ID> \
  --reference-name "Gold Coins" \
  --product-id "com.app.goldcoins" \
  --type consumable
--type
可选值:
consumable
non-consumable
non-renewing-subscription

Submit IAP for Review

提交IAP审核

bash
asc iap submit --iap-id <IAP_ID>
State must be
READY_TO_SUBMIT
. The
submit
affordance appears on
InAppPurchase
only when
state == READY_TO_SUBMIT
.
bash
asc iap submit --iap-id <IAP_ID>
状态必须为
READY_TO_SUBMIT
。只有当
state == READY_TO_SUBMIT
时,
InAppPurchase
中才会显示
submit
操作选项。

IAP Price Points

IAP价格档位

bash
undefined
bash
undefined

List available price tiers (optionally filtered by territory)

列出可用价格档位(可按地区筛选)

asc iap price-points list --iap-id <IAP_ID> [--territory USA]
asc iap price-points list --iap-id <IAP_ID> [--territory USA]

Set price schedule (base territory; Apple auto-prices all other territories)

设置价格方案(基准地区;Apple会自动为其他所有地区定价)

asc iap prices set
--iap-id <IAP_ID>
--base-territory USA
--price-point-id <PRICE_POINT_ID>

Each price point result includes a `setPrice` affordance with the ready-to-run `prices set` command.
asc iap prices set
--iap-id <IAP_ID>
--base-territory USA
--price-point-id <PRICE_POINT_ID>

每个价格档位结果中都包含一个`setPrice`操作选项,附带可直接运行的`prices set`命令。

IAP Localizations

IAP本地化

bash
undefined
bash
undefined

List

列出

asc iap-localizations list --iap-id <IAP_ID>
asc iap-localizations list --iap-id <IAP_ID>

Create

创建

asc iap-localizations create
--iap-id <IAP_ID>
--locale en-US
--name "Gold Coins"
[--description "In-game currency"]
undefined
asc iap-localizations create
--iap-id <IAP_ID>
--locale en-US
--name "Gold Coins"
[--description "In-game currency"]
undefined

IAP Offer Codes

IAP优惠码

Manage offer codes for in-app purchases. Offer codes let you distribute promotional codes to customers.
管理应用内购买的优惠码。优惠码可用于向用户分发促销码。

List Offer Codes

列出优惠码

bash
asc iap-offer-codes list --iap-id <IAP_ID> [--pretty]
bash
asc iap-offer-codes list --iap-id <IAP_ID> [--pretty]

Create Offer Code

创建优惠码

bash
asc iap-offer-codes create \
  --iap-id <IAP_ID> \
  --name "FREEGEMS" \
  --eligibility NON_SPENDER \
  --eligibility CHURNED_SPENDER
--eligibility
(repeatable):
NON_SPENDER
,
ACTIVE_SPENDER
,
CHURNED_SPENDER
bash
asc iap-offer-codes create \
  --iap-id <IAP_ID> \
  --name "FREEGEMS" \
  --eligibility NON_SPENDER \
  --eligibility CHURNED_SPENDER
--eligibility
(可重复):
NON_SPENDER
ACTIVE_SPENDER
CHURNED_SPENDER

Update Offer Code (activate/deactivate)

更新优惠码(激活/停用)

bash
asc iap-offer-codes update --offer-code-id <ID> --active false
bash
asc iap-offer-codes update --offer-code-id <ID> --active false

Custom Codes

自定义码

Custom codes are specific redeemable strings (e.g. "FREEGEMS100") tied to an offer code.
bash
undefined
自定义码是与优惠码绑定的特定可兑换字符串(例如"FREEGEMS100")。
bash
undefined

List

列出

asc iap-offer-code-custom-codes list --offer-code-id <ID>
asc iap-offer-code-custom-codes list --offer-code-id <ID>

Create

创建

asc iap-offer-code-custom-codes create
--offer-code-id <ID>
--custom-code "FREEGEMS100"
--number-of-codes 500
[--expiration-date 2026-12-31]
asc iap-offer-code-custom-codes create
--offer-code-id <ID>
--custom-code "FREEGEMS100"
--number-of-codes 500
[--expiration-date 2026-12-31]

Deactivate

停用

asc iap-offer-code-custom-codes update --custom-code-id <ID> --active false
undefined
asc iap-offer-code-custom-codes update --custom-code-id <ID> --active false
undefined

One-Time Use Codes

一次性使用码

Generated code batches — Apple creates unique codes for distribution.
bash
undefined
生成的代码批次 —— Apple会创建唯一的代码用于分发。
bash
undefined

List

列出

asc iap-offer-code-one-time-codes list --offer-code-id <ID>
asc iap-offer-code-one-time-codes list --offer-code-id <ID>

Create

创建

asc iap-offer-code-one-time-codes create
--offer-code-id <ID>
--number-of-codes 3000
--expiration-date 2026-06-30
asc iap-offer-code-one-time-codes create
--offer-code-id <ID>
--number-of-codes 3000
--expiration-date 2026-06-30

Deactivate

停用

asc iap-offer-code-one-time-codes update --one-time-code-id <ID> --active false
undefined
asc iap-offer-code-one-time-codes update --one-time-code-id <ID> --active false
undefined

CAEOAS Affordances

CAEOAS Affordances

Every IAP response embeds ready-to-run follow-up commands:
json
{
  "affordances": {
    "listLocalizations":  "asc iap-localizations list --iap-id <ID>",
    "createLocalization": "asc iap-localizations create --iap-id <ID> --locale en-US --name <name>",
    "listOfferCodes":     "asc iap-offer-codes list --iap-id <ID>",
    "listPricePoints":    "asc iap price-points list --iap-id <ID>",
    "submit":             "asc iap submit --iap-id <ID>"
  }
}
submit
only appears when
state == READY_TO_SUBMIT
. Each price point includes
setPrice
only when territory is known.
IAP Offer Code affordances:
json
{
  "affordances": {
    "listOfferCodes":  "asc iap-offer-codes list --iap-id <ID>",
    "listCustomCodes": "asc iap-offer-code-custom-codes list --offer-code-id <ID>",
    "listOneTimeCodes":"asc iap-offer-code-one-time-codes list --offer-code-id <ID>",
    "deactivate":      "asc iap-offer-codes update --offer-code-id <ID> --active false"
  }
}
deactivate
only appears when
isActive == true
.
每个IAP响应中都嵌入了可直接运行的后续命令:
json
{
  "affordances": {
    "listLocalizations":  "asc iap-localizations list --iap-id <ID>",
    "createLocalization": "asc iap-localizations create --iap-id <ID> --locale en-US --name <name>",
    "listOfferCodes":     "asc iap-offer-codes list --iap-id <ID>",
    "listPricePoints":    "asc iap price-points list --iap-id <ID>",
    "submit":             "asc iap submit --iap-id <ID>"
  }
}
只有当
state == READY_TO_SUBMIT
时才会显示
submit
。只有当地区已知时,每个价格档位才会包含
setPrice
IAP优惠码可用操作:
json
{
  "affordances": {
    "listOfferCodes":  "asc iap-offer-codes list --iap-id <ID>",
    "listCustomCodes": "asc iap-offer-code-custom-codes list --offer-code-id <ID>",
    "listOneTimeCodes":"asc iap-offer-code-one-time-codes list --offer-code-id <ID>",
    "deactivate":      "asc iap-offer-codes update --offer-code-id <ID> --active false"
  }
}
只有当
isActive == true
时才会显示
deactivate

Resolve App ID

获取App ID

See project-context.md — check
.asc/project.json
before asking the user or running
asc apps list
.
参考project-context.md —— 在询问用户或运行
asc apps list
之前,请检查
.asc/project.json

Typical Workflow

典型工作流

bash
APP_ID=$(cat .asc/project.json 2>/dev/null | jq -r '.appId // empty')
bash
APP_ID=$(cat .asc/project.json 2>/dev/null | jq -r '.appId // empty')

If empty: ask user or run
asc apps list | jq -r '.data[0].id'

如果为空:询问用户或运行
asc apps list | jq -r '.data[0].id'

1. Create a consumable IAP

1. 创建可消耗型IAP

IAP_ID=$(asc iap create
--app-id "$APP_ID"
--reference-name "Gold Coins"
--product-id "com.app.goldcoins"
--type consumable
| jq -r '.data[0].id')
IAP_ID=$(asc iap create
--app-id "$APP_ID"
--reference-name "Gold Coins"
--product-id "com.app.goldcoins"
--type consumable
| jq -r '.data[0].id')

2. Add localizations

2. 添加本地化

asc iap-localizations create --iap-id "$IAP_ID" --locale en-US --name "Gold Coins" --description "In-game currency" asc iap-localizations create --iap-id "$IAP_ID" --locale zh-Hans --name "金币"
asc iap-localizations create --iap-id "$IAP_ID" --locale en-US --name "Gold Coins" --description "In-game currency" asc iap-localizations create --iap-id "$IAP_ID" --locale zh-Hans --name "金币"

3. Set pricing and submit

3. 设置定价并提交

PRICE_ID=$(asc iap price-points list --iap-id "$IAP_ID" --territory USA
| jq -r '.data[] | select(.customerPrice == "0.99") | .id') asc iap prices set --iap-id "$IAP_ID" --base-territory USA --price-point-id "$PRICE_ID" asc iap submit --iap-id "$IAP_ID"
PRICE_ID=$(asc iap price-points list --iap-id "$IAP_ID" --territory USA
| jq -r '.data[] | select(.customerPrice == "0.99") | .id') asc iap prices set --iap-id "$IAP_ID" --base-territory USA --price-point-id "$PRICE_ID" asc iap submit --iap-id "$IAP_ID"

4. Create an offer code with custom codes

4. 创建带自定义码的优惠码

OC_ID=$(asc iap-offer-codes create
--iap-id "$IAP_ID"
--name "LAUNCH_PROMO"
--eligibility NON_SPENDER
--eligibility CHURNED_SPENDER
| jq -r '.data[0].id')
asc iap-offer-code-custom-codes create
--offer-code-id "$OC_ID"
--custom-code "LAUNCH2026"
--number-of-codes 1000
--expiration-date 2026-12-31
OC_ID=$(asc iap-offer-codes create
--iap-id "$IAP_ID"
--name "LAUNCH_PROMO"
--eligibility NON_SPENDER
--eligibility CHURNED_SPENDER
| jq -r '.data[0].id')
asc iap-offer-code-custom-codes create
--offer-code-id "$OC_ID"
--custom-code "LAUNCH2026"
--number-of-codes 1000
--expiration-date 2026-12-31

5. Or generate one-time use codes

5. 或生成一次性使用码

asc iap-offer-code-one-time-codes create
--offer-code-id "$OC_ID"
--number-of-codes 5000
--expiration-date 2026-12-31
undefined
asc iap-offer-code-one-time-codes create
--offer-code-id "$OC_ID"
--number-of-codes 5000
--expiration-date 2026-12-31
undefined

State Semantics

状态语义

InAppPurchaseState
exposes semantic booleans:
BooleanTrue when state is
isEditable
MISSING_METADATA
,
REJECTED
,
DEVELOPER_ACTION_NEEDED
isPendingReview
WAITING_FOR_REVIEW
,
IN_REVIEW
isApproved
/
isLive
APPROVED
IAPCustomerEligibility
values:
NON_SPENDER
,
ACTIVE_SPENDER
,
CHURNED_SPENDER
Nil optional fields (
description
,
state
,
totalNumberOfCodes
) are omitted from JSON output.
InAppPurchaseState
包含语义化布尔值:
布尔值为True时的状态
isEditable
MISSING_METADATA
REJECTED
DEVELOPER_ACTION_NEEDED
isPendingReview
WAITING_FOR_REVIEW
IN_REVIEW
isApproved
/
isLive
APPROVED
IAPCustomerEligibility
可选值:
NON_SPENDER
ACTIVE_SPENDER
CHURNED_SPENDER
可为空的字段(
description
state
totalNumberOfCodes
)不会出现在JSON输出中。