Пример #1
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));
            }
        }