用途
asc-iap 是 asc CLI 工具的一个技能,用于管理 App Store 应用内购买(In-App Purchases,IAP)。它面向需要通过命令行操作 IAP 的开发者,覆盖从创建、本地化、定价到提交审核的完整流程。
主要能力
列出 IAP
asc iap list --app-id <APP_ID> [--limit N] [--pretty]
创建 IAP
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。
提交 IAP 审核
asc iap submit --iap-id <IAP_ID>
状态必须为 READY_TO_SUBMIT。只有当 state == READY_TO_SUBMIT 时,InAppPurchase 上才会出现 submit 操作入口。
IAP 价格点
# 列出可用价格层级(可按地区筛选)
asc iap price-points list --iap-id <IAP_ID> [--territory USA]
# 设置价格表(基准地区;Apple 自动为其他地区定价)
asc iap prices set \
--iap-id <IAP_ID> \
--base-territory USA \
--price-point-id <PRICE_POINT_ID>
每个价格点结果都包含一个 setPrice 操作入口,附带可直接运行的 prices set 命令。
IAP 本地化
# 列出
asc iap-localizations list --iap-id <IAP_ID>
# 创建
asc iap-localizations create \
--iap-id <IAP_ID> \
--locale en-US \
--name "Gold Coins" \
[--description "In-game currency"]
使用方式
CAEOAS 操作入口(Affordances)
每个 IAP 响应都会内嵌可直接运行的后续命令:
{
"affordances": {
"listLocalizations": "asc iap-localizations list --iap-id <ID>",
"createLocalization": "asc iap-localizations create --iap-id <ID> --locale en-US --name <name>",
"listPricePoints": "asc iap price-points list --iap-id <ID>",
"submit": "asc iap submit --iap-id <ID>"
}
}
submit 仅在 state == READY_TO_SUBMIT 时出现。每个价格点仅在地区已知时包含 setPrice。
解析 App ID
参见 project-context.md —— 在询问用户或运行 asc apps list 之前,先检查 .asc/project.json。
典型工作流
APP_ID=$(cat .asc/project.json 2>/dev/null | jq -r '.appId // empty')
# 若为空:询问用户或运行 `asc apps list | jq -r '.data[0].id'`
# 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')
# 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 "金币"
# 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"
状态语义
InAppPurchaseState 暴露语义化布尔值:
| 布尔值 | 为 true 时的状态 |
|---|---|
| isEditable | MISSING_METADATA、REJECTED、DEVELOPER_ACTION_NEEDED |
| isPendingReview | WAITING_FOR_REVIEW、IN_REVIEW |
| isApproved / isLive | APPROVED |
JSON 输出中会省略值为 nil 的可选字段(如 description、state)。
适用场景
- 在开发或发布流程中通过脚本批量创建和管理 IAP。
- 为 IAP 添加多语言本地化信息。
- 查询价格点并设置基准地区定价。
- 在 IAP 状态就绪时提交审核。
限制
- 提交审核要求 IAP 状态为
READY_TO_SUBMIT。 - 价格设置需指定基准地区,其他地区由 Apple 自动定价。
- 资料未提供该技能的收费、价格、平台支持范围等额外信息。