Java Code Examples for com.alipay.api.request.AlipayTradeWapPayRequest#setReturnUrl()

The following examples show how to use com.alipay.api.request.AlipayTradeWapPayRequest#setReturnUrl() . 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: AlipayWAPPayController.java    From springboot-pay-example with Apache License 2.0 6 votes vote down vote up
/**
 * 去支付
 *
 * 支付宝返回一个form表单,并自动提交,跳转到支付宝页面
 *
 * @param response
 * @throws Exception
 */
@PostMapping("/gotoPayPage")
public void gotoPayPage(HttpServletResponse response) throws AlipayApiException, IOException {
    // 订单模型
    String productCode="QUICK_WAP_WAY";
    AlipayTradeWapPayModel model = new AlipayTradeWapPayModel();
    model.setOutTradeNo(UUID.randomUUID().toString());
    model.setSubject("支付测试");
    model.setTotalAmount("0.01");
    model.setBody("支付测试,共0.01元");
    model.setTimeoutExpress("5m");
    model.setProductCode(productCode);

    AlipayTradeWapPayRequest wapPayRequest =new AlipayTradeWapPayRequest();
    wapPayRequest.setReturnUrl("http://yxep7y.natappfree.cc/alipay/wap/returnUrl");
    wapPayRequest.setNotifyUrl(alipayProperties.getNotifyUrl());
    wapPayRequest.setBizModel(model);

    // 调用SDK生成表单, 并直接将完整的表单html输出到页面
    String form = alipayClient.pageExecute(wapPayRequest).getBody();
    System.out.println(form);
    response.setContentType("text/html;charset=" + alipayProperties.getCharset());
    response.getWriter().write(form);
    response.getWriter().flush();
    response.getWriter().close();
}
 
Example 2
Source File: AlipayUtil.java    From anyline with Apache License 2.0 5 votes vote down vote up
public String createWapOrder(AlipayTradeOrder order){ 
	String result = ""; 
	AlipayTradeWapPayRequest alipayRequest = new AlipayTradeWapPayRequest();//创建API对应的request 
    alipayRequest.setReturnUrl(config.RETURN_URL); 
    alipayRequest.setNotifyUrl(config.NOTIFY_URL); 
    alipayRequest.setBizContent(BeanUtil.object2json(order));//填充业务参数 
    try { 
        result = client.pageExecute(alipayRequest).getBody(); //调用SDK生成表单 
    } catch (AlipayApiException e) { 
        e.printStackTrace(); 
    } 
	return result; 
}
 
Example 3
Source File: AlipayConfigServiceImpl.java    From yshopmall with Apache License 2.0 5 votes vote down vote up
@Override
public String toPayAsWeb(AlipayConfig alipay, TradeVo trade) throws Exception {
    if(alipay.getId() == null){
        throw new BadRequestException("请先添加相应配置,再操作");
    }
    AlipayClient alipayClient = new DefaultAlipayClient(alipay.getGatewayUrl(), alipay.getAppId(), alipay.getPrivateKey(), alipay.getFormat(), alipay.getCharset(), alipay.getPublicKey(), alipay.getSignType());

    double money = Double.parseDouble(trade.getTotalAmount());
    double maxMoney = 5000;
    if(money <= 0 || money >= maxMoney){
        throw new BadRequestException("测试金额过大");
    }
    // 创建API对应的request(手机网页版)
    AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest();
    request.setReturnUrl(alipay.getReturnUrl());
    request.setNotifyUrl(alipay.getNotifyUrl());
    request.setBizContent("{" +
            "    \"out_trade_no\":\""+trade.getOutTradeNo()+"\"," +
            "    \"product_code\":\"FAST_INSTANT_TRADE_PAY\"," +
            "    \"total_amount\":"+trade.getTotalAmount()+"," +
            "    \"subject\":\""+trade.getSubject()+"\"," +
            "    \"body\":\""+trade.getBody()+"\"," +
            "    \"extend_params\":{" +
            "    \"sys_service_provider_id\":\""+alipay.getSysServiceProviderId()+"\"" +
            "    }"+
            "  }");
    return alipayClient.pageExecute(request, "GET").getBody();
}
 
