コード例 #1
0
        /// <summary>
        /// 获取微信预支付信息包
        /// </summary>
        /// <returns></returns>
        private static string GetWxPayPackage(OnLinePayOrder orderReturn, string paytype, string openid,
                                              string authority)
        {
            string    domain = string.IsNullOrEmpty(AppConfig.FrontSiteDomain) ? authority : AppConfig.FrontSiteDomain;
            WxPayInfo wx     = new WxPayInfo
            {
                AppID     = ApplicationSettings.Get(paytype == "wx" ? "WXAPPID" : "WXNATIVEAPPID"),
                AppSecret = ApplicationSettings.Get(paytype == "wx" ? "WXAPPSECRET" : "WXNATIVESECRET"),
                // ReSharper disable once SpecifyACultureInStringConversionExplicitly
                Body       = orderReturn.Amount.ToString(),
                Key        = ApplicationSettings.Get(paytype == "wx" ? "WXAPPKEY" : "WXNATIVEKEY"),
                Mchid      = ApplicationSettings.Get(paytype == "wx" ? "WXAPPMCHID" : "WXNATIVEMCHID"),
                NotifyUrl  = "http://" + domain + "/Notify/" + (paytype == "wx" ? "WxApp.aspx" : "WxWeb.aspx"),
                OpenId     = openid,
                OutTradeNo = orderReturn.OrderID,
                TotalFee   = (orderReturn.Amount * 100).ToString("F0"),
                TradeType  = paytype == "wx" ? "APP" : "JSAPI"
            };
            WxPayHelper helper = new WxPayHelper(wx);

            return(helper.GetPrepayIDSign());
        }