예제 #1
0
        private void OnPushGiftRsp(object s)
        {
            if (s is SCGetPushResponse)
            {
                var rsp = s as SCGetPushResponse;

                List <Push_Info> infos = new List <Push_Info>();

                if (null == rsp.Infos || 0 == rsp.Infos.Count)
                {
                    m_login_push_infos = null;
                    return;
                }

                infos.AddRange(rsp.Infos);

                PushGiftManager.Instance.RefreshLoginPush(infos);
            }
            else if (s is SCBuyPushResponse)
            {
                var rsp = s as SCBuyPushResponse;

                if (!MsgStatusCodeUtil.OnError(rsp.ReponseStatus))
                {
#if UNITY_IOS && PLATFORM_ID
                    GameEvents.IAPEvents.Sys_BuyProductIOSEvent.SafeInvoke(ConfCharge.Get(ConfPush.Get(rsp.PushId).chargeid).chargeSouceId);
#else
                    GameEvents.IAPEvents.Sys_BuyProductEvent.SafeInvoke(ConfCharge.Get(ConfPush.Get(rsp.PushId).chargeid).id);
#endif
                }
            }
        }
예제 #2
0
        private List <IAPProduct> DoGetProductsIOS()
        {
            List <IAPProduct> ret = new List <IAPProduct>();


            foreach (var item in ConfCharge.array)
            {
#if UNITY_ANDROID
                if ((int)IAP_PLATFROM_TYPE.E_GOOGLE_PLAY != item.source)
                {
                    continue;
                }
#elif UNITY_IOS
                if ((int)IAP_PLATFROM_TYPE.E_APPLE_STORE != item.source)
                {
                    continue;
                }
#endif


                IAPProduct product = new IAPProduct()
                {
                    m_charge_id          = item.id,
                    m_unique_platform_id = ConfCharge.Get(item.id).chargeSouceId,
                    m_type = ConvertProductType(1),
                };

                ret.Add(product);
            }

            return(ret);
        }
예제 #3
0
        public void RspVerifyTransaction(long charge_id_)
        {
#if UNITY_IOS && PLATFORM_ID
            ConfCharge charge = ConfCharge.Get(charge_id_);

            DoConfirmPendingPurchaseByIDIOS(charge.chargeSouceId);
#else
            DoConfirmPendingPurchaseByID(charge_id_);
#endif
        }
예제 #4
0
        public static long GetGiftID(long charge_id_)
        {
            ConfCharge charge = ConfCharge.Get(charge_id_);

            if (null == charge)
            {
                return(-1L);
            }

            ConfPush push_gift = ConfPush.array.Find((item) => item.chargeid == charge.id);

            if (null == push_gift)
            {
                return(-1L);
            }

            return(push_gift.giftid);
        }
