当前位置: 首页>>代码示例>>C#>>正文


C# RequestHandler.ParseXML方法代码示例

本文整理汇总了C#中RequestHandler.ParseXML方法的典型用法代码示例。如果您正苦于以下问题:C# RequestHandler.ParseXML方法的具体用法?C# RequestHandler.ParseXML怎么用?C# RequestHandler.ParseXML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RequestHandler的用法示例。


在下文中一共展示了RequestHandler.ParseXML方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WeChatRefund

        /// <summary>
        /// 微信退单
        /// </summary>
        /// <param name="dingdan"></param>
        /// <param name="dto"></param>
        /// <param name="returnMsg"></param>
        /// <returns></returns>
        private bool WeChatRefund(wx_hotel_dingdan dingdan, TuidanDto dto, int wid, out string returnMsg)
        {
            bool result = false;
            returnMsg = null;

            var refundResult = _hotelOrderService.GetWeChatRefundParams(wid, dingdan.hotelid.Value, dingdan.id, dto.refundCode);

            //使用系统订单号退单
            if (refundResult != null && refundResult.Tables.Count > 0 && refundResult.Tables[0].Rows.Count > 0)
            {
                var orderNumber = refundResult.Tables[0].Rows[0]["orderNumber"].ToString();
                var transaction_id = refundResult.Tables[0].Rows[0]["transaction_id"].ToString();
                var refundAmount = Convert.ToInt32(refundResult.Tables[0].Rows[0]["refundAmount"]);
                var payAmount = Convert.ToInt32(refundResult.Tables[0].Rows[0]["payAmount"]);


                var wxModel = new BLL.wx_userweixin().GetModel(wid);
                var payInfo = new BLL.wx_payment_wxpay().GetModelByWid(wid);

                var requestHandler = new RequestHandler(null);
                requestHandler.SetParameter("out_trade_no", orderNumber);
                //requestHandler.SetParameter("transaction_id", transaction_id);
                requestHandler.SetParameter("out_refund_no", dto.refundCode);
                requestHandler.SetParameter("appid", wxModel.AppId);
                requestHandler.SetParameter("mch_id", payInfo.mch_id);//商户号
                requestHandler.SetParameter("nonce_str", Guid.NewGuid().ToString().Replace("-", ""));

                //退款金额
                if (PayHelper.IsDebug)
                {
                    requestHandler.SetParameter("total_fee", (payAmount).ToString());
                    requestHandler.SetParameter("refund_fee", (refundAmount).ToString());
                }
                else
                {
                    requestHandler.SetParameter("total_fee", (payAmount * 100).ToString());
                    requestHandler.SetParameter("refund_fee", (refundAmount * 100).ToString());
                }

                requestHandler.SetParameter("op_user_id", wxModel.AppId);
                requestHandler.SetParameter("sign", requestHandler.CreateMd5Sign("key", payInfo.paykey));

                var refundInfo = TenPayV3Helper.Refund(requestHandler.ParseXML(), string.Format(@"{0}{1}", AppDomain.CurrentDomain.BaseDirectory, payInfo.certInfoPath), payInfo.cerInfoPwd);
                var refundOrderResponse = new RefundOrderResponse(refundInfo);

                result = refundOrderResponse.IsSuccess;
                returnMsg = refundOrderResponse.return_msg;
            }

            return result;
        }
开发者ID:jxiaox,项目名称:weixinpf,代码行数:58,代码来源:hotel_dingdan_cz.aspx.cs

