Esempio n. 1
0
        protected void btnClick_Click(object sender, EventArgs e)
        {
            var entity = new UnifiedOrderEntity
            {
                OrderId      = "1234455678",
                wid          = 1,
                total_fee    = 1,
                out_trade_no = "DD123456789",
                openid       = openid,
                body         = "测试不关注支付",
                PayModuleID  = (int)PayModuleEnum.Restaurant,
                PayComplete  = "../restaurant/index.aspx"
            };

            entity.Extra.Add("content", "");
            //entity.Extra.Add("shopname", new BLL.wx_diancai_shopinfo().GetModel(this.shopid).hotelName);
            //entity.Extra.Add("shopid", shopid.ToString());
            entity.Extra.Add("wid", "1");

            var ticket  = EncryptionManager.CreateIV();
            var payData = EncryptionManager.AESEncrypt(entity.ToJson(), ticket);

            Response.Redirect(PayHelper.GetPayUrl(payData, ticket));

            //Response.Redirect("http://weixin.zhiyoubao.com/ticket/scenicTicket.htm?scenicId=1021");
        }
Esempio n. 2
0
        public void PostProcessPayment(PaymentInfo order)
        {
            string PUB32      = "30819c300d06092a864886f70d010101050003818a003081860281807cd21042439755abab54981724a366a66913258fcbc6075555e973d48137e22eedd5ab5f3be57404a30795e71f6f4c8f31d4715e3e0d1985426ed51c131bee24448202f3c777558c0e5b23cac643a5bed52719fef620548c6608377d5a86fd57cb8cb67272656cbd9dd8d796dc5613400edb1905b7802a7e7bcd673c3d23d3bf020111"; //公钥前30位 新接口使用
            string MERCHANTID = "105584073990057";                                                                                                                                                                                                                                                                                                                //商户代码(客户号)
            string POSID      = "100000631";                                                                                                                                                                                                                                                                                                                      //商户柜台代码
            string BRANCHID   = "442000000";                                                                                                                                                                                                                                                                                                                      //分行代码
            string ORDERID    = order.SysOrderNo;                                                                                                                                                                                                                                                                                                                 //定单号
            string PAYMENT    = order.OrderAmount;                                                                                                                                                                                                                                                                                                                //付款金额
            string MAC        = "MERCHANTID=" + MERCHANTID + "&POSID=" + POSID
                                + "&BRANCHID=" + BRANCHID + "&ORDERID=" + ORDERID
                                + "&PAYMENT=" + PAYMENT + "&CURCODE=01"
                                + "&TXCODE=520100" + "&REMARK1="
                                + "&REMARK2=";

            HttpHelper http = new HttpHelper();

            http.Url = order.PayOnlineProviderUrl;
            http.Add("INTER_FLAG", "0");                            //商户接口类型 0为旧接口,1为新接口
            http.Add("MERCHANTID", MERCHANTID);
            http.Add("POSID", POSID);
            http.Add("BRANCHID", BRANCHID);
            http.Add("PUB32", PUB32);
            http.Add("ORDERID", ORDERID);
            http.Add("PAYMENT", PAYMENT);                           //付款金额
            http.Add("CURCODE", "01");                              //币种缺省为01-人民币
            http.Add("TXCODE", "520100");                           //交易码
            http.Add("REMARK1", "");                                //备注1
            http.Add("REMARK2", "");                                //备注2
            http.Add("DOTYPE", "0");                                //支付类型 0为网上银行支付,1为E付卡支付
            http.Add("MAC", PayHelper.GetMD5(MAC, "").ToLower());   //MAC校验域
            http.Post();
        }
Esempio n. 3
0
        /// <summary>
        /// APP支付
        /// </summary>
        /// <param name="cash"></param>
        /// <returns></returns>
        public JsonResult AppPay(decimal cash)
        {
            string body      = "订单描述";
            string notifyurl = "http://localhost:4040/WXPay/WXCall"; //微信后台通知的地址
            string Recordid  = UtilTool.GenerateOutTradeNo();
            string clientIp  = UtilTool.GetWebClientIp();            //本地测试时地址为::1会导致微信返回错误   要在服务器上部署  远程调用调试
            SortedDictionary <string, object> wxRes = PayHelper.AppPay(body, notifyurl, Recordid, "", cash, clientIp);

            if (wxRes != null)
            {
                Dictionary <string, object> data = new Dictionary <string, object>();
                foreach (var item in wxRes)                 //微信APP支付需要的参数
                {
                    data.Add(item.Key, item.Value);
                }

                data.Add("orderid", Recordid);        //如果APP要需要网站订单号则返回网站订单号
                data.Add("code", "SUCCESS");
                return(Json(data));
            }
            else
            {
                Dictionary <string, object> data = new Dictionary <string, object>();
                data.Add("code", "FAILD");
                return(Json(data));
            }
        }
        /// <summary>
        ///     生成支付链接
        /// </summary>
        /// <param name="unifiedOrderInfo"></param>
        /// <returns></returns>
        public string GeneratePayUrl(UnifiedOrderInfo unifiedOrderInfo)
        {
            var ticket = EncryptionManager.CreateIV();
            var payData = EncryptionManager.AESEncrypt(JSONHelper.Serialize(unifiedOrderInfo, "yyyy-MM-dd"), ticket);

            return PayHelper.GetPayUrl(payData, ticket);
        }
