网页端调用支付宝
调用微信和支付宝第三方接口方法总结
https://blog.csdn.net/yufeng005/article/details/54583467
- //微信支付
- function wxPay(outTradeNo){
- var orderType="0"; //路线 订单
- $.ajax({
- url :'<%=basePath%>client/travel/getWXClientPayInfo.do?outTradeNo='+outTradeNo+'&orderType='+orderType,
- cache : false,
- type : "get",
- success : function(data)
- {
- if(data!=null){
- data = jQuery.parseJSON(data);
- var u = navigator.userAgent;
- var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
- var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
- if(isAndroid){
- ClientInterface.pay(outTradeNo,data.prepayid,data.noncestr,data.timestamp,data.sign,orderType);
- }else if(isiOS){
- window.location.href='http://localhost/pay/'+outTradeNo+';'+data.prepayid+";"+data.noncestr+";"+data.timestamp+";"+data.sign+";"+orderType;
- }
- }
- }
- });
- }
- //支付宝支付
- function aliPay(outTradeNo){
- var orderType="0";
- var info = $("#aliPayInfo").val();//订单信息
- var totalAmount = $("#moeny").val();//总金额
- var orderName = $("#orderName").val();//订单名称
- //type 0:线路 1:景点 2:酒店 3:商城 4:VIP
- var prams = {
- aliPayInfo : info,
- type : orderType,
- orderNumber : outTradeNo,
- money : totalAmount,
- orderName : orderName
- };
- //先调支付宝确定是否下单 否则返回支付宝会话信息
- $.ajax({
- url : '<%=basePath%>client/hotel/foundZFBOrder.do',
- type : "post",
- data : prams,
- cache : false,
- dataType : "json",
- success : function(data)
- {
- //alert("info +===="+data.info);
- if(data.isSuccess){
- if(isAndroid){
- ClientInterface.aliPay(data.info,outTradeNo,orderType,totalAmount);
- }else if(isiOS){
- window.location.href='http://localhost/aliPay/'+data.info+';'+outTradeNo+";"+orderType+";"+totalAmount;
- }
- }else{
- var title = "支付宝下单失败";
- prompt(title);
- }
- },
- error : function(data){
- var title = "支付宝下单失败";
- prompt(title);
- }
- });
- }
https://blog.csdn.net/weixin_41003211/article/details/78541735
var prodConfig = {
"body": "body",
"subject": "daledou",
"out_trade_no": "70501111111S001111110",
"timeout_express": "90m",
"total_amount": 9.00,
"product_code": "QUICK_WAP_WAY"
}
var alipayConfig = {
biz_content: JSON.stringify(prodConfig),
app_id: '自己的appid',
version: '1.0',
format: 'json',
sign_type: 'RSA2',
method: 'alipay.trade.wap.pay',
notify_url: 'http://***/alipy/notify_url.php',
return_url: 'http://***/alipy/return_url.php',
charset: 'UTF-8',
sign: 'L3quItR9hqIfsgjZVqDO/L8k5dmdSSn7KCQcHMRsZl0yzFa9im5Ge/ZXZh1sIo+fqr5zJkUUYmZknERw+iPiiNt/w0VLKPzjgzL4afoQ4oS5vnD8SzdccA9C1E5GxjvJCXGseeciQpyNkMmvXwTcL7egS4ukn2dAV0lpcM8KNPJdi+1HlWgAlnFT0Xq6Kqs24GD+Fd4ogpXoWOa3HfSjY1+DY+7FwKyunTvR9isN/kRIckW887GE2Dy2jRSghhANrf47f54SDMu+UcuRsNfxsgwfSTiafTW1q8Eym/2G7PBOWnI0I5llD7bs9Qu3zB/b+IpLlkEa0jUNj1rXgvkjww==',
timestamp: '2017-11-15 14:55:46'
}
function to() {
httpPost('https://openapi.alipaydev.com/gateway.do', alipayConfig)
}
function httpPost(URL, PARAMS) {
var temp = document.createElement("form");
temp.action = URL;
temp.method = "post";
temp.style.display = "none";
or (var x in PARAMS) {
var opt = document.createElement("textarea");
opt.name = x;
opt.value = PARAMS[x];
temp.appendChild(opt);
}
document.body.appendChild(temp);
temp.submit();
return temp;
}
https://blog.csdn.net/achenyuan/article/details/77196838
https://blog.csdn.net/u012062810/article/details/77244996