Exemple #1
0
        /// <summary>
        /// 开始支付逻辑。
        /// </summary>
        /// <param name="trade"></param>
        /// <param name="payChannel"></param>
        public void Pay(TradeNoResult trade, int payChannel)
        {
            switch (payChannel)
            {
            case PayChannelType.ALIPAY_IOS:
                AlipayIOS(trade.extra);
                break;

            case PayChannelType.ALIPAY_CLIENT:
                AlipayAndroid(trade.extra);
                break;

            case PayChannelType.IOS_IAP:
                IapPay(trade);
                break;

            case PayChannelType.WEI_XIN:
                WxPay(trade.extra);
                break;

            case PayChannelType.XIAOMI:
                XiaoMiPay(trade);
                break;
            }
        }
        private bool CheckTradoNoResult()
        {
            _trade = _tradeNoResult.Read();
            if (_trade == null)
            {
                return(false);
            }

            if (_trade.result != ResultCode.OK)
            {
                // 申请订单失败。
                TradeNoFail();

                AnalyticPayFail("trade_no_fail", "" + _trade.result);
            }

            return(true);
        }
Exemple #3
0
        public void IapPay(TradeNoResult res)
        {
            IapPayResultTime = 0;
            IapPayResultData = null;

            if (res == null)
            {
                return;
            }

            string productId  = null;
            string outTradeNo = null;

            IapProductID iapProductId = null;

            try
            {
                iapProductId = JsonUtility.FromJson <IapProductID>(res.extra);
            }
            catch (Exception e)
            {
            }

            if (iapProductId != null)
            {
                productId = iapProductId.productID;
            }

            var trade = res.trade;

            if (trade != null)
            {
                outTradeNo = trade.out_trade_no;
            }

#if UNITY_IOS
            _ios.IapPay(productId, outTradeNo);
#endif
        }
Exemple #4
0
        public void XiaoMiPay(TradeNoResult res)
        {
            MiPayResultTime = 0;
            MiPayResultData = null;

            if (res == null)
            {
                return;
            }

            var trade = res.trade;

            if (trade == null)
            {
                return;
            }

#if UNITY_ANDROID
            var myUser   = _myUser.Read();
            var userName = myUser == null ? null : myUser.username;
            _android.MiPay(trade.out_trade_no, userName, (int)trade.total_fee);
#endif
        }