Esempio n. 5
0
        public object RefundOrder([FromBody] JObject _obj)
        {
            var reqParams = new SortedDictionary <string, object>();

            reqParams.Add("charset", "utf-8");
            reqParams.Add("method", "qct.trade.refund.apply");
            reqParams.Add("mch_id", _obj.Property("mch_id", true));
            reqParams.Add("store_id", _obj.Property("store_id", true));
            reqParams.Add("device_id", _obj.Property("device_id", true));
            reqParams.Add("refund_amount", _obj.Property("refund_amount", true));
            reqParams.Add("sign_type", "MD5");
            reqParams.Add("version", "1.0");
            reqParams.Add("out_refund_no", _obj.Property("out_refund_no", true));
            reqParams.Add("out_trade_no", _obj.Property("out_trade_no", true));
            reqParams.Add("create_date", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            reqParams.Add("refund_notify_url", "");
            reqParams.Add("refund reason", "");
            //签名
            String sign = PayHelper.Sign(reqParams, "1A064D83D7D043DB8DE76D4C15694C98");

            reqParams.Add("sign", sign);
            var obj    = HttpClient.PayPost("http://test.pay.qcterp.com/api/pay/refund", reqParams);
            var result = JsonConvert.DeserializeObject <JObject>(obj);

            if (result.Property("return_code").Value.ToString() == "00000")
            {
                return("success");
            }
            else
            {
                return(result.Property("return_msg").Value.ToString());
            }
        }
Esempio n. 6
0
        /**
         *
         * 获取收货地址js函数入口参数,详情请参考收货地址共享接口:http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_9
         * @return string 共享收货地址js函数需要的参数,json格式可以直接做参数使用
         */
        public string JsApiPayAddress(string access_token)
        {
            //参与签名的是网页授权获取用户信息时微信后台回传的完整url
            string url = "http://redirect_uri";

            //构造需要用SHA1算法加密的数据
            SortedDictionary <string, object> data = new SortedDictionary <string, object>
            {
                { "appid", appid },
                { "url", url },
                { "timestamp", PayHelper.Time_stamp },
                { "noncestr", PayHelper.Nonce_str },
                { "accesstoken", access_token }
            };
            string addrSign = EncryptHelper.SHA1(PayHelper.ToUrl(data));

            //获取收货地址js函数入口参数
            SortedDictionary <string, object> afterData = new SortedDictionary <string, object>
            {
                { "appId", appid },
                { "scope", "jsapi_address" },
                { "signType", "sha1" },
                { "addrSign", addrSign },
                { "timeStamp", data["timestamp"] },
                { "nonceStr", data["noncestr"] }
            };

            return(JsonConvert.SerializeObject(afterData));
        }
Esempio n. 7
0
        /// <summary>
        /// 扫码支付(模式一)
        /// 官方文档:https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_1
        /// </summary>
        /// <returns></returns>
        public ActionResult NativePayOne(string productId)
        {
            try
            {
                if (string.IsNullOrEmpty(productId))
                {
                    return(Json(new { Code = 1, Msg = "产品不能为空!" }));
                }

                SortedDictionary <string, object> data = new SortedDictionary <string, object>
                {
                    { "appid", appid },
                    { "mch_id", mch_id },
                    { "time_stamp", PayHelper.Time_stamp },
                    { "nonce_str", PayHelper.Nonce_str },
                    { "product_id", productId }
                };
                data.Add("sign", PayHelper.MakeSign(data));

                return(Json(new { Code = 0, Msg = "weixin://wxpay/bizpayurl?" + PayHelper.ToUrl(data) }));
            }
            catch (Exception ex)
            {
                LogHelper.SaveLog(ex);
                return(Json(new { Code = 1, Msg = "服务器异常,请联系管理员!" }));
            }
        }
Esempio n. 8
0
        /**
         * 下载对账单
         * @param WxPayData inputObj 提交给下载对账单API的参数
         * @param int timeOut 接口超时时间
         * @throws Exception
         * @return 成功时返回,其他抛异常
         */
        public SortedDictionary <string, object> DownloadBill(SortedDictionary <string, object> inputObj, int timeOut = 6)
        {
            //检测必填参数
            if (!inputObj.ContainsKey("bill_date"))
            {
                throw new Exception("对账单接口中,缺少必填参数bill_date!");
            }

            inputObj.Add("appid", appid);                       //公众账号ID
            inputObj.Add("mch_id", mch_id);                     //商户号
            inputObj.Add("nonce_str", PayHelper.Nonce_str);     //随机字符串
            inputObj.Add("sign", PayHelper.MakeSign(inputObj)); //签名

            string xml      = inputObj.ToXml();
            string response = HttpService.Post(xml, "https://api.mch.weixin.qq.com/pay/downloadbill", false, timeOut);//调用HTTP通信接口以提交数据到API

            if (response.Substring(0, 5) == "<xml>")
            {
                return(PayHelper.FromXml(response));
            }
            else
            {
                return new SortedDictionary <string, object>()
                       {
                           { "result", response }
                       }
            };
        }
Esempio n. 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //定义变量
            userName = GameRequest.GetFormString("txtPayAccounts");
            string reUserName = GameRequest.GetFormString("txtPayReAccounts");

            money     = GameRequest.GetFormInt("hdfSalePrice", 0);
            sendUrl   = System.Configuration.ConfigurationSettings.AppSettings["DaySendUrl"];    //导向地址
            notifyUrl = System.Configuration.ConfigurationSettings.AppSettings["DayNotifyUrl"];  //同步回调地址
            string key = System.Configuration.ConfigurationSettings.AppSettings["DayKey"];       //密钥

            merId = System.Configuration.ConfigurationSettings.AppSettings["DayMerId"];          //商户ID


            //验证参数
            if (userName != reUserName)
            {
                ShowAndRedirect("两次输入的用户名不一致", "/Pay/PayDay.aspx");
                return;
            }
            if (money == 0)
            {
                ShowAndRedirect("金额输入有误", "/Pay/PayDay.aspx");
                return;
            }

            //生成订单
            orderID = PayHelper.GetOrderIDByPrefix("Day");      //订单号
            OnLineOrder onlineOrder = new OnLineOrder( );

            onlineOrder.ShareID = 2;
            onlineOrder.OrderID = orderID;
            if (Fetch.GetUserCookie( ) == null)
            {
                onlineOrder.OperUserID = 0;
            }
            else
            {
                onlineOrder.OperUserID = Fetch.GetUserCookie( ).UserID;
            }
            onlineOrder.Accounts    = userName;
            onlineOrder.CardTotal   = 1;
            onlineOrder.CardTypeID  = money < 30 ? 1 : money < 60 ? 2 : money < 120 ? 3 : 4;
            onlineOrder.OrderAmount = money;
            onlineOrder.IPAddress   = GameRequest.GetUserIP( );
            TreasureFacade treasureFacade = new TreasureFacade( );
            Message        umsg           = treasureFacade.RequestOrder(onlineOrder);

            if (!umsg.Success)
            {
                RenderAlertInfo(true, umsg.Content, 2);
                return;
            }

            //生成sign签名
            string signStr = merId + "|" + orderID + "|" + money + "|" + sendUrl + "|" + userName + "|" + key;

            sign = EncryptMD5(signStr, false, 32);
        }
