写的测试流程,比较乱,望勿吐槽
1、提交 支付基础数据
- <form action="${ctx}/np/h5/restf/np-pay-confirm" method="post" id="payForm" target="_self">
- <input type="hidden" name="mergeId" id="mergeId" value="${merge_id }">
- <input type="hidden" name="shop.title" id="shopTitle" value="测试产品">
- <input type="hidden" name="totalPrice" id="totalPrice" value="${totalPrice }">
- <input type="hidden" name="totalNum" id="totalNum" value="${totalNum }">
- <input type="hidden" name="yhId" id="yhId" value="">
- </form>
2、处理提交的支付数据
- @RequestMapping("np-pay-confirm")
- public String payConfirm(@ModelAttribute PersonOrder order,Model model) {
- 请求参数//
- //支付类型
- String payment_type = "1";
- //必填,不能修改
- //服务器异步通知页面路径
- String notify_url = "http://域名/new/restf/np-alipay-notify";
- //需http://格式的完整路径,不能加?id=123这类自定义参数
- //页面跳转同步通知页面路径
- String return_url = "http://域名/h5/person-order-list?yhId="+order.getYhId();
- //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/
- //商户订单号
- String out_trade_no = order.getMergeId();
- //商户网站订单系统中唯一订单号,必填
- //订单名称
- String subject = order.getShop().getTitle();
- //必填
- //付款金额
- String total_fee = order.getTotalPrice()+"";
- //必填
- //商品展示地址
- String show_url = "http://域名/np/web/np-shop-get?yhId="+order.getYhId()+"&distance=KM&isShare=0&type=newpage";
- //必填,需以http://开头的完整路径,例如:http://www.商户网址.com/myorder.html
- /*//订单描述
- String body = new String(request.getParameter("WIDbody").getBytes("ISO-8859-1"),"UTF-8");
- //选填
- //超时时间
- String it_b_pay = new String(request.getParameter("WIDit_b_pay").getBytes("ISO-8859-1"),"UTF-8");
- //选填
- //钱包token
- String extern_token = new String(request.getParameter("WIDextern_token").getBytes("ISO-8859-1"),"UTF-8");
- //选填
- */
- //
- //把请求参数打包成数组
- Map<String, String> sParaTemp = new HashMap<String, String>();
- sParaTemp.put("service", "alipay.wap.create.direct.pay.by.user");
- sParaTemp.put("partner", "***");
- sParaTemp.put("seller_id", "***");
- sParaTemp.put("_input_charset", AlipayConfig.input_charset);
- sParaTemp.put("payment_type", payment_type);
- sParaTemp.put("notify_url", notify_url);
- sParaTemp.put("return_url", return_url);
- sParaTemp.put("out_trade_no", out_trade_no);
- sParaTemp.put("subject", subject);
- sParaTemp.put("total_fee", total_fee);
- sParaTemp.put("show_url", show_url);
- //建立请求
- String sHtmlText = AlipaySubmit.buildRequest(sParaTemp,"POST","确认");
- model.addAttribute("sHtmlText", sHtmlText);
- return "h5/person/alireturn";
- }
3、调用支付组件
alireturn.jsp
- <html class="no-js">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
- <title>登录</title>
- <meta name="description" content="">
- <meta name="keywords" content="">
- </head>
- <body>
- ${sHtmlText}
- </body>
- </html>