调用支付宝支付(C#)
2021-06-21 16:04
标签:pid soft api mount subject 蚂蚁金服 应用 vat 文档 //支付宝支付 // 支付宝网关 //开发者应用私钥,由支付宝密钥生成工具生成 商户应用私钥 蚂蚁金服后台商户应用公钥与支付宝密钥生成工具商户应用公钥匹配一致 //参数返回格式,只支持json //请求和签名使用的字符编码格式,支持GBK和UTF-8 //支付宝公钥,由支付宝生成到蚂蚁金服复制 DefaultAopClient client = new DefaultAopClient(Url, APPID, APP_PRIVATE_KEY, FORMAT, "1.0", "RSA2", zhifubao_public_key, CHARSET, false); // 订单名称 // 付款金额 // 商品描述 // 支付中途退出返回商户网站地址 #region -----API日志---- // 组装业务参数model AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest(); AlipayTradeWapPayResponse response = null; return response.Body; 具体请看支付宝开发文档:https://openhome.alipay.com/developmentDocument.htm 调用支付宝支付(C#) 标签:pid soft api mount subject 蚂蚁金服 应用 vat 文档 原文地址:https://www.cnblogs.com/Lance88/p/10234875.html
public string AliPay(string OrderID, string Total) //OrderID订单号,Total订单总金额
{
string Url = "https://openapi.alipay.com/gateway.do";
string APPID = "2016080180820878";
string APP_PRIVATE_KEY = "开发者应用私钥";
string FORMAT = "json";
string CHARSET = "UTF-8";
string zhifubao_public_key = "支付宝公钥";
// 外部订单号,商户网站订单系统中唯一的订单号
string out_trade_no = OrderID.Trim();
string subject = "订单" + OrderID + "支付";
string total_amout = Total.Trim().ToString();
string body = "订单" + OrderID + "支付";
string quit_url = "url";
Maticsoft.BLL.Shop_Apilog Bll_Api = new Maticsoft.BLL.Shop_Apilog();
Maticsoft.Model.Shop_Apilog Api = new Maticsoft.Model.Shop_Apilog();
Api.ApiName = "https://openapi.alipay.com/gateway.do";
Api.ReTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff");
Api.Method = "支付宝支付"+OrderID;
#endregion
AlipayTradeWapPayModel model = new AlipayTradeWapPayModel();
model.Body = body;
model.Subject = subject;
model.TotalAmount = total_amout;
model.OutTradeNo = out_trade_no;
model.ProductCode = "QUICK_WAP_WAY";
model.QuitUrl = quit_url;
// 设置支付完成同步回调地址
request.SetReturnUrl("回调地址");
// 设置支付完成异步通知接收地址
request.SetNotifyUrl("异步通知接收地址");
// 将业务model载入到request
request.SetBizModel(model);
try
{
response = client.pageExecute(request, null, "post");
Api.ApiInfo = response.Body;
Bll_Api.Add(Api);
}
catch (Exception exp)
{
throw exp;
}
}