Example 4
Source File: AlipayWapServiceImpl.java    From fast-family-master with Apache License 2.0 5 votes vote down vote up
@Override
public AlipayTradeWapPayResponse payWap(AlipayTradeWapPayModel model) throws AlipayApiException {
    AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest();
    request.setBizModel(model);
    request.setNotifyUrl(aliPayProperties.getNotifyUrl());
    request.setReturnUrl(aliPayProperties.getReturnUrl());
    return alipayClient.pageExecute(request);
}
 
Example 5
Source File: AliPayServiceImpl.java    From eladmin with Apache License 2.0 5 votes vote down vote up
@Override
public String toPayAsWeb(AlipayConfig alipay, TradeVo trade) throws Exception {
    if(alipay.getId() == null){
        throw new BadRequestException("请先添加相应配置,再操作");
    }
    AlipayClient alipayClient = new DefaultAlipayClient(alipay.getGatewayUrl(), alipay.getAppId(), alipay.getPrivateKey(), alipay.getFormat(), alipay.getCharset(), alipay.getPublicKey(), alipay.getSignType());

    double money = Double.parseDouble(trade.getTotalAmount());
    double maxMoney = 5000;
    if(money <= 0 || money >= maxMoney){
        throw new BadRequestException("测试金额过大");
    }
    // 创建API对应的request(手机网页版)
    AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest();
    request.setReturnUrl(alipay.getReturnUrl());
    request.setNotifyUrl(alipay.getNotifyUrl());
    request.setBizContent("{" +
            "    \"out_trade_no\":\""+trade.getOutTradeNo()+"\"," +
            "    \"product_code\":\"FAST_INSTANT_TRADE_PAY\"," +
            "    \"total_amount\":"+trade.getTotalAmount()+"," +
            "    \"subject\":\""+trade.getSubject()+"\"," +
            "    \"body\":\""+trade.getBody()+"\"," +
            "    \"extend_params\":{" +
            "    \"sys_service_provider_id\":\""+alipay.getSysServiceProviderId()+"\"" +
            "    }"+
            "  }");
    return alipayClient.pageExecute(request, "GET").getBody();
}
 
Example 6
Source File: AliPayServiceImpl.java    From albedo with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String toPayAsWeb(AlipayConfig alipay, TradeVo trade) throws Exception {
	if (alipay.getId() == null) {
		throw new BadRequestException("请先添加相应配置,再操作");
	}
	AlipayClient alipayClient = new DefaultAlipayClient(alipay.getGatewayUrl(), alipay.getAppId(), alipay.getPrivateKey(), alipay.getFormat(), alipay.getCharset(), alipay.getPublicKey(), alipay.getSignType());

	double money = Double.parseDouble(trade.getTotalAmount());
	double maxMoney = 5000;
	if (money <= 0 || money >= maxMoney) {
		throw new BadRequestException("测试金额过大");
	}
	// 创建API对应的request(手机网页版)
	AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest();
	request.setReturnUrl(alipay.getReturnUrl());
	request.setNotifyUrl(alipay.getNotifyUrl());
	request.setBizContent("{" +
		"    \"out_trade_no\":\"" + trade.getOutTradeNo() + "\"," +
		"    \"product_code\":\"FAST_INSTANT_TRADE_PAY\"," +
		"    \"total_amount\":" + trade.getTotalAmount() + "," +
		"    \"subject\":\"" + trade.getSubject() + "\"," +
		"    \"body\":\"" + trade.getBody() + "\"," +
		"    \"extend_params\":{" +
		"    \"sys_service_provider_id\":\"" + alipay.getSysServiceProviderId() + "\"" +
		"    }" +
		"  }");
	return alipayClient.pageExecute(request, "GET").getBody();
}
 
Example 7
Source File: WapPayChain.java    From alipay with Apache License 2.0 3 votes vote down vote up
/**
 * Generate Forms
 * <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 String
 * @throws AlipayApiException AlipayApiException
 */
public String pay(String returnUrl, String notifyUrl) throws AlipayApiException {
    AlipayTradeWapPayRequest payRequest = new AlipayTradeWapPayRequest ();
    payRequest.setReturnUrl (returnUrl);
    payRequest.setNotifyUrl (notifyUrl);
    payRequest.setBizModel (alipayTradeWapPayModel);
    return alipayClient.pageExecute (payRequest).getBody ();
}