Esempio n. 10
0
 public PayController()
 {
     _PaySettingService  = new PaySettingService();
     _baseSettingService = new BaseSettingService();
     _userInfoService    = new UserInfoService();
     _payInfoService     = new PayInfoService();
     _payHelper          = new PayHelper();
 }
Esempio n. 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string str = ApplicationSettings.Get("key_th");
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary["versionId"]     = base.Request["versionId"];
            dictionary["transType"]     = base.Request["transType"];
            dictionary["asynNotifyUrl"] = base.Request["asynNotifyUrl"];
            dictionary["synNotifyUrl"]  = base.Request["synNotifyUrl"];
            dictionary["merId"]         = base.Request["merId"];
            dictionary["orderAmount"]   = base.Request["orderAmount"];
            dictionary["prdOrdNo"]      = base.Request["prdOrdNo"];
            dictionary["orderStatus"]   = base.Request["orderStatus"];
            dictionary["payId"]         = base.Request["payId"];
            dictionary["payTime"]       = base.Request["payTime"];
            dictionary["signType"]      = base.Request["signType"];
            dictionary = (
                from p in dictionary
                orderby p.Key
                select p).ToDictionary <KeyValuePair <string, string>, string, string>((KeyValuePair <string, string> p) => p.Key, (KeyValuePair <string, string> o) => o.Value);
            string password = string.Concat(PayHelper.PrepareSign(dictionary), "&key=", str);

            dictionary["signData"] = base.Request["signData"];
            if (dictionary["orderStatus"] == "01")
            {
                string text = TextEncrypt.EncryptPassword(password);
                if (dictionary["signData"] == text)
                {
                    ShareDetialInfo shareDetialInfo = new ShareDetialInfo()
                    {
                        OrderID   = dictionary["prdOrdNo"],
                        IPAddress = Utility.UserIP,
                        PayAmount = Convert.ToDecimal(dictionary["orderAmount"]) / new decimal(100)
                    };
                    Message message = FacadeManage.aideTreasureFacade.FilliedOnline(shareDetialInfo, 0);
                    if (!message.Success)
                    {
                        Log.Write(message.Content);
                    }
                    else
                    {
                        base.Response.Write("SUCCESS");
                    }
                }
                else
                {
                    Log.Write(string.Concat("签名错误,mySign:", text, "——Sign=", dictionary["signData"]));
                    base.Response.Write("签名错误");
                }
            }
            else
            {
                Log.Write("支付系统错误");
                base.Response.Write("支付系统错误");
            }
        }
Esempio n. 12
0
        public HttpResponseMessage PayFor(dynamic obj)
        {
            HttpResponseMessage response = new HttpResponseMessage();
            string pay  = "";
            string id   = "";
            string type = "";

            try
            {
                pay  = obj.pay.Value;
                id   = obj.id.Value;
                type = obj.type.Value;
            }
            catch (Exception e)
            {
            }
            PayType typeP = PayType.Treat;

            switch (int.Parse(type))
            {
            case 0:
                typeP = PayType.Treat;
                break;

            case 1:
                typeP = PayType.Exam;
                break;

            case 2:
                typeP = PayType.Pres;
                break;

            case 3:
                typeP = PayType.Surg;
                break;

            case 4:
                typeP = PayType.Hos;
                break;

            default:
                typeP = PayType.Treat;
                break;
            }
            try
            {
                PayHelper.Pay(double.Parse(pay), typeP, id);
            }
            catch (Exception)
            {
                throw;
            }

            return(response);
        }
Esempio n. 13
0
    public virtual void OnCheckOrdersSuccess(CheckOrderRess resList)
    {
        Debug.Log("OnCheckOrdersSuccess==>ObjectDumper Length:" + resList.CheckOrderRess_.Count + "\n" +
                  ObjectDumper.Dump(resList));

        PayHelper.SetGlobal(resList);

        List <string> list = new List <string>();

        foreach (var res in resList.CheckOrderRess_)
        {
            list.Add(res.OrderId);

            JSONObject json = new JSONObject(res.Extra);
            Debug.Log("OnCheckOrdersSuccess==>res.Extra " + res.Extra);

            ProductVo vo = GlobalData.PayModel.GetProduct(res.CommodityId);
            SdkHelper.StatisticsAgent.OnPayEnd(res.OrderId, PayChannel, vo);

            if (res.Amount <= 0 || string.IsNullOrEmpty(res.OrderId))
            {
                BuglyAgent.ReportException("PayAgent", "Amount:" + res.Amount + "  OrderId:" + res.OrderId, "none");
            }

            payChecker.RemoveOrder(res.OrderId);
        }

        if (resList.Awards?.Count > 0)
        {
            RewardUtil.AddReward(resList.Awards);
            AwardWindow awardWindow = PopupManager.ShowWindow <AwardWindow>("GameMain/Prefabs/AwardWindow/AwardWindow");
            awardWindow.SetData(resList.Awards, I18NManager.Get("Common_RechargeSuccess"));
        }

        Debug.Log("GlobalData.PlayerModel.PlayerVo.ExtInfo" + resList.UserExtraInfo);

        EventDispatcher.TriggerEvent(EventConst.GetPayInfoSuccess, resList.UserBuyRmbMall);

        if (resList.TriggerId != null && resList.TriggerId.Count > 0)
        {
            Debug.LogWarning("resList.TriggerId-------->" + resList.TriggerId[0]);
            EventDispatcher.TriggerEvent(EventConst.TriggerGiftPaySuccess, resList.TriggerId);
        }

        if (resList.UserBuyRmbMall == null)
        {
            string orderId = "none";
            if (list.Count > 0)
            {
                orderId = list[0];
            }
            BuglyAgent.ReportException("checkOrderSuccess UserBuyRmbMall", "resList.UserBuyRmbMall为空 orderId:" + orderId, "");
        }
    }
