网页端调用支付宝

  

调用微信和支付宝第三方接口方法总结

https://blog.csdn.net/yufeng005/article/details/54583467

  1. //微信支付   
  2.             function wxPay(outTradeNo){  
  3.                 var orderType="0"; //路线 订单   
  4.                  $.ajax({  
  5.                         url :'<%=basePath%>client/travel/getWXClientPayInfo.do?outTradeNo='+outTradeNo+'&orderType='+orderType,  
  6.                         cache : false,  
  7.                         type : "get",  
  8.                         success : function(data)  
  9.                         {  
  10.                               
  11.                             if(data!=null){  
  12.                                 data = jQuery.parseJSON(data);  
  13.                                   
  14.                                 var u = navigator.userAgent;  
  15.                                 var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端  
  16.                                 var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端  
  17.                                 if(isAndroid){  
  18.                                     ClientInterface.pay(outTradeNo,data.prepayid,data.noncestr,data.timestamp,data.sign,orderType);  
  19.                                 }else if(isiOS){  
  20.                                     window.location.href='http://localhost/pay/'+outTradeNo+';'+data.prepayid+";"+data.noncestr+";"+data.timestamp+";"+data.sign+";"+orderType;  
  21.                                 }     
  22.                                   
  23.                              }   
  24.                         }  
  25.                     });  
  26.             }  

 

 

  1. //支付宝支付   
  2.             function aliPay(outTradeNo){  
  3.                 var orderType="0";  
  4.                 var info = $("#aliPayInfo").val();//订单信息   
  5.                 var totalAmount = $("#moeny").val();//总金额  
  6.                 var orderName = $("#orderName").val();//订单名称  
  7.                   
  8.                 //type 0:线路 1:景点  2:酒店 3:商城 4:VIP  
  9.                 var prams = {  
  10.                         aliPayInfo : info,  
  11.                         type : orderType,  
  12.                         orderNumber : outTradeNo,  
  13.                         money : totalAmount,  
  14.                         orderName : orderName  
  15.                 };  
  16.                 //先调支付宝确定是否下单 否则返回支付宝会话信息  
  17.                 $.ajax({  
  18.                     url : '<%=basePath%>client/hotel/foundZFBOrder.do',  
  19.                     type : "post",  
  20.                     data : prams,  
  21.                     cache : false,  
  22.                     dataType : "json",  
  23.                     success : function(data)  
  24.                     {  
  25.                         //alert("info +===="+data.info);  
  26.                         if(data.isSuccess){  
  27.                             if(isAndroid){  
  28.                                 ClientInterface.aliPay(data.info,outTradeNo,orderType,totalAmount);  
  29.                             }else if(isiOS){  
  30.                                 window.location.href='http://localhost/aliPay/'+data.info+';'+outTradeNo+";"+orderType+";"+totalAmount;  
  31.                             }  
  32.                         }else{  
  33.                             var title = "支付宝下单失败";  
  34.                             prompt(title);  
  35.                         }  
  36.                     },   
  37.                     error : function(data){  
  38.                         var title = "支付宝下单失败";  
  39.                         prompt(title);  
  40.                     }  
  41.                 });  
  42.             }  

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

posted @ 2018-04-20 09:40  豆豆飞  阅读(1355)  评论(0编辑  收藏  举报