IAP.getProductItemList
功能说明
获取可通过应用内购购买的商品列表。在进入商品列表页面时调用。
Toss App Android/iOS 5.219.0 可在以上版本使用。若在不支持的版本中调用则 UNSUPPORTED_APP_VERSION 会发生错误。
类型
IAP.getProductItemList(): Promise<{ products: IapProductListItem[] }>;Params
无
Response
type ConsumableProductListItem = {
sku: string;
type: "CONSUMABLE";
displayName: string;
displayAmount: string;
iconUrl: string;
description: string;
};
type NonConsumableProductListItem = {
sku: string;
type: "NON_CONSUMABLE";
displayName: string;
displayAmount: string;
iconUrl: string;
description: string;
};
type Offer =
| { type: "FREE_TRIAL"; offerId: string; period: string }
| {
type: "NEW_SUBSCRIPTION";
offerId: string;
period: string;
displayAmount: string;
}
| {
type: "RETURNING";
offerId: string;
period: string;
displayAmount: string;
};
type SubscriptionProductListItem = {
sku: string;
type: "SUBSCRIPTION";
displayName: string;
displayAmount: string;
iconUrl: string;
description: string;
renewalCycle: "WEEKLY" | "MONTHLY" | "YEARLY";
offers?: Offer[];
};
type IapProductListItem =
| ConsumableProductListItem
| NonConsumableProductListItem
| SubscriptionProductListItem;错误
错误代码是 catch 到的错误的 error.code 值。
代码
说明
UNSUPPORTED_APP_VERSION
如果当前运行的 Toss App 版本不支持此功能,调用后会立即发生。 IAP.getProductItemList.isSupported()可通过它提前确认,发生时 error.message请向用户显示(更新提示文案)。
示例代码
这有帮助吗?