Esempio n. 14
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            System.Collections.Generic.Dictionary <string, string> dictionary = new System.Collections.Generic.Dictionary <string, string>();
            dictionary["p1_MerId"] = base.Request["p1_MerId"];
            dictionary["r0_Cmd"]   = base.Request["r0_Cmd"];
            dictionary["R1_Code"]  = base.Request["R1_Code"];
            dictionary["R2_TrxId"] = base.Request["R2_TrxId"];
            dictionary["r3_Amt"]   = base.Request["r3_Amt"];
            dictionary["r4_Cur"]   = base.Request["r4_Cur"];
            dictionary["r5_Order"] = base.Request["r5_Order"];
            dictionary["r6_Type"]  = base.Request["r6_Type"];
            string text = base.Request["hmac"];

            if (!(dictionary["R1_Code"] == "1"))
            {
                Log.Write("支付系统错误 R1_Code:" + dictionary["R1_Code"] + " orderid:" + dictionary["r5_Order"]);
                base.Response.Write("支付系统错误");
            }
            else
            {
                string signSource = PayHelper.GetSignSource(dictionary);
                string aKey       = ApplicationSettings.Get("key_hfht");
                string text2      = Encrypt.HmacSign(signSource, aKey);
                if (!(text.ToLower() == text2.ToLower()))
                {
                    Log.Write(string.Concat(new string[]
                    {
                        "签名错误,signSource=",
                        signSource,
                        " mySign=",
                        text2,
                        " Sign=",
                        text
                    }));
                    base.Response.Write("签名错误");
                }
                else
                {
                    ShareDetialInfo shareDetialInfo = new ShareDetialInfo();
                    shareDetialInfo.OrderID   = dictionary["r5_Order"];
                    shareDetialInfo.IPAddress = Utility.UserIP;
                    shareDetialInfo.PayAmount = System.Convert.ToDecimal(dictionary["r3_Amt"]);
                    Message message = FacadeManage.aideTreasureFacade.FilliedOnline(shareDetialInfo, 0);
                    if (message.Success)
                    {
                        base.Response.Write("success");
                    }
                    else
                    {
                        Log.Write(message.Content);
                    }
                }
            }
        }
Esempio n. 15
0
        public override Task <NotifyReturnModel> Notify(HttpRequest request)
        {
            NotifyReturnModel notifyReturn = new NotifyReturnModel();
            string            content      = string.Empty;

            #region MyRegion
            long contentLen = request.ContentLength == null ? 0 : request.ContentLength.Value;
            if (contentLen > 0)
            {
                // 读取请求体中所有内容
                System.IO.Stream stream = request.Body;
                request.Body.Position = 0;
                byte[] buffer = new byte[contentLen];
                stream.Read(buffer, 0, buffer.Length);
                // 转化为字符串
                content = System.Text.Encoding.UTF8.GetString(buffer);
            }
            #endregion


            //var body = request.Body;
            //using (StreamReader dRead = new StreamReader(body, Encoding.UTF8))
            //{
            //    content = dRead.ReadToEnd();
            //}
            hyNotify j            = JsonConvert.DeserializeObject <hyNotify>(content);
            string   krid         = j.krid;
            string   money        = j.money;
            string   order_sn     = j.order_sn;
            string   out_order_sn = j.out_order_sn;
            string   status       = j.status;
            data     data         = j.data;
            string   kts          = j.kts;
            string   sign         = j.sign;
            string   signstr      = string.Format("krid={0}&money={1}&order_sn={2}&out_order_sn={3}&status={4}&kts={5}", krid, money, order_sn, out_order_sn, status, kts);

            string _sign = PayHelper.Md5Hash4(signstr);
            _sign = PayHelper.Md5Hash4(_sign + this.MchKey);
            if (status == "success" && _sign.ToLower() == sign.ToLower())
            {
                notifyReturn.ReturnMsg = "ok";
                notifyReturn.IsPay     = true;
                notifyReturn.MchID     = this.MchID;
                notifyReturn.IsCheck   = true;
            }
            else
            {
                notifyReturn.ReturnMsg = "支付失败";
                notifyReturn.IsPay     = false;
                notifyReturn.MchID     = this.MchID;
                notifyReturn.IsCheck   = false;
            }
            return(Task.FromResult <NotifyReturnModel>(notifyReturn));
        }
Esempio n. 16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dingdanbll"></param>
        /// <param name="jsonDict"></param>
        /// <param name="context"></param>
        private void GetPayUrl(wx_hotel_dingdan dingdanbll, HttpContext context)
        {
            int ddid = MyCommFun.RequestInt("dingdanidnum");

            if (ddid > 0)
            {
                var dingdan = dingdanbll.GetModel(ddid);
                if (dingdan != null)
                {
                    Model.wx_hotels_info hotelInfo = new wx_hotels_info();
                    int wid = 0;
                    if (dingdan.hotelid != null)
                    {
                        hotelInfo = new BLL.wx_hotels_info().GetModel(dingdan.hotelid.Value);
                        if (hotelInfo.wid != null)
                        {
                            wid = hotelInfo.wid.Value;
                        }
                    }
                    //总花费
                    var dateSpan   = dingdan.leaveTime.Value - dingdan.arriveTime.Value;
                    var totalPrice = dingdan.price.Value * dingdan.orderNum.Value * dateSpan.Days;

                    var port   = WebHelper.GetHostPort();
                    var url    = string.Format("{0}/weixin/KNSHotel/hotel_order_paycallback.aspx", port);
                    var entity = new UnifiedOrderEntity
                    {
                        wid          = wid,
                        total_fee    = totalPrice == null ? 0 : (int)totalPrice,
                        out_trade_no = dingdan.OrderNumber,
                        openid       = dingdan.openid,
                        OrderId      = dingdan.id.ToString(),
                        body         = string.Format("订单编号{2} {3}{1}{0}间", dingdan.orderNum, dingdan.roomType
                                                     , dingdan.OrderNumber, hotelInfo.hotelName),
                        PayModuleID = (int)PayModuleEnum.Hotel,
                        PayComplete = url
                    };

                    entity.Extra.Add("dingdanidnum", ddid.ToString());
                    entity.Extra.Add("openid", dingdan.openid);
                    entity.Extra.Add("hotelid", dingdan.hotelid.ToString());
                    entity.Extra.Add("roomid", dingdan.roomid.ToString());

                    var ticket  = EncryptionManager.CreateIV();
                    var payData = EncryptionManager.AESEncrypt(entity.ToJson(), ticket);

                    context.Response.Write(AjaxResult.Success(PayHelper.GetPayUrl(payData, ticket)));
                }
            }
            else
            {
                context.Response.Write(AjaxResult.Error("获取支付状态失败!"));
            }
        }
