Esempio n. 1
0
        //购买失败
        public void OnPurchaseFailed(Product e, PurchaseFailureReason p)
        {
            //var wrapper = (Dictionary<string, object>)MiniJson.JsonDecode(e.receipt);
            //var store = (string)wrapper["Store"];

            //var payload = (string)wrapper["Payload"];
            //ISGoogle = true;
            //var gpDetails = (Dictionary<string, object>)MiniJson.JsonDecode(payload);
            //var gpJson = (string)gpDetails["json"];
            //var gpSig = (string)gpDetails["signature"];

            //NetworkManager.(CLIENT_CUSTOM_MESSAGE_ENUM.CLIENT_CUSTOMMSG_GOOGLE_DELIVERY, (int)p, gpJson, gpSig);
            if (p == PurchaseFailureReason.UserCancelled)
            {
                mPayCallback(-2000, null);
            }
            else
            {
                if (p == PurchaseFailureReason.PurchasingUnavailable || p == PurchaseFailureReason.DuplicateTransaction)
                {
                    OnConfirmProduct(e.definition.id);
                }
                mPayCallback(-3000, null);
                //OnConfirmProduct(e.definition.id);
            }
            currenTransaction = null;
            EB.Debug.Log("购买失败--------------------" + p.ToString());
        }
Esempio n. 2
0
 //发起UnityIAP 支付请求
 public void Pay(EB.IAP.Item item, EB.IAP.Transaction transaction, Action <int, object> callback)
 {
     EB.Debug.Log("---------------------------GoogleSDKManager.Pay------------------------");
     currenTransaction = transaction;
     mPayCallback      = callback;
     if (!IsInitialized())
     {
         EB.Debug.LogError("GoogleSDKManager.Pay: not initialized");
         return;
     }
     EB.Debug.Log("---------------------------GoogleSDKManager.BuyProduct------------------------" + item.payoutId.ToString());
     BuyProduct(item.payoutId.ToString(), transaction.transactionId);
 }
Esempio n. 3
0
        /// <summary>
        /// //购买成功和恢复成功的回调,可以根据id的不同进行不同的操作
        /// </summary>
        /// <param name="e">回调的商品列表</param>
        /// <returns></returns>
        public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e)
        {
            EB.Debug.Log("购买处理成功--------------------Google返回数据");
            EB.Debug.Log("receipt:" + e.purchasedProduct.receipt);
            CrossPlatformValidator validator = new CrossPlatformValidator(GooglePlayTangle.Data(), AppleTangle.Data(), Application.identifier);
            var result = validator.Validate(e.purchasedProduct.receipt);
            Dictionary <string, string> data = new Dictionary <string, string>();
            List <Transaction>          cacheTransactions;

            foreach (IPurchaseReceipt receipt in result)
            {
                EB.Debug.Log("------------IPurchaseReceipt---------------");
                GooglePlayReceipt google = receipt as GooglePlayReceipt;
                if (google != null)
                {
                    string eProductId = e.purchasedProduct.definition.id;
                    if (currenTransaction == null)
                    {
                        SparxTransactionHelper.GetTranByPayoutId(int.Parse(eProductId), out cacheTransactions);
                        if (cacheTransactions == null || cacheTransactions.Count == 0)
                        {
                            //这个时候就只能去服务器看了,本地的缓存订单已经没了
                            EB.Debug.Log("------------PurchaseProcessingResult.Complete-----------------" + google.transactionID);
                            return(PurchaseProcessingResult.Complete);
                        }
                        //同一个缓存的Google订单号去遍历所有缓存在本地的APP订单逐一请求发货
                        for (int i = 0; i < cacheTransactions.Count; i++)
                        {
                            data.Clear();
                            currenTransaction = cacheTransactions[i];
                            EB.Debug.Log("------------currentGPProductId---------------:" + eProductId);
                            data.Add("productId", e.purchasedProduct.definition.id);
                            EB.Debug.Log("------------currentGPProductId---------------:");
                            EB.Debug.Log("------------currentGPTokenId-----------------:" + google.purchaseToken);
                            data.Add("token", google.purchaseToken);
                            EB.Debug.Log("------------currentGPTokenId-----------------");
                            EB.Debug.Log("------------currentGPTransactionId-----------:" + currenTransaction.transactionId);
                            data.Add("transactionId", currenTransaction.transactionId);
                            EB.Debug.Log("------------currentGPTransactionId-----------:");
                            data.Add("transactionProId", currenTransaction.productId);
                            if (mPayCallback != null)
                            {
                                //支付成功的向APPServer申请处理
                                EB.Debug.Log("------------PayCallback---------------:" + e.purchasedProduct.definition.id);
                                mPayCallback(-1000, data);
                                mPayCallback = null;
                            }
                        }
                    }
                    else
                    {
                        data.Clear();
                        EB.Debug.Log("------------currentGPProductId---------------:" + eProductId);
                        data.Add("productId", e.purchasedProduct.definition.id);
                        EB.Debug.Log("------------currentGPProductId---------------:");
                        EB.Debug.Log("------------currentGPTokenId-----------------:" + google.purchaseToken);
                        data.Add("token", google.purchaseToken);
                        EB.Debug.Log("------------currentGPTokenId-----------------");
                        EB.Debug.Log("------------currentGPTransactionId-----------:" + currenTransaction.transactionId);
                        data.Add("transactionId", currenTransaction.transactionId);
                        EB.Debug.Log("------------currentGPTransactionId-----------:");
                        data.Add("transactionProId", currenTransaction.productId);
                        if (mPayCallback != null)
                        {
                            //支付成功的向APPServer申请处理
                            EB.Debug.Log("------------PayCallback---------------:" + e.purchasedProduct.definition.id);
                            mPayCallback(-1000, data);
                            mPayCallback = null;
                        }
                    }
                }
                EB.Debug.Log("------------for IPurchaseReceipt +1-----------:");
            }
            EB.Debug.Log("------------for IPurchaseReceipt End-----------:");
            EB.Debug.Log("购买处理完毕--------------------");
            currenTransaction = null;
            return(PurchaseProcessingResult.Pending);
        }
Esempio n. 4
0
 public override void OnOfferPurchaseSuceeded(EB.IAP.Item item, EB.IAP.Transaction trans)
 {
     base.OnOfferPurchaseSuceeded(item, trans);
     // Hotfix_LT.Messenger.Raise(Hotfix_LT.EventName.OnOfferPurchaseSuceeded, item, trans);
     GlobalUtils.CallStaticHotfix("Hotfix_LT.MessengerAdapter", "Wallet_OnOfferPurchaseSuceeded", item, trans);
 }