示例2: UnifiedOrder

        /// <summary>
        ///     统一下单
        /// </summary>
        /// <param name="unifiedOrderInfo"></param>
        /// <param name="errMessage"></param>
        /// <returns></returns>
        public JsAPIParameter UnifiedOrder(UnifiedOrderInfo unifiedOrderInfo, out string errMessage)
        {
            if (unifiedOrderInfo == null)
            {
                errMessage = "下单数据为空";
                return null;
            }

            if (!unifiedOrderInfo.CheckRequired(out errMessage))
            {
                return null;
            }

            var paymentInfoRepository = DependencyManager.Resolve<IPaymentInfoRepository>();

            //判断当前订单号是否存在
            var orderInfo = paymentInfoRepository.GetPaymentInfoBySysOrderNo(unifiedOrderInfo.PayModuleName,
                unifiedOrderInfo.OutTradeNo);
            if (orderInfo != null && orderInfo.Status != 0 && orderInfo.OpenId.Equals(unifiedOrderInfo.Openid))
            //0表示尚未支付
            {
                errMessage = "系统异常,请重新下单操作";
                return null;
            }

            //调用微信统一下单接口
            var appInfo = DependencyManager.Resolve<IAppInfoRepository>().GetAppInfo(unifiedOrderInfo.AppId);
            var payment =
                DependencyManager.Resolve<Weixin.Repository.IPaymentInfoRepository>()
                    .GetModelByAppId(unifiedOrderInfo.AppId);
            if (string.IsNullOrEmpty(appInfo.AppId) || string.IsNullOrEmpty(payment.MchId) ||
                string.IsNullOrEmpty(payment.Paykey))
            {
                errMessage = "当前公众号支付配置不完整";
                return null;
            }


            var packageReqHandler = new RequestHandler(default(HttpContext));
            //初始化
            packageReqHandler.Init();

            var nonceStr = TenPayV3Util.GetNoncestr();

            //设置package订单参数
            packageReqHandler.SetParameter("appid", appInfo.AppId); //公众账号ID
            packageReqHandler.SetParameter("mch_id", payment.MchId); //商户号
            packageReqHandler.SetParameter("nonce_str", nonceStr); //随机字符串
            packageReqHandler.SetParameter("body", unifiedOrderInfo.Body); //商品描述
            packageReqHandler.SetParameter("attach", unifiedOrderInfo.PayModuleName); //向微信传递系统支付模块ID
            packageReqHandler.SetParameter("out_trade_no", unifiedOrderInfo.OutTradeNo); //商家订单号

            //debug模式下,单位为
            packageReqHandler.SetParameter("total_fee", PayHelper.IsDebug
                ? (unifiedOrderInfo.TotalFee / 100).ToString()
                : (unifiedOrderInfo.TotalFee * 100).ToString());

            packageReqHandler.SetParameter("spbill_create_ip", "1.1.1.1"); //用户的公网ip,不是商户服务器IP

            packageReqHandler.SetParameter("notify_url", PayHelper.GetPayNotifyUrl()); //接收财付通通知的URL
            packageReqHandler.SetParameter("trade_type", TenPayV3Type.JSAPI.ToString()); //交易类型
            packageReqHandler.SetParameter("openid", unifiedOrderInfo.Openid); //用户的openId

            var sign = packageReqHandler.CreateMd5Sign("key", payment.Paykey);
            packageReqHandler.SetParameter("sign", sign); //签名

            var data = packageReqHandler.ParseXML();

            //同意下单,获取到预付订单号
            var unifiedOrderResult = TenPayV3Helper.Unifiedorder(data);
            var rtnUnifiedOrderResult = new UnifiedOrderResponse(unifiedOrderResult);

            //下单成功,保存下单对象
            if (rtnUnifiedOrderResult.IsSuccess)
            {
                var paymentInfo = new PaymentInfo
                {
                    PaymentId = Guid.NewGuid(),
                    AppId = unifiedOrderInfo.AppId,
                    CreateTime = DateTime.Now,
                    Description = "无",
                    Body = unifiedOrderInfo.Body,
                    ModuleName = unifiedOrderInfo.PayModuleName,
                    OrderCode = unifiedOrderInfo.OutTradeNo,
                    OrderId = unifiedOrderInfo.OrderId,
                    OpenId = unifiedOrderInfo.Openid,
                    PayAmount = unifiedOrderInfo.TotalFee,
                    WxOrderCode = rtnUnifiedOrderResult.prepay_id,
                    ModifyTime = DateTime.Now,
                    Status = 0
                };

                paymentInfoRepository.Add(paymentInfo);

//.........这里部分代码省略.........
开发者ID:jxiaox,项目名称:weixinpfnew,代码行数:101,代码来源:UnifiedOrderService.cs


注:本文中的RequestHandler.ParseXML方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。