Esempio n. 17
0
    private void OnCheckPayListSuccess(CheckOrderRess resList)
    {
        PayHelper.SetGlobal(resList);

        if (resList.Awards?.Count > 0)
        {
            RewardUtil.AddReward(resList.Awards);

            AwardWindow awardWindow = PopupManager.ShowWindow <AwardWindow>("GameMain/Prefabs/AwardWindow/AwardWindow");
            awardWindow.SetData(resList.Awards);
        }

        EventDispatcher.TriggerEvent(EventConst.GetPayInfoSuccess, resList.UserBuyRmbMall);

        List <string> list = new List <string>();

        foreach (var res in resList.CheckOrderRess_)
        {
            list.Add(res.OrderId);
            if (res.Status == OrderStatusPB.StatusFiish)
            {
                Debug.Log("充值成功---TransactionId:" + res.TransactionId);
            }
            else
            {
                Debug.Log("充值状态:" + res.Status + " ---TransactionId:" + res.TransactionId);
            }

            ProductVo vo = GlobalData.PayModel.GetProduct(res.CommodityId);
            SdkHelper.StatisticsAgent.IOSPay(res, vo);
        }

        Debug.Log("OnCheckPayListSuccess resList.TransactionId=======>" + ObjectDumper.Dump(resList.TransactionId));

        Debug.Log("first" + GlobalData.PlayerModel.PlayerVo.FirstRecharges.Count);

        GalaSDKBaseFunction.EndPay(GalaSDKBaseFunction.GalaSDKType.Apple, resList.TransactionId.ToArray());

        if (resList.TriggerId != null && resList.TriggerId.Count > 0)
        {
            Debug.LogWarning("resList.TriggerId-------->" + resList.TriggerId[0]);
            EventDispatcher.TriggerEvent(EventConst.TriggerGiftPaySuccess, resList.TriggerId);
        }

        if (resList.UserBuyRmbMall == null)
        {
            string orderId = "none";
            if (list.Count > 0)
            {
                orderId = list[0];
            }
            BuglyAgent.ReportException("checkOrderSuccess UserBuyRmbMall", "resList.UserBuyRmbMall为空 orderId:" + orderId, "");
        }
    }
Esempio n. 18
0
    private void OnCheckOrdersSuccess(CheckOrderRess resList)
    {
        Debug.Log("OnCheckOrdersSuccess==>ObjectDumper Length:" + resList.CheckOrderRess_.Count + "\n" +
                  ObjectDumper.Dump(resList));

        PayHelper.SetGlobal(resList);

        List <string> list = new List <string>();

        foreach (var res in resList.CheckOrderRess_)
        {
            JSONObject json = new JSONObject(res.Extra);
            Debug.Log("OnCheckOrdersSuccess==>res.Extra " + res.Extra);

            string data = json["signedData"].str;
            data = data.Replace("\\", "");

            JSONObject signedData = new JSONObject(data);

            JSONObject purchaseToken = signedData["purchaseToken"];

            Debug.Log("OnCheckOrdersSuccess==>purchaseToken " + purchaseToken.str);

            list.Add(purchaseToken.str);

            ProductVo vo = GlobalData.PayModel.GetProduct(res.CommodityId);
            SdkHelper.StatisticsAgent.OnPayEnd(res.OrderId, PayAgent.PayChannel, vo);

            if (res.Amount <= 0 || string.IsNullOrEmpty(res.OrderId))
            {
                BuglyAgent.ReportException("GooglePlay_Pay", "Amount:" + res.Amount + "  OrderId:" + res.OrderId, "none");
            }
        }

        GalaSDKBaseFunction.EndPay(GalaSDKBaseFunction.GalaSDKType.Google, list.ToArray());

        if (resList.Awards?.Count > 0)
        {
            RewardUtil.AddReward(resList.Awards);
            AwardWindow awardWindow = PopupManager.ShowWindow <AwardWindow>("GameMain/Prefabs/AwardWindow/AwardWindow");
            awardWindow.SetData(resList.Awards);
        }

        Debug.Log("GlobalData.PlayerModel.PlayerVo.ExtInfo" + resList.UserExtraInfo);
        EventDispatcher.TriggerEvent(EventConst.GetPayInfoSuccess, resList.UserBuyRmbMall);

        if (resList.TriggerId != null && resList.TriggerId.Count > 0)
        {
            Debug.LogWarning("resList.TrigerId-------->" + resList.TriggerId[0]);
            EventDispatcher.TriggerEvent(EventConst.TriggerGiftPaySuccess, resList.TriggerId);
        }
    }
