Java Code Examples for com.alipay.api.request.AlipayTradePagePayRequest#setBizModel()

The following examples show how to use com.alipay.api.request.AlipayTradePagePayRequest#setBizModel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AlipayPagePayController.java    From springboot-pay-example with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example 2
Source File: PagePayChain.java    From alipay with Apache License 2.0 3 votes vote down vote up
/**
 * Generate Payment Page
 * <p>
 * 生成支付页面
 *
 * @param returnUrl After the transaction is completed, the page will take the initiative to jump to the HTTP / HTTPS path specified in the merchant server
 *                  交易完成后页面主动跳转,商户服务器里指定的页面http/https路径
 * @param notifyUrl AliPay Server Initiatively Tells The Http/Https Path Specified In The Merchant Server.
 *                  支付宝服务器主动通知商户服务器里指定的页面http/https路径
 * @return pay
 * @throws AlipayApiException AlipayApiException
 */
public String pay(String returnUrl, String notifyUrl) throws AlipayApiException {
    AlipayTradePagePayRequest pagePayRequest = new AlipayTradePagePayRequest ();
    pagePayRequest.setReturnUrl (returnUrl);
    pagePayRequest.setNotifyUrl (notifyUrl);
    pagePayRequest.setBizModel (alipayTradePagePayModel);
    return alipayClient.pageExecute (pagePayRequest).getBody ();
}
 
Example 3
Source File: PagePayChain.java    From alipay with Apache License 2.0 2 votes vote down vote up
/**
 * Custom Build PayRequest
 * <p>
 * 自定义构建PayRequest
 *
 * @param pagePayRequest pagePayRequest
 * @return String
 * @throws AlipayApiException AlipayApiException
 */
public String pay(AlipayTradePagePayRequest pagePayRequest) throws AlipayApiException {
    pagePayRequest.setBizModel (alipayTradePagePayModel);
    return alipayClient.pageExecute (pagePayRequest).getBody ();
}