当订阅有折扣价时,我得到两个价格,但无法区分用户是否有资格使用折扣。
当我使用
queryProductDetails
方法根据产品id获取List时,获取到的List的长度为2,分别是优惠价和正常价,但我不知道应该向页面显示哪一个用户。 ProductDetails中没有列出用户是否有资格使用折扣,实际支付的价格可能与显示的价格有所不同。我想向用户展示他支付的实际价格。我该怎么办?
Set<String> kIds = <String>{productId!};
final ProductDetailsResponse response =
await _iap.queryProductDetails(kIds);
if (response.notFoundIDs.isNotEmpty) {
if (response.error != null) _handleError(response.error!);
}
List<ProductDetails> products = response.productDetails;
List<ProductDetails> products =
await IAPUtil.showSaleProducts(modeEntity.productId);
if (products.isNotEmpty) {
vipModeList[i].priceUnit = products.first.currencySymbol;
if (Platform.isAndroid) {
if (products.first is GooglePlayProductDetails) {
ProductDetailsWrapper skuDetails =
(products.first as GooglePlayProductDetails).productDetails;
print('优惠长度:${skuDetails.subscriptionOfferDetails?.length}');
vipModeList[i].vipPrice = '${products.first.rawPrice}';
if (skuDetails.subscriptionOfferDetails?.length == 1) {
vipModeList[i].oldPrice = '';
} else {
vipModeList[i].oldPrice = '${products.last.rawPrice}';
}
}
// vipModeList[i].vipPrice = '${products.first.rawPrice}';
// vipModeList[i].oldPrice = '';
// if (products.length > 1) {
// vipModeList[i].oldPrice = '${products.last.rawPrice}';
// }
} else {
if (products.first is AppStoreProductDetails) {
SKProductWrapper skProduct =
(products.first as AppStoreProductDetails).skProduct;
vipModeList[i].oldPrice = '';
vipModeList[i].vipPrice = '${products.first.rawPrice}';
if (skProduct.introductoryPrice != null) {
vipModeList[i].oldPrice = '${products.first.rawPrice}';
vipModeList[i].vipPrice = skProduct.introductoryPrice!.price;
}
}
}
}
我处理了通过这种方式获得的产品数据,但不确定这是否是最好的方法