Esempio n. 19
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            SortedDictionary <string, string> sortedDictionary = new SortedDictionary <string, string>();

            sortedDictionary["merchant_code"]      = base.Request.Form["merchant_code"];
            sortedDictionary["notify_type"]        = base.Request.Form["notify_type"];
            sortedDictionary["notify_id"]          = base.Request.Form["notify_id"];
            sortedDictionary["interface_version"]  = base.Request.Form["interface_version"];
            sortedDictionary["order_no"]           = base.Request.Form["order_no"];
            sortedDictionary["order_time"]         = base.Request.Form["order_time"];
            sortedDictionary["order_amount"]       = base.Request.Form["order_amount"];
            sortedDictionary["extra_return_param"] = base.Request.Form["extra_return_param"];
            sortedDictionary["trade_no"]           = base.Request.Form["trade_no"];
            sortedDictionary["trade_time"]         = base.Request.Form["trade_time"];
            sortedDictionary["trade_status"]       = base.Request.Form["trade_status"];
            sortedDictionary["bank_seq_no"]        = base.Request["bank_seq_no"];
            string plainText = PayHelper.PrepareSign(sortedDictionary);

            sortedDictionary["sign_type"] = base.Request.Form["sign_type"];
            sortedDictionary["sign"]      = base.Request.Form["sign"];
            if (!(sortedDictionary["sign_type"] == "RSA-S"))
            {
                Log.Write(JsonHelper.SerializeObject(sortedDictionary));
            }
            else
            {
                string publicKey = ApplicationSettings.Get("pubKey_zdb");
                publicKey = HttpHelp.RSAPublicKeyJava2DotNet(publicKey);
                if (!HttpHelp.ValidateRsaSign(plainText, publicKey, sortedDictionary["sign"]))
                {
                    Log.Write("验签失败:" + JsonHelper.SerializeObject(sortedDictionary));
                    base.Response.Write("验签失败");
                }
                else
                {
                    ShareDetialInfo shareDetialInfo = new ShareDetialInfo();
                    shareDetialInfo.OrderID   = sortedDictionary["order_no"];
                    shareDetialInfo.IPAddress = Utility.UserIP;
                    shareDetialInfo.PayAmount = System.Convert.ToDecimal(sortedDictionary["order_amount"]);
                    Message message = FacadeManage.aideTreasureFacade.FilliedOnline(shareDetialInfo, 0);
                    if (message.Success)
                    {
                        base.Response.Write("SUCCESS");
                    }
                    else
                    {
                        Log.Write(message.Content + ":" + JsonHelper.SerializeObject(sortedDictionary));
                        base.Response.Write(message.Content);
                    }
                }
            }
        }
Esempio n. 20
0
        /**
         *
         * 查询订单情况
         * @param string out_trade_no  商户订单号
         * @param int succCode         查询订单结果:0表示订单不成功,1表示订单成功,2表示继续查询
         * @return 订单查询接口返回的数据,参见协议接口
         */
        private SortedDictionary <string, object> MicroPayQuery(string out_trade_no, out int succCode)
        {
            string url   = "https://api.mch.weixin.qq.com/pay/orderquery";
            string appid = "WeChat_APPID";
            string MCHID = "WeChat_MCHID";

            SortedDictionary <string, object> data = new SortedDictionary <string, object>
            {
                { "out_trade_no", out_trade_no },
                { "appid", appid },  //公众账号ID
                { "mch_id", MCHID }, //商户号
                { "nonce_str", PayHelper.Nonce_str }//随机字符串
            };

            data.Add("sign", PayHelper.MakeSign(data));//签名

            string xml      = data.ToXml();
            string response = HttpService.Post(xml, url, false, 10);//调用HTTP通信接口提交数据

            //将xml格式的数据转化为对象以返回
            var result = PayHelper.FromXml(response);


            if (result["return_code"].ToString() == "SUCCESS" && result["result_code"].ToString() == "SUCCESS")
            {
                //支付成功
                if (result["trade_state"].ToString() == "SUCCESS")
                {
                    succCode = 1;
                    return(result);
                }
                //用户支付中,需要继续查询
                else if (result["trade_state"].ToString() == "USERPAYING")
                {
                    succCode = 2;
                    return(result);
                }
            }

            //如果返回错误码为“此交易订单号不存在”则直接认定失败
            if (result["err_code"].ToString() == "ORDERNOTEXIST")
            {
                succCode = 0;
            }
            else
            {
                //如果是系统错误,则后续继续
                succCode = 2;
            }
            return(result);
        }
Esempio n. 21
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        // GET: Pay
        public ActionResult Pay()
        {
            var m = new AlipayBizContentModel()
            {
                body    = "Iphone6 16G",
                subject = "Iphone6 16G",
                //out_trade_no = "20150320010102001",
                out_trade_no = DateTime.Now.Ticks.ToString(),
                total_amount = decimal.Parse("88.88"),
                product_code = "FAST_INSTANT_TRADE_PAY"
            };
            var form = PayHelper.AliPay(m);

            return(Content(form, "text/html", Encoding.UTF8));
        }
Esempio n. 22
0
        /**
         *
         * 统一下单
         * @param WxPaydata inputObj 提交给统一下单API的参数
         * @param int timeOut 超时时间
         * @throws Exception
         * @return 成功时返回,其他抛异常
         */
        public SortedDictionary <string, object> UnifiedOrder(SortedDictionary <string, object> inputObj, int timeOut = 6)
        {
            //检测必填参数
            if (!inputObj.ContainsKey("out_trade_no"))
            {
                throw new Exception("缺少统一支付接口必填参数out_trade_no!");
            }
            else if (!inputObj.ContainsKey("body"))
            {
                throw new Exception("缺少统一支付接口必填参数body!");
            }
            else if (!inputObj.ContainsKey("total_fee"))
            {
                throw new Exception("缺少统一支付接口必填参数total_fee!");
            }
            else if (!inputObj.ContainsKey("trade_type"))
            {
                throw new Exception("缺少统一支付接口必填参数trade_type!");
            }

            //关联参数
            if (inputObj["trade_type"].ToString() == "JSAPI" && !inputObj.ContainsKey("openid"))
            {
                throw new Exception("统一支付接口中,缺少必填参数openid!trade_type为JSAPI时,openid为必填参数!");
            }
            if (inputObj["trade_type"].ToString() == "NATIVE" && !inputObj.ContainsKey("product_id"))
            {
                throw new Exception("统一支付接口中,缺少必填参数product_id!trade_type为JSAPI时,product_id为必填参数!");
            }

            //异步通知url未设置,则使用配置文件中的url
            if (!inputObj.ContainsKey("notify_url"))
            {
                inputObj.Add("notify_url", "http://url");//异步通知url
            }

            inputObj.Add("appid", appid);                   //公众账号ID
            inputObj.Add("mch_id", mch_id);                 //商户号
            inputObj.Add("spbill_create_ip", ip);           //终端ip
            inputObj.Add("nonce_str", PayHelper.Nonce_str); //随机字符串

            inputObj.Add("sign", PayHelper.MakeSign(inputObj, key));

            string response = HttpService.Post(PayHelper.ToXml(inputObj), "https://api.mch.weixin.qq.com/pay/unifiedorder", false, timeOut);

            return(PayHelper.FromXml(response, key));
        }
