/// <summary> /// 交易购买完成. /// </summary> /// <param name="iProductID">产品ID.</param> /// <param name="iQuantity">数量.</param> /// <param name="iTransactionID">交易ID.</param> /// <param name="iReceipt">收据.</param> private void OnIAPTransactionPurchased(string iProductID, Int32 iQuantity, string iTransactionID, string iReceipt) { this.Info("OnIAPTransactionPurchased():ProductID:{0}({1}) TransactionID::{2} Receipt::{3}", iProductID, iQuantity, iTransactionID, iReceipt); // 切换状态 -> 完成 // this.SwitchState (IAPState.Runing); this.ActiveStep = IAPActionStep.ReceiptVerifying; this.ActiveTransactionID = iTransactionID; this.ActiveReceipt = iReceipt; this.Info("OnIAPTransactionPurchased():ActiveTransactionID:{0}", this.ActiveTransactionID); this.Info("OnIAPTransactionPurchased():ActiveReceipt:{0}", this.ActiveReceipt); // 开始计时 if (null != this._timeCounter) { this._timeCounter.RestartCounter(); } IAPRequestBase <T4, T5> request = this.CreateReceiptVerifyRequest( this.ActiveOrderID, iTransactionID, iReceipt, this.OnResponsedReceiptVerify); if (null != request) { request.Send(); } }
/// <summary> /// 超时确认回调函数. /// </summary> protected virtual void OnTimeoutRetry() { this.Info("OnTimeoutRetry():ActiveStep::{0}", this.ActiveStep); // 切换状态 -> 继续执行 this.SwitchState(IAPState.Runing); switch (this.ActiveStep) { case IAPActionStep.ProductsVerifying: { // 开始验证产品列表 this.UToIAPProductsVerify(); } break; case IAPActionStep.Ordering: { // 追加订单 Action IAPRequestBase <T1, T2, T3> request = CreateOrderRequest(this.ActiveIAPItem, this.OnResponsedOrdered); if (null != request) { request.Send(); } } break; case IAPActionStep.Purchasing: { if (null != this._IAPInstance) { this._IAPInstance.StartTransaction( this.ActiveProductID, this.ActiveQuantity); } } break; case IAPActionStep.ReceiptVerifying: { IAPRequestBase <T4, T5> request = this.CreateReceiptVerifyRequest( this.ActiveOrderID, this.ActiveTransactionID, this.ActiveReceipt, this.OnResponsedReceiptVerify); if (null != request) { request.Send(); } } break; default: {} break; } }
/// <summary> /// 购买IAP Item. /// </summary> /// <param name="iIAPItemId">IAP Item ID.</param> /// <param name="iProductID">产品ID.</param> /// <param name="iQuantity">数量.</param> protected virtual void UToIAPBuyItem(T1 iIAPItem) { // 执行动作 this.SwitchState(IAPState.Runing); // 下订单中 this.ActiveStep = IAPActionStep.Ordering; this.ActiveProductID = iIAPItem.ProductId; this.ActiveQuantity = iIAPItem.Quantity; this.Info("UToIAPBuyItem():{0}", iIAPItem.ToString()); // 追加订单 Action IAPRequestBase <T1, T2, T3> request = CreateOrderRequest(iIAPItem, this.OnResponsedOrdered); if (null != request) { request.Send(); } }