예제 #5
0
        private void DoRspVerifyTransaction(object msg_)
        {
            if (msg_ is SCGooglePayChargeResponse)
            {
                var rsp = msg_ as SCGooglePayChargeResponse;

                if (!MsgStatusCodeUtil.OnError(rsp.ResponseStatus))
                {
                    Debugger.Log("UNITY IAP purchase rsp product id = " + rsp.ProductId);

                    EngineCoreEvents.AudioEvents.PlayAudio.SafeInvoke(Audio.AudioType.UISound, GameCustomAudioKey.buy_cash_success.ToString());

                    ConfCharge good = (!string.IsNullOrEmpty(rsp.ProductId) && !string.IsNullOrWhiteSpace(rsp.ProductId)) ? IAPTools.GetGoodsByPlatformID(rsp.ProductId) : null;

                    long charge_id = null != good ? good.id : 0L;

                    if (0 == charge_id)
                    {
                        TransactionTips(LocalizeModule.Instance.GetString("submit_ok"), false);
                        return;
                    }

                    Debugger.Log("UNITY IAP purchase rsp charge id = " + charge_id);
                    IAPTools.instance.RspVerifyTransaction(charge_id);

                    string good_desc = LocalizeModule.Instance.GetString(good.desc);

                    Debugger.Log("UNITY IAP in transction done charge_id = " + charge_id);

                    GameEvents.NetWorkEvents.SendAsyncMsg.SafeInvoke(new CSPlayerInfoRequest());

                    TransactionTips(good_desc, true);

                    GameEvents.IAPEvents.OnTransactionDone.SafeInvoke(charge_id);

                    long giftID = CommonHelper.GetGiftID(charge_id);
                    if (giftID > 0)
                    {
                        //CommonHelper.OpenGift(giftID, 1);
                    }
                }
                else
                {
                    Debugger.LogError("UNITY IAP error transction done product id = " + rsp.ProductId);

                    ConfCharge good = (!string.IsNullOrEmpty(rsp.ProductId) && !string.IsNullOrWhiteSpace(rsp.ProductId)) ? IAPTools.GetGoodsByPlatformID(rsp.ProductId) : null;

                    if (null != good)
                    {
                        string good_desc = LocalizeModule.Instance.GetString(good.desc);

                        TransactionTips(good_desc, false);

                        IAPTools.instance.RspVerifyTransaction(good.id);
                    }
                    else
                    {
                        var pair_req = EngineCoreEvents.SystemEvents.GetRspPairReq.SafeInvoke();

                        if (pair_req is CSGooglePayChargeRequest)
                        {
                            CSGooglePayChargeRequest req_wrapper = pair_req as CSGooglePayChargeRequest;
                            string charge_id = req_wrapper.ProductId;

                            good = ConfCharge.Get(long.Parse(charge_id));

                            if (null != good)
                            {
                                string good_desc = LocalizeModule.Instance.GetString(good.desc);

                                TransactionTips(good_desc, false);

                                IAPTools.instance.RspVerifyTransaction(good.id);
                            }
                        }
                    }
                }
            }
            else if (msg_ is SCIOSPayChargeResponse)
            {
                var rsp = msg_ as SCIOSPayChargeResponse;

                Debugger.Log("UNITY IAP purchase rsp platform id = " + rsp.ProductId);


                if (!MsgStatusCodeUtil.OnError(rsp.ResponseStatus))
                {
                    EngineCoreEvents.AudioEvents.PlayAudio.SafeInvoke(Audio.AudioType.UISound, GameCustomAudioKey.buy_cash_success.ToString());

                    ConfCharge good = (!string.IsNullOrEmpty(rsp.ProductId) && !string.IsNullOrWhiteSpace(rsp.ProductId)) ? IAPTools.GetGoodsByPlatformID(rsp.ProductId) : null;

                    long charge_id = null != good ? good.id : 0L;

                    if (0 == charge_id)
                    {
                        TransactionTips(LocalizeModule.Instance.GetString("submit_ok"), false);
                        return;
                    }

                    Debugger.Log("UNITY IAP purchase rsp charge id = " + charge_id);
                    IAPTools.instance.RspVerifyTransaction(charge_id);

                    string good_desc = LocalizeModule.Instance.GetString(good.desc);


                    Debugger.Log("in transction done charge_id = " + charge_id);

                    GameEvents.NetWorkEvents.SendAsyncMsg.SafeInvoke(new CSPlayerInfoRequest());

                    TransactionTips(good_desc, true);

                    GameEvents.IAPEvents.OnTransactionDone.SafeInvoke(charge_id);

                    //long giftID = CommonHelper.GetGiftID(charge_id);
                    //if (giftID > 0)
                    //{
                    //    var gifts = PushGiftManager.Instance.GetPushInfosByTurnOnType(ENUM_PUSH_GIFT_BLOCK_TYPE.E_LOGIN);

                    //    if( null != gifts && gifts.Count > 0)
                    //    {
                    //        foreach( var gift in gifts)
                    //        {
                    //            if( giftID ==  gift.PushId )
                    //            {
                    //                gift.Buyed = true;
                    //            }

                    //        }
                    //    }
                    //    //CommonHelper.OpenGift(giftID, 1);
                    //}
                }
                else
                {
                    Debugger.LogError("UNITY IAP error transction done product id = " + rsp.ProductId);


                    ConfCharge good = (!string.IsNullOrEmpty(rsp.ProductId) && !string.IsNullOrWhiteSpace(rsp.ProductId)) ? IAPTools.GetGoodsByPlatformID(rsp.ProductId) : null;

                    if (null != good)
                    {
                        string good_desc = LocalizeModule.Instance.GetString(good.desc);

                        TransactionTips(good_desc, false);

                        IAPTools.instance.RspVerifyTransaction(good.id);
                    }
                    else
                    {
                        var pair_req = EngineCoreEvents.SystemEvents.GetRspPairReq.SafeInvoke();

                        if (pair_req is CSIOSPayChargeRequest)
                        {
                            CSIOSPayChargeRequest req_wrapper = pair_req as CSIOSPayChargeRequest;
#if UNITY_IOS && PLATFROM_ID
                            string platform_unique_id = req_wrapper.ProductId;
                            Debug.Log("失败交易商品 platform unique id " + platform_unique_id);
                            good = IAPTools.GetGoodsByPlatformID(platform_unique_id);
#else
                            string charge_id = req_wrapper.ProductId;
                            Debug.Log("失败交易商品 charge id " + charge_id);
                            good = ConfCharge.Get(long.Parse(charge_id));
#endif
                            if (null != good)
                            {
                                string good_desc = LocalizeModule.Instance.GetString(good.desc);

                                Debug.Log("失败交易商品 " + good_desc);

                                TransactionTips(good_desc, false);

                                IAPTools.instance.RspVerifyTransaction(good.id);
                            }
                        }
                    }
                }
            }
        }