Esempio n. 23
0
        /**
         *
         * 转换短链接
         * 该接口主要用于扫码原生支付模式一中的二维码链接转成短链接(weixin://wxpay/s/XXXXXX),
         * 减小二维码数据量,提升扫描速度和精确度。
         * @param WxPayData inputObj 提交给转换短连接API的参数
         * @param int timeOut 接口超时时间
         * @throws Exception
         * @return 成功时返回,其他抛异常
         */
        public SortedDictionary <string, object> ShortUrl(SortedDictionary <string, object> inputObj, int timeOut = 6)
        {
            //检测必填参数
            if (!inputObj.ContainsKey("long_url"))
            {
                throw new Exception("需要转换的URL,签名用原串,传输需URL encode!");
            }

            inputObj.Add("appid", appid);                       //公众账号ID
            inputObj.Add("mch_id", mch_id);                     //商户号
            inputObj.Add("nonce_str", PayHelper.Nonce_str);     //随机字符串
            inputObj.Add("sign", PayHelper.MakeSign(inputObj)); //签名
            string xml      = inputObj.ToXml();
            string response = HttpService.Post(xml, "https://api.mch.weixin.qq.com/tools/shorturl", false, timeOut);

            return(PayHelper.FromXml(response));;
        }
Esempio n. 24
0
        /**
         *
         * 撤销订单API接口
         * @param WxPayData inputObj 提交给撤销订单API接口的参数,out_trade_no和transaction_id必填一个
         * @param int timeOut 接口超时时间
         * @throws Exception
         * @return 成功时返回API调用结果,其他抛异常
         */
        public SortedDictionary <string, object> Reverse(SortedDictionary <string, object> inputObj, int timeOut = 6)
        {
            //检测必填参数
            if (!inputObj.ContainsKey("out_trade_no") && !inputObj.ContainsKey("transaction_id"))
            {
                throw new Exception("撤销订单API接口中,参数out_trade_no和transaction_id必须填写一个!");
            }

            inputObj.Add("appid", appid);                       //公众账号ID
            inputObj.Add("mch_id", mch_id);                     //商户号
            inputObj.Add("nonce_str", PayHelper.Nonce_str);     //随机字符串
            inputObj.Add("sign", PayHelper.MakeSign(inputObj)); //签名
            string xml      = inputObj.ToXml();
            string response = HttpService.Post(xml, "https://api.mch.weixin.qq.com/secapi/pay/reverse", true, timeOut);

            return(PayHelper.FromXml(response));
        }
Esempio n. 25
0
        /**
         *
         * 关闭订单
         * @param WxPayData inputObj 提交给关闭订单API的参数
         * @param int timeOut 接口超时时间
         * @throws Exception
         * @return 成功时返回,其他抛异常
         */
        public SortedDictionary <string, object> CloseOrder(SortedDictionary <string, object> inputObj, int timeOut = 6)
        {
            //检测必填参数
            if (!inputObj.ContainsKey("out_trade_no"))
            {
                throw new Exception("关闭订单接口中,out_trade_no必填!");
            }

            inputObj.Add("appid", appid);                       //公众账号ID
            inputObj.Add("mch_id", mch_id);                     //商户号
            inputObj.Add("nonce_str", PayHelper.Nonce_str);     //随机字符串
            inputObj.Add("sign", PayHelper.MakeSign(inputObj)); //签名

            string xml      = PayHelper.ToXml(inputObj);
            string response = HttpService.Post(xml, "https://api.mch.weixin.qq.com/pay/closeorder", false, timeOut);

            return(PayHelper.FromXml(response));
        }
Esempio n. 26
0
        /**
         *
         * 查询退款
         * 提交退款申请后,通过该接口查询退款状态。退款有一定延时,
         * 用零钱支付的退款20分钟内到账,银行卡支付的退款3个工作日后重新查询退款状态。
         * out_refund_no、out_trade_no、transaction_id、refund_id四个参数必填一个
         * @param WxPayData inputObj 提交给查询退款API的参数
         * @param int timeOut 接口超时时间
         * @throws Exception
         * @return 成功时返回,其他抛异常
         */
        public SortedDictionary <string, object> RefundQuery(SortedDictionary <string, object> inputObj, int timeOut = 6)
        {
            //检测必填参数
            if (!inputObj.ContainsKey("out_refund_no") && !inputObj.ContainsKey("out_trade_no") &&
                !inputObj.ContainsKey("transaction_id") && !inputObj.ContainsKey("refund_id"))
            {
                throw new Exception("退款查询接口中,out_refund_no、out_trade_no、transaction_id、refund_id四个参数必填一个!");
            }

            inputObj.Add("appid", appid);                       //公众账号ID
            inputObj.Add("mch_id", mch_id);                     //商户号
            inputObj.Add("nonce_str", PayHelper.Nonce_str);     //随机字符串
            inputObj.Add("sign", PayHelper.MakeSign(inputObj)); //签名

            string xml      = inputObj.ToXml();
            string response = HttpService.Post(xml, "https://api.mch.weixin.qq.com/pay/refundquery", false, timeOut);//调用HTTP通信接口以提交数据到API

            return(PayHelper.FromXml(response));
        }
Esempio n. 27
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string str = ApplicationSettings.Get("key_jifubao");

            System.Collections.Generic.Dictionary <string, string> dictionary = new System.Collections.Generic.Dictionary <string, string>();
            dictionary["service"]   = "TRADE.NOTIFY";
            dictionary["merId"]     = base.Request["merId"];
            dictionary["tradeNo"]   = base.Request["tradeNo"];
            dictionary["tradeDate"] = base.Request["tradeDate"];
            dictionary["opeNo"]     = base.Request["opeNo"];
            dictionary["opeDate"]   = base.Request["opeDate"];
            dictionary["amount"]    = base.Request["amount"];
            dictionary["status"]    = base.Request["status"];
            dictionary["extra"]     = "";
            dictionary["payTime"]   = base.Request["payTime"];
            string str2 = PayHelper.PrepareSign(dictionary);
            string text = TextEncrypt.EncryptPassword(str2 + str).ToLower();

            dictionary["sign"]       = base.Request["sign"];
            dictionary["notifyType"] = base.Request["notifyType"];
            if (!(text.ToLower() == dictionary["sign"].ToLower()))
            {
                Log.Write("签名错误" + dictionary["tradeNo"]);
                base.Response.Write("签名错误");
            }
            else
            {
                ShareDetialInfo shareDetialInfo = new ShareDetialInfo();
                shareDetialInfo.OrderID   = dictionary["tradeNo"];
                shareDetialInfo.IPAddress = Utility.UserIP;
                shareDetialInfo.PayAmount = System.Convert.ToDecimal(dictionary["amount"]);
                Message message = FacadeManage.aideTreasureFacade.FilliedOnline(shareDetialInfo, 0);
                if (message.Success)
                {
                    Log.Write("充值成功" + dictionary["tradeNo"]);
                    base.Response.Write("success");
                }
                else
                {
                    Log.Write(message.Content + dictionary["tradeNo"]);
                }
            }
        }
