经过好几天的修改,支付终于完成了啊
做支付的流程
做前的必须准备:
string seller_email = ""; //商家签约时的支付宝帐号,即收款的支付宝帐号
string key = ""; //安全校验码,与partner是一组,获取方式是:用签约时支付宝帐号登陆支付宝网站www.alipay.com,在商家服务我的商家里即可查到。
string partner = ""; //商户ID,合作身份者ID,合作伙伴ID
alipay.cs
Alipay_Notify.aspx
Alipay_Return.aspx
建一个文件夹 Notify_DATA
以上alipay.cs,Alipay_Notify.aspx ,Alipay_Return.aspx,支付宝提供代码
确认支付事件:
protected void BtnAlipay_Click(object sender, EventArgs e)
{
//业务参数赋值;
string gateway = "https://www.alipay.com/cooperate/gateway.do?"; //支付接口
string service = "create_partner_trade_by_buyer"; //服务名称,这个是识别是何接口实现何功能的标识,请勿修改
string seller_email = ""; //商家签约时的支付宝帐号,即收款的支付宝帐号
string sign_type = ""; //加密类型,签名方式“不用改”
string key = ""; //安全校验码,与partner是一组,获取方式是:用签约时支付宝帐号登陆支付宝网站www.alipay.com,在商家服务我的商家里即可查到。
string partner = "2088002037527206"; //商户ID,合作身份者ID,合作伙伴ID
string _input_charset = "utf-8"; //编码类型,完全根据客户自身的项目的编码格式而定,千万不要填错。否则极其容易造成MD5加密错误。
string show_url = "http://www.alipay.com/"; //展示地址,即在支付页面时,商品名称旁边的“详情”的链接地址。
string out_trade_no = TxtOrderno.Text.Trim(); //客户自己的订单号,(现取系统时间,可改成网站自己的变量),订单号必须在自身订单系统中保持唯一性
string subject = TxtSubject.Text.Trim(); //商品名称,也可称为订单名称,该接口并不是单一的只能买一样东西,可把一次支付当作一次下订单
string body = TxtBody.Text.Trim(); //商品描述,即备注
string price = TxtPrice.Text.Trim(); //商品价格,也可称为订单的总金额
string quantity = TxtQua.Text.Trim(); //商品数量,当该支付被当作是订单而非单个商品时,数量写为“1”
string logistics_type = "POST"; //物流配送方式:POST(平邮)、EMS(EMS)、EXPRESS(其他快递)
string logistics_fee = TxtPost.Text.Trim(); //物流配送费用
string logistics_payment = "BUYER_PAY"; //物流配送费用付款方式:SELLER_PAY(卖家支付)、BUYER_PAY(买家支付)、BUYER_PAY_AFTER_RECEIVE(货到付款)
string logistics_type_1 = "EXPRESS"; //物流配送方式:POST(平邮)、EMS(EMS)、EXPRESS(其他快递)
string logistics_fee_1 = TxtEpress.Text.Trim(); //物流配送费用
string logistics_payment_1 = "BUYER_PAY"; //物流配送费用付款方式:SELLER_PAY(卖家支付)、BUYER_PAY(买家支付)、BUYER_PAY_AFTER_RECEIVE(货到付款)
string logistics_type_2 = "EMS"; //物流配送方式:POST(平邮)、EMS(EMS)、EXPRESS(其他快递)
string logistics_fee_2 = TxtEMS.Text.Trim(); //物流配送费用
string logistics_payment_2 = "BUYER_PAY"; //物流配送费用付款方式:SELLER_PAY(卖家支付)、BUYER_PAY(买家支付)、BUYER_PAY_AFTER_RECEIVE(货到付款)
//服务器通知url(Alipay_Notify.asp文件所在路经),必须是完整的路径地址
string notify_url = "http://localhost:4715/dbnet05utf8/Alipay_Notify.aspx";
//服务器返回url(return_Alipay_Notify.asp文件所在路经),必须是完整的路径地址
string return_url = "http://localhost:4715/dbnet05utf8/Alipay_Return.aspx";
//支付URL生成
string aliay_url = AliPay.CreatUrl(
gateway,
service,
partner,
sign_type,
out_trade_no,
subject,
body,
price,
show_url,
seller_email,
key,
return_url,
_input_charset,
notify_url,
logistics_type,
logistics_fee,
logistics_payment,
logistics_type_1,
logistics_fee_1,
logistics_payment_1,
logistics_type_2,
logistics_fee_2,
logistics_payment_2,
quantity
);
//以下是GET方式传递参数
// Response.Redirect(aliay_url);
//以下是POST方式传递参数
Response.Write("<form name='alipaysubmit' method='post' action='https://www.alipay.com/cooperate/gateway.do?_input_charset=utf-8'>");
Response.Write("<input type='hidden' name='service' value=" + service + ">");
Response.Write("<input type='hidden' name='partner' value=" + partner + ">");
Response.Write("<input type='hidden' name='sign_type' value=" + sign_type + ">");
Response.Write("<input type='hidden' name='out_trade_no' value=" + out_trade_no + ">");
Response.Write("<input type='hidden' name='subject' value=" + subject + ">");
Response.Write("<input type='hidden' name='body' value=" + body + ">");
Response.Write("<input type='hidden' name='price' value=" + price + ">");
Response.Write("<input type='hidden' name='show_url' value=" + show_url + ">");
Response.Write("<input type='hidden' name='seller_email' value=" + seller_email + ">");
Response.Write("<input type='hidden' name='return_url' value=" + return_url + ">");
Response.Write("<input type='hidden' name='notify_url' value=" + notify_url + ">");
Response.Write("<input type='hidden' name='logistics_type' value=" + logistics_type + ">");
Response.Write("<input type='hidden' name='logistics_fee' value=" + logistics_fee + ">");
Response.Write("<input type='hidden' name='logistics_payment' value=" + logistics_payment + ">");
Response.Write("<input type='hidden' name='logistics_type_1' value=" + logistics_type_1 + ">");
Response.Write("<input type='hidden' name='logistics_fee_1' value=" + logistics_fee_1 + ">");
Response.Write("<input type='hidden' name='logistics_payment_1' value=" + logistics_payment_1 + ">");
Response.Write("<input type='hidden' name='logistics_type_2' value=" + logistics_type_2 + ">");
Response.Write("<input type='hidden' name='logistics_fee_2' value=" + logistics_fee_2 + ">");
Response.Write("<input type='hidden' name='logistics_payment_2' value=" + logistics_payment_2 + ">");
Response.Write("<input type='hidden' name='payment_type' value=1>");
Response.Write("<input type='hidden' name='quantity' value=" + quantity + ">");
Response.Write("<input type='hidden' name='sign' value=" + aliay_url + ">");
Response.Write("</form>");
Response.Write("<script>");
Response.Write("document.alipaysubmit.submit()");
Response.Write("</script>");
}
切记:1,所传入的值,绝对不能有空。2,产品价格只能保留两位小数
以上是我遇到的问题