コード例 #1
0
ファイル: PayNormalAction.cs プロジェクト: haiya/Scut
        private void Check10086Payment(OrderInfo orderInfo)
        {
            string url = "http://ospd.mmarket.com:8089/trust";
            string appId = "";
            string version = "1.0.0";
            int orderType = 1;
            GameChannel gameChannel = ZyGameBaseConfigManager.GameSetting.GetChannelSetting(ChannelType.channelMIUI);
            if (gameChannel != null)
            {
                url = gameChannel.Url;
                version = gameChannel.Version;
                orderType = gameChannel.CType.ToInt();
                GameSdkSetting setting = gameChannel.GetSetting(orderInfo.PayType);
                if (setting != null)
                {
                    appId = setting.AppId;
                }
                else
                {
                    return;
                }
            }

            StringBuilder paramData = new StringBuilder();
            paramData.Append("<?xml version=\"1.0\"?>");
            paramData.AppendFormat("<Trusted2ServQueryReq>");
            paramData.AppendFormat("<MsgType>{0}</MsgType>", "Trusted2ServQueryReq");
            paramData.AppendFormat("<Version>{0}</Version>", version);
            paramData.AppendFormat("<AppID>{0}</AppID>", appId);
            paramData.AppendFormat("<OrderID>{0}</OrderID>", orderInfo.OrderNO);
            paramData.AppendFormat("<OrderType>{0}</OrderType>", orderType);
            paramData.AppendFormat("</Trusted2ServQueryReq>");
            HttpRequest request = new HttpRequest();
            request.Post(HttpRequest.ContentTypeXml, url, paramData.ToString(), stream =>
            {
                try
                {
                    var doc = request.ToXml(stream);
                    TraceLog.ReleaseWriteFatal("10068 order:{0} response:{1}", orderInfo.OrderNO, doc.InnerXml);
                    var returnCode = doc.SelectSingleNode("Trusted2ServQueryResp/ReturnCode");
                    if (returnCode != null && !string.IsNullOrEmpty(returnCode.InnerText))
                    {
                        int code = returnCode.InnerText.ToInt();
                        if (code == 0)
                        {
                            string orderNo = "";
                            var orderIDNode = doc.SelectSingleNode("Trusted2ServQueryResp/OrderID");
                            if (orderIDNode != null)
                            {
                                orderNo = orderIDNode.InnerText;
                            }
                            var priceNode = doc.SelectSingleNode("Trusted2ServQueryResp/TotalPrice");
                            if (priceNode != null)
                            {
                                decimal amount = priceNode.InnerText.ToDecimal();
                                orderInfo.Amount = amount;
                                orderInfo.GameCoins = (int)amount * 10;
                            }
                            return PayManager.PaySuccess(orderNo, orderInfo);
                        }
                        TraceLog.ReleaseWriteFatal("10086 payment order:{0} fail code:{1}", orderInfo.OrderNO, code);
                    }
                }
                catch (Exception ex)
                {
                    TraceLog.WriteError("10086 payment error:", ex);
                }
                return false;
            });
        }
コード例 #2
0
ファイル: PayNormalAction.cs プロジェクト: rongxiong/Scut
        private void Check10086Payment(OrderInfo orderInfo)
        {
            string url = "http://ospd.mmarket.com:8089/trust";
            string appId = "";
            string version = "1.0.0";
            int orderType = 1;
            var section = SdkSectionFactory.Section10086;
            if (section != null && !string.IsNullOrEmpty(orderInfo.PayType))
            {
                url = section.Url;
                version = section.Version;
                orderType = section.OrderType;
                Channel10086Element channel10086 = section.Channels[orderInfo.PayType];
                if (channel10086 != null)
                {
                    appId = channel10086.AppId;
                }
                else
                {
                    return;
                }
            }
            StringBuilder paramData = new StringBuilder();
            paramData.Append("<?xml version=\"1.0\"?>");
            paramData.AppendFormat("<Trusted2ServQueryReq>");
            paramData.AppendFormat("<MsgType>{0}</MsgType>", "Trusted2ServQueryReq");
            paramData.AppendFormat("<Version>{0}</Version>", version);
            paramData.AppendFormat("<AppID>{0}</AppID>", appId);
            paramData.AppendFormat("<OrderID>{0}</OrderID>", orderInfo.OrderNO);
            paramData.AppendFormat("<OrderType>{0}</OrderType>", orderType);
            paramData.AppendFormat("</Trusted2ServQueryReq>");
            HttpRequest request = new HttpRequest();
            request.Post(HttpRequest.ContentTypeXml, url, paramData.ToString(), stream =>
            {
                try
                {
                    /****************************************************************************
            Copyright (c) 2013-2015 scutgame.com

            http://www.scutgame.com

            Permission is hereby granted, free of charge, to any person obtaining a copy
            of this software and associated documentation files (the "Software"), to deal
            in the Software without restriction, including without limitation the rights
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
            copies of the Software, and to permit persons to whom the Software is
            furnished to do so, subject to the following conditions:

            The above copyright notice and this permission notice shall be included in
            all copies or substantial portions of the Software.

            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
            THE SOFTWARE.
            ****************************************************************************/
                    var doc = request.ToXml(stream);
                    TraceLog.ReleaseWriteFatal("10068 order:{0} response:{1}", orderInfo.OrderNO, doc.InnerXml);
                    var returnCode = doc.SelectSingleNode("Trusted2ServQueryResp/ReturnCode");
                    if (returnCode != null && !string.IsNullOrEmpty(returnCode.InnerText))
                    {
                        int code = returnCode.InnerText.ToInt();
                        if (code == 0)
                        {
                            string orderNo = "";
                            var orderIDNode = doc.SelectSingleNode("Trusted2ServQueryResp/OrderID");
                            if (orderIDNode != null)
                            {
                                orderNo = orderIDNode.InnerText;
                            }
                            var priceNode = doc.SelectSingleNode("Trusted2ServQueryResp/TotalPrice");
                            if (priceNode != null)
                            {
                                decimal amount = priceNode.InnerText.ToDecimal();
                                orderInfo.Amount = amount;
                                orderInfo.GameCoins = (int)amount * 10;
                            }
                            return PayManager.PaySuccess(orderNo, orderInfo);
                        }
                        TraceLog.ReleaseWriteFatal("10086 payment order:{0} fail code:{1}", orderInfo.OrderNO, code);
                    }
                }
                catch (Exception ex)
                {
                    TraceLog.WriteError("10086 payment error:", ex);
                }
                return false;
            });
        }