h5页面 支付宝支付

写的测试流程,比较乱,望勿吐槽

1、提交 支付基础数据

[html]  view plain  copy
  1. <form action="${ctx}/np/h5/restf/np-pay-confirm" method="post" id="payForm" target="_self">  
  2.    <input type="hidden" name="mergeId" id="mergeId" value="${merge_id }">  
  3.    <input type="hidden" name="shop.title" id="shopTitle" value="测试产品">  
  4.    <input type="hidden" name="totalPrice" id="totalPrice" value="${totalPrice }">  
  5.    <input type="hidden" name="totalNum" id="totalNum" value="${totalNum }">  
  6.    <input type="hidden" name="yhId" id="yhId" value="">  
  7. </form>  

2、处理提交的支付数据

[java]  view plain  copy
  1. @RequestMapping("np-pay-confirm")  
  2.     public String payConfirm(@ModelAttribute PersonOrder order,Model model) {  
  3.         请求参数//  
  4.           
  5.         //支付类型  
  6.         String payment_type = "1";  
  7.         //必填,不能修改  
  8.         //服务器异步通知页面路径  
  9.         String notify_url = "http://域名/new/restf/np-alipay-notify";  
  10.         //需http://格式的完整路径,不能加?id=123这类自定义参数  
  11.           
  12.         //页面跳转同步通知页面路径  
  13.         String return_url = "http://域名/h5/person-order-list?yhId="+order.getYhId();  
  14.         //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/  
  15.           
  16.         //商户订单号  
  17.         String out_trade_no = order.getMergeId();  
  18.         //商户网站订单系统中唯一订单号,必填  
  19.           
  20.         //订单名称  
  21.         String subject = order.getShop().getTitle();  
  22.         //必填  
  23.           
  24.         //付款金额  
  25.         String total_fee = order.getTotalPrice()+"";  
  26.         //必填  
  27.           
  28.         //商品展示地址  
  29.         String show_url = "http://域名/np/web/np-shop-get?yhId="+order.getYhId()+"&distance=KM&isShare=0&type=newpage";  
  30.         //必填,需以http://开头的完整路径,例如:http://www.商户网址.com/myorder.html  
  31.           
  32.         /*//订单描述 
  33.         String body = new String(request.getParameter("WIDbody").getBytes("ISO-8859-1"),"UTF-8"); 
  34.         //选填 
  35.          
  36.         //超时时间 
  37.         String it_b_pay = new String(request.getParameter("WIDit_b_pay").getBytes("ISO-8859-1"),"UTF-8"); 
  38.         //选填 
  39.          
  40.         //钱包token 
  41.         String extern_token = new String(request.getParameter("WIDextern_token").getBytes("ISO-8859-1"),"UTF-8"); 
  42.         //选填 
  43. */        
  44.           
  45.         //  
  46.           
  47.         //把请求参数打包成数组  
  48.         Map<String, String> sParaTemp = new HashMap<String, String>();  
  49.         sParaTemp.put("service""alipay.wap.create.direct.pay.by.user");  
  50.         sParaTemp.put("partner""***");  
  51.         sParaTemp.put("seller_id""***");  
  52.         sParaTemp.put("_input_charset", AlipayConfig.input_charset);  
  53.         sParaTemp.put("payment_type", payment_type);  
  54.         sParaTemp.put("notify_url", notify_url);  
  55.         sParaTemp.put("return_url", return_url);  
  56.         sParaTemp.put("out_trade_no", out_trade_no);  
  57.         sParaTemp.put("subject", subject);  
  58.         sParaTemp.put("total_fee", total_fee);  
  59.         sParaTemp.put("show_url", show_url);  
  60.           
  61.         //建立请求  
  62.         String sHtmlText = AlipaySubmit.buildRequest(sParaTemp,"POST","确认");  
  63.         model.addAttribute("sHtmlText", sHtmlText);  
  64.         return "h5/person/alireturn";  
  65.     }  

3、调用支付组件

alireturn.jsp

[html]  view plain  copy
  1. <html class="no-js">  
  2. <head>  
  3.     <meta charset="utf-8">  
  4.     <meta http-equiv="X-UA-Compatible" content="IE=edge">  
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">  
  6.     <meta name="apple-mobile-web-app-capable" content="yes">  
  7.     <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />  
  8.     <title>登录</title>  
  9.     <meta name="description" content="">  
  10.     <meta name="keywords" content="">  
  11. </head>  
  12. <body>  
  13.     ${sHtmlText}  
  14. </body>  
  15. </html>  
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值