using System; using PhxhSDK; using System.Collections.Generic; public class IAPManager : Singlenton { private IAPHandle _helper; public void Init() { _helper = new IAPHandle(); } /// /// 添加商品并初始化IAP /// public void AddGoods(List consumableGoods, List nonConsumableGoods, Action onRestorePurchase = null) { _helper.ConsumableGoods = consumableGoods; _helper.NonConsumableGoods = nonConsumableGoods; _helper.OnRestorePurchase = onRestorePurchase; try { _helper.InitIap(); } catch (Exception e) { DebugUtil.LogError("Add Goods Failed, Error: {0}", e.Message); } } /// /// 购买商品 /// public void BuyGoods(string goodsName, string actorId, Action onPurchaseSuccess, Action onPurchaseFail) { _helper.BuyGoods(goodsName, actorId, onPurchaseSuccess, onPurchaseFail); } /// /// 设为客户端验证凭证 /// public void SetClientVerify(bool clientVerify = false) { _helper.ClientVerify = clientVerify; } /// /// 恢复购买 TODO:待测试 /// public void RestorePurchase(Action> restorePurchase) { _helper.RestorePurchase(restorePurchase); } /// /// 购买成功回掉函数 /// public void OnReceiveReceipt(Action onResult) { _helper.SendReceiptAction = onResult; } /// /// 服务器验证成功后操作 /// public void ReceiveServerReceipt(string receipt) { _helper.RemovePendingOrder(receipt); } }