protected void Page_Load(object sender, EventArgs e) { CommOrderBll obll = new CommOrderBll(); string orderId = Request.QueryString["orderId"]; CommOrderModel model = obll.GetModel(orderId); List <CommOrderItemModel> items = obll.GetOrderItems(orderId); string subject = String.Join(",", (from s in items select s.ProductName).ToArray()); int quantity = (from s in items select s.Quantity).Sum(); string paymethod = (model.ShipMethod == ShipMethodType.EMS?"EMS":"Express"); subject = String.IsNullOrEmpty(subject)?null:subject; string agent = null; string body = null; AliPay ap = new AliPay(); StandardGoods bp = new StandardGoods(PayServiceType.trade_create_by_buyer.Key, AlipaySetting.Partner, AlipaySetting.NotifyUrl, AlipaySetting.ReturnUrl, agent, AlipaySetting.EncodeType, AlipaySetting.Key, AlipaySetting.SignType, subject, body, model.OrderId, model.Paysum, quantity, null, AlipaySetting.SellerEmail, null, null, null, null, "POST", model.ShipFee, LogisticsPayment.SELLER_PAY.Key, "1"); bp.Notify_Url = AlipaySetting.NotifyUrl; bp.Return_Url = AlipaySetting.ReturnUrl; bp.Receive_Address = model.FullAddress; bp.Receive_Phone = model.RecieverPhone; bp.Receive_Zip = model.Postalcode; bp.Receive_Name = model.RecieverName; ap.CreateStandardTrade(AlipaySetting.PushUrl, bp, this); }
protected void Button1_Click(object sender, EventArgs e) { long orderID = Convert.ToInt64(Request.Cookies["orderID"].Value); OrdersInfo order = Orders.GetOrdersByID(orderID); AliPay ap = new AliPay(); PaymentInfo pay=Payment.GetPaymentByID(2); string key = pay.PrivateKey;//填写自己的key string partner = pay.PartnerID;//填写自己的Partner decimal sendPrice =decimal.Round(order.SendPrice,2); decimal price = decimal.Round(order.NeedPayPrice, 2); StandardGoods bp = new StandardGoods("trade_create_by_buyer", partner, key, "MD5", order.OrderID.ToString(), Guid.NewGuid().ToString(), price - sendPrice, 1, pay.UserName, pay.UserName , "EMS", sendPrice, "BUYER_PAY", "1"); bp.Notify_Url = "http://"; ap.CreateStandardTrade("https://www.alipay.com/cooperate/gateway.do", bp, this); }