Esempio n. 28
0
        /// <summary>
        /// 通联支付支付
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <AllinpayResponse> Pay(PayRequestDto request)
        {
            var req = new RequestPublic(_options.CusId, _options.AppId, request.Trxamt, request.Reqsn, request.PayType, _options.SignType);

            req.ValidTime = request.ValidTime;
            req.Body      = request.Body;
            req.Remark    = request.Remark;
            req.Acct      = request.Acct;
            if (!string.IsNullOrWhiteSpace(_options.AppKey))
            {
                req.AppKey = _options.AppKey;
            }
            if (!string.IsNullOrWhiteSpace(_options.NotifyUrl))
            {
                req.NotifyUrl = _options.NotifyUrl;
            }
            if (!string.IsNullOrWhiteSpace(_options.SubAppid))
            {
                req.SubAppid = _options.SubAppid;
            }
            if (!string.IsNullOrWhiteSpace(_options.Version))
            {
                req.Version = _options.Version;
            }
            var param = req.GetPublicParams();
            var res   = await _http.PostResponse <AllinpayResponse>(_options.ApiGateWay + payUrl, param);

            if (!string.IsNullOrWhiteSpace(res.Sign))
            {
                if (PayHelper.ValidSign(param, _options.AppKey, _options.SignType))
                {
                    return(await Task.FromResult <AllinpayResponse>(res));
                }
                else
                {
                    return(await Task.FromException <AllinpayResponse>(new Exception("验证签名失败")));
                }
            }
            else
            {
                return(await Task.FromResult <AllinpayResponse>(res));
            }
        }
Esempio n. 29
0
        /**
         *
         * 申请退款
         * @param WxPayData inputObj 提交给申请退款API的参数
         * @param int timeOut 超时时间
         * @throws Exception
         * @return 成功时返回接口调用结果,其他抛异常
         */
        public static SortedDictionary <string, object> Refund(SortedDictionary <string, object> inputObj, int timeOut = 30)
        {
            //检测必填参数
            if (!inputObj.ContainsKey("out_trade_no") && !inputObj.ContainsKey("transaction_id"))
            {
                throw new Exception("退款申请接口中,out_trade_no、transaction_id至少填一个!");
            }
            else if (!inputObj.ContainsKey("out_refund_no"))
            {
                throw new Exception("退款申请接口中,缺少必填参数out_refund_no!");
            }
            else if (!inputObj.ContainsKey("total_fee"))
            {
                throw new Exception("退款申请接口中,缺少必填参数total_fee!");
            }
            else if (!inputObj.ContainsKey("refund_fee"))
            {
                throw new Exception("退款申请接口中,缺少必填参数refund_fee!");
            }
            else if (!inputObj.ContainsKey("op_user_id"))
            {
                throw new Exception("退款申请接口中,缺少必填参数op_user_id!");
            }

            inputObj.Add("appid", "WeChat_APPID");                                 //公众账号ID
            inputObj.Add("mch_id", "WeChat_MCHID");                                //商户号
            inputObj.Add("nonce_str", Guid.NewGuid().ToString().Replace("-", "")); //随机字符串
            inputObj.Add("sign", inputObj.MakeSign());                             //签名

            string xml   = inputObj.ToXml();
            var    start = DateTime.Now;

            string response = HttpService.Post(xml, "https://api.mch.weixin.qq.com/secapi/pay/refund", true, timeOut);//调用HTTP通信接口提交数据到API

            var end      = DateTime.Now;
            int timeCost = (int)((end - start).TotalMilliseconds);//获得接口耗时

            return(PayHelper.FromXml(response));
        }
Esempio n. 30
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string str = ApplicationSettings.Get("key_e");
            SortedDictionary <string, string> sortedDictionary = new SortedDictionary <string, string>();

            sortedDictionary["dd"]           = base.Request["dd"];
            sortedDictionary["total_fee"]    = base.Request["total_fee"];
            sortedDictionary["out_trade_no"] = base.Request["out_trade_no"];
            sortedDictionary["partner"]      = base.Request["partner"];
            sortedDictionary["sign_type"]    = base.Request["sign_type"];
            sortedDictionary["charset"]      = base.Request["charset"];
            sortedDictionary["sign"]         = base.Request["sign"];
            sortedDictionary["msg"]          = base.Request["msg"];
            Log.Write("通知参数:" + JsonHelper.SerializeObject(sortedDictionary));
            string str2 = PayHelper.PrepareSign(sortedDictionary);
            string b    = TextEncrypt.EncryptPassword(str2 + str).ToLower();

            if (!(sortedDictionary["sign"].ToLower() == b))
            {
                Log.Write("签名错误:" + JsonHelper.SerializeObject(sortedDictionary));
                base.Response.Write("签名错误");
            }
            else
            {
                ShareDetialInfo shareDetialInfo = new ShareDetialInfo();
                shareDetialInfo.OrderID   = sortedDictionary["out_trade_no"];
                shareDetialInfo.IPAddress = Utility.UserIP;
                shareDetialInfo.PayAmount = System.Convert.ToDecimal(sortedDictionary["total_fee"]);
                Message message = FacadeManage.aideTreasureFacade.FilliedOnline(shareDetialInfo, 0);
                if (message.Success)
                {
                    base.Response.Write("SUCCESS");
                }
                else
                {
                    Log.Write(message.Content + ":" + JsonHelper.SerializeObject(sortedDictionary));
                }
            }
        }