示例#1
0
 /// <summary>
 /// 支付下单
 /// </summary>
 /// <param name="config">公共参数</param>
 /// <param name="sClientIp">客户端的原始Ip(不能是代理IP必须是真实的IP)</param>
 /// <param name="sOrderNo">订单号</param>
 /// <param name="sDescription">订单描述,展示在支付页面上的文字描述</param>
 /// <param name="total_fee">支付金额(单位是分)</param>
 /// <param name="notify_url">异步通知地址</param>
 /// <param name="return_url">同步通知地址</param>
 /// <param name="iPayType">支付方式 1-支付宝 ;2-微信</param>
 /// <returns></returns>
 public Message bookOrder(TenPayConfig config, string sClientIp, string sOrderNo, string sDescription, decimal total_fee, string notify_url, string return_url, int iPayType, int time_expire = 2)
 {
     if (iPayType == 1)
     {//支付宝支付
         var res = AlipayHelp.Alipay(new AlipayConfig()
         {
             app_id               = config.appid,
             alipay_public_key    = config.key,
             merchant_private_key = config.merchant_private_key
         }, sDescription, sOrderNo, total_fee.ToString(), notify_url, return_url, time_expire);
         return(res);
     }
     else
     {
         if (string.IsNullOrEmpty(sClientIp))
         {
             return(new Message()
             {
                 state = false,
                 error = "用户真实IP必传"
             });
         }
         string wxPayType = System.Configuration.ConfigurationManager.AppSettings["wxPayMtd"];
         total_fee = total_fee * 100;
         wxPayType = string.IsNullOrEmpty(wxPayType) ? "weixin" : wxPayType;
         Message res = null;
         if (wxPayType.Equals("weixin"))
         {
             res = TenPayMode.UniteOrder_First(config, sDescription, sOrderNo, Convert.ToInt32(total_fee).ToString(), sClientIp, notify_url, time_expire);
         }
         else if (wxPayType.Equals("pingan"))
         {
             res = PingAnPay.UniteOrder_First(config, sDescription, sOrderNo, Convert.ToInt32(total_fee).ToString(), sClientIp, notify_url, time_expire);
         }
         else
         {
             return(res = new Message()
             {
                 state = false,
                 error = "微信支付类型错误."
             });
         }
         if (res.state)
         {//对url进行urlencode处理
             string redirect_url = return_url;
             if (redirect_url != null)
             {
                 res.data = string.Format("{0}&redirect_url={1}", res.data, TenPayHelp.UrlEncode(redirect_url));
             }
         }
         return(res);
     }
 }
示例#2
0
        /// <summary>
        /// 微信申请退款
        /// </summary>
        /// <param name="sOrderNo">订单号</param>
        /// <param name="sRefundNo">退款订单号</param>
        /// <param name="total_fee">支付的金额</param>
        /// <param name="refund_fee">申请退款的金额</param>
        /// <param name="refund_desc">退款描述</param>
        /// <returns></returns>
        public Message PayRefund(TenPayConfig config, string sOrderNo, string sRefundNo, int total_fee, int refund_fee, string refund_desc)
        {
            string wxPayType = System.Configuration.ConfigurationManager.AppSettings["wxPayMtd"];

            wxPayType = string.IsNullOrEmpty(wxPayType) ? "weixin" : wxPayType;
            Message result = null;

            if (wxPayType.Equals("weixin"))
            {
                result = TenPayMode.PayRefund(config, sOrderNo, sRefundNo, total_fee.ToString(), refund_fee.ToString(), refund_desc);
            }
            else if (wxPayType.Equals("pingan"))
            {
                result = PingAnPay.PayRefund(config, sOrderNo, sRefundNo, total_fee, refund_fee, refund_desc);
            }
            else
            {
                result = new Message()
                {
                    state = false, error = "支付方式(wxPayType)参数错误"
                };
            }
            return(result);
        }
示例#3
0
        /// <summary>
        /// 根据订单号查询微信支付状态
        /// </summary>
        /// <param name="config">公共参数</param>
        /// <param name="sOrderNo"></param>
        /// <returns></returns>
        public Message QueryPayState(TenPayConfig config, string sOrderNo)
        {
            var res = TenPayMode.OrderQuery(config, sOrderNo);

            return(res);
        }