/// <summary>
        /// 定位到支付宝支付界面
        /// </summary>
        public void RedirectToAlipay()
        {
            DigitalTrade alipayTrade = new DigitalTrade();
            alipayTrade.Subject = string.Format("{0} 论坛积分充值({1}:{2}{3}),用户:{4}", config.Forumtitle, creditstransname, creditsamount, creditstransunit, username);
            if (Utils.IsValidEmail(config.Alipayaccout))//如果用户保存在配置文件里面的支付宝帐号格式是email的话
                alipayTrade.Seller_Email = config.Alipayaccout;
            else
                alipayTrade.Seller_Id = config.Alipayaccout;

            alipayTrade.Return_Url = Utils.GetRootUrl(forumpath) + "tools/notifypage.aspx";
            alipayTrade.Notify_Url = Utils.GetRootUrl(forumpath) + "tools/notifypage.aspx";
            alipayTrade.Quantity = 1;
            decimal price = decimal.Round(((decimal)creditsamount / (decimal)config.Cashtocreditrate), 2);
            alipayTrade.Price = price > 0.1M ? price : 0.1M;//限定每个订单的最低价格是0.1元
            alipayTrade.Payment_Type = 1;
            alipayTrade.PayMethod = "bankPay";//跳转到支付宝时默认支付类型是网上银行
            string payUrl = "";

            alipayTrade.Partner = config.Alipaypartnerid;
            alipayTrade.Sign = config.Alipaypartnercheckkey;
            payUrl = StandardAliPayment.GetService().CreateDigitalGoodsTradeUrl(alipayTrade);

            CreditOrders.CreateCreditOrder(userid, username, creditstrans, creditsamount, 1, alipayTrade.Out_Trade_No);//创建积分充值订单
            HttpContext.Current.Response.Redirect(payUrl);//跳转到支付宝即时到帐支付页面
        }
        /// <summary>
        /// 后台测试填写帐号是否可用
        /// </summary>
        public void TestAccout(string accout)
        {
            int openPartner = DNTRequest.GetInt("openpartner", 0);
            string partnerId = DNTRequest.GetString("partnerid");
            string partnerKey = DNTRequest.GetString("partnerKey");

            DigitalTrade virtualTrade = new DigitalTrade();
            virtualTrade.Subject = "测试支付宝充值功能";

            if (Utils.IsValidEmail(accout))//如果传递的帐号类型是email
                virtualTrade.Seller_Email = accout;
            else
                virtualTrade.Seller_Id = accout;

            virtualTrade.Return_Url = Utils.GetRootUrl(BaseConfigs.GetForumPath) + "tools/notifypage.aspx";
            virtualTrade.Notify_Url = Utils.GetRootUrl(BaseConfigs.GetForumPath) + "tools/notifypage.aspx";
            virtualTrade.Quantity = 1;
            virtualTrade.Price = 0.1M;
            virtualTrade.Payment_Type = 1;
            virtualTrade.PayMethod = "bankPay";

            string payUrl = "";

            if (openPartner == 1)
            {
                virtualTrade.Partner = partnerId;
                virtualTrade.Sign = partnerKey;
                payUrl = StandardAliPayment.GetService().CreateDigitalGoodsTradeUrl(virtualTrade);
            }
            else
            {
                payUrl = AliPayment.GetService().CreateDigitalGoodsTradeUrl(virtualTrade);
            }

            HttpContext.Current.Response.Redirect(payUrl);
        }
Beispiel #3
0
        /// <summary>
        /// 获取在线支付的URL字符串
        /// </summary>
        /// <returns></returns>
        private string GetAliPayUrl()
        {
            string current_url = DNTRequest.GetUrl();
            //forumurl = "http://124.207.144.194:8081/";
            if (forumurl.ToLower().StartsWith("http://"))
                current_url = forumurl + "tradenotify.aspx";
            else
            {
                if (current_url.IndexOf("/aspx/") > 0)
                    current_url = current_url.Substring(0, current_url.IndexOf("/aspx/") + 1) + "tradenotify.aspx";
                else
                    current_url = current_url.Substring(0, current_url.LastIndexOf("/") + 1) + "tradenotify.aspx";
            }

            IPayment _payment = AliPayment.GetService();
            if (goodstradelog.Transport > 0)
            {
                //普通(实物)交易
                NormalTrade normalTrade = new NormalTrade();
                normalTrade.Body = goodstradelog.Subject; //goodsinfo.Message;
                normalTrade.Out_Trade_No = goodstradelog.Tradeno;

                string transportpay = "";
                switch (goodstradelog.Transportpay)
                {
                    case 1: transportpay = "SELLER_PAY"; break;//卖家承担运费
                    case 2: transportpay = "BUYER_PAY"; break;//买家承担运费
                    case 3: transportpay = "BUYER_PAY_AFTER_RECEIVE"; break; //买家收到货后直接支付给物流公司,费用不用计到总价中
                }

                string transport = "";
                switch (goodstradelog.Transport)
                {
                    case 0: transport = "VIRTUAL"; break;//虚拟物品
                    case 1: transport = "POST"; break;//平邮
                    case 2: transport = "EMS"; break;//EMS
                    case 3: transport = "EXPRESS"; break; //其他快递公司
                }
                normalTrade.Logistics_Info = new LogisticsInfo[1] { new LogisticsInfo(transport, goodstradelog.Transportfee, transportpay) };
                normalTrade.Notify_Url = current_url;
                normalTrade.Payment_Type = goodsinfo.Itemtype;
                normalTrade.Price = goodstradelog.Price;
                normalTrade.Quantity = goodstradelog.Number;
                normalTrade.Seller_Email = goodstradelog.Selleraccount;
                normalTrade.Show_Url = current_url.Replace("tradenotify.aspx", base.ShowGoodsAspxRewrite(goodstradelog.Goodsid));
                normalTrade.Subject = goodstradelog.Subject;
                normalTrade.Buyer_Email = Users.GetShortUserInfo(goodstradelog.Buyerid).Email;
                
                return _payment.CreateNormalGoodsTradeUrl((ITrade)normalTrade);
            }
            else
            {
                //虚拟商品交易
                DigitalTrade digitalTrade = new DigitalTrade();
                digitalTrade.Body = goodstradelog.Subject;
                digitalTrade.Out_Trade_No = goodstradelog.Tradeno;

                digitalTrade.Notify_Url = current_url;
                digitalTrade.Payment_Type = goodsinfo.Itemtype;
                digitalTrade.Price = goodstradelog.Price;
                digitalTrade.Quantity = goodstradelog.Number;
                digitalTrade.Seller_Email = goodstradelog.Selleraccount;
                digitalTrade.Show_Url = current_url.Replace("tradenotify.aspx", base.ShowGoodsAspxRewrite(goodstradelog.Goodsid));
                digitalTrade.Subject = goodstradelog.Subject;
                digitalTrade.Buyer_Email = Users.GetShortUserInfo(goodstradelog.Buyerid).Email;

                return _payment.CreateDigitalGoodsTradeUrl((ITrade)digitalTrade);
            }
        }