购买可能会因多种原因失败,包括网络故障、支付失败或设备设置。您可能希望检查购买失败的原因并提示用户采取行动,但请注意,并非所有商店都提供细粒度的失败信息。
/// <summary>
/// Called when a purchase fails.
/// </summary>
public void OnPurchaseFailed (Product i, PurchaseFailureReason p)
{
if (p == PurchaseFailureReason.PurchasingUnavailable) {
// IAP may be disabled in device settings.
}
}