下面列出了怎么用com.alipay.api.domain.AlipayTradePagePayModel的API类实例代码及写法,或者点击链接到github查看源代码。
@PostMapping("/gotoPayPage")
public void gotoPayPage(HttpServletResponse response) throws AlipayApiException, IOException {
// 订单模型
String productCode = "FAST_INSTANT_TRADE_PAY";
AlipayTradePagePayModel model = new AlipayTradePagePayModel();
model.setOutTradeNo(UUID.randomUUID().toString());
model.setSubject("支付测试");
model.setTotalAmount("0.01");
model.setBody("支付测试,共0.01元");
model.setProductCode(productCode);
AlipayTradePagePayRequest pagePayRequest =new AlipayTradePagePayRequest();
pagePayRequest.setReturnUrl("http://s9v2cw.natappfree.cc/alipay/page/returnUrl");
pagePayRequest.setNotifyUrl(alipayProperties.getNotifyUrl());
pagePayRequest.setBizModel(model);
// 调用SDK生成表单, 并直接将完整的表单html输出到页面
String form = alipayClient.pageExecute(pagePayRequest).getBody();
response.setContentType("text/html;charset=" + alipayProperties.getCharset());
response.getWriter().write(form);
response.getWriter().flush();
response.getWriter().close();
}
public PagePayChain(AlipayClient alipayClient, AlipayTradePagePayModel alipayTradePagePayModel) {
this.alipayClient = alipayClient;
this.alipayTradePagePayModel = alipayTradePagePayModel;
}