Java Code Examples for com.alipay.api.domain.AlipayTradeAppPayModel#setTimeoutExpress()

The following examples show how to use com.alipay.api.domain.AlipayTradeAppPayModel#setTimeoutExpress() . 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: AlipayUtil.java    From anyline with Apache License 2.0 6 votes vote down vote up
/** 
 * app支付 
 *  
 * @param subject 支付标题 
 * @param body  支付明细 
 * @param price  支付价格(元) 
 * @param order  系统订单号 
 * @return String
 */ 
public String createAppOrder(String subject, String body, String price, String order) { 
	String result = ""; 
	AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest(); 
	AlipayTradeAppPayModel model = new AlipayTradeAppPayModel(); 
	model.setBody(body); 
	model.setSubject(subject); 
	model.setOutTradeNo(order); 
	model.setTimeoutExpress("30m"); 
	model.setTotalAmount(price); 
	request.setBizModel(model); 
	request.setNotifyUrl(config.getString("NOTIFY_URL")); 
	try { 
		AlipayTradeAppPayResponse response = client.sdkExecute(request); 
		result = response.getBody(); 
	} catch (AlipayApiException e) { 
		e.printStackTrace(); 
	} 

	return result; 
}
 
Example 2
Source File: AliPayService.java    From java-pay with Apache License 2.0 6 votes vote down vote up
/**
 * 支付宝App支付
 *
 * @param orderId
 * @param servletRequest
 * @return
 */
public String appPay(Long orderId, HttpServletRequest servletRequest) {
    Order order = orderService.findOne(orderId);
    AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
    // SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
    AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
    model.setBody("描述");
    model.setSubject("商品名称");
    model.setOutTradeNo(order.getOutTradeNo());
    model.setTimeoutExpress("30m");
    model.setTotalAmount(order.getTotalFee().toString());
    model.setProductCode("QUICK_MSECURITY_PAY");
    request.setBizModel(model);
    request.setNotifyUrl(appProperties.getAli().getNotify_url());
    try {
        // 这里和普通的接口调用不同,使用的是sdkExecute
        AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
        //就是orderString 可以直接给客户端请求,无需再做处理。
        log.info("orderString:{}", response.getBody());
        return response.getBody();
    } catch (AlipayApiException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 3
Source File: PayUtil.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
/**
 * 支付宝订单创建
 * @param out_trade_no 商户订单号,商户网站订单系统中唯一订单号,必填
 * @param subject      订单名称,必填
 * @param total_amount 付款金额,必填
 * @param body         商品描述,可空
 */
public static String createOrder(String out_trade_no, String subject, String total_amount, String body) throws Exception {
    if (Strings.isEmpty(out_trade_no) || Strings.isEmpty(subject) || Strings.isEmpty(total_amount)) {
        throw new Exception("支付宝参数异常");
    }
    AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.URL, AlipayConfig.APPID, AlipayConfig.RSA_PRIVATE_KEY,
            AlipayConfig.FORMAT, AlipayConfig.CHARSET, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.SIGNTYPE);
    //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
    AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
    //SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
    AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
    model.setBody(body);
    model.setSubject(subject);
    model.setOutTradeNo(out_trade_no);
    model.setTimeoutExpress("30m");
    model.setTotalAmount(total_amount);
    model.setProductCode("QUICK_MSECURITY_PAY");
    request.setBizModel(model);
    request.setNotifyUrl(AlipayConfig.notify_url);
    try {
        //这里和普通的接口调用不同,使用的是sdkExecute
        AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
        System.out.println(response.getBody());
        return response.getBody();
        //就是orderString 可以直接给客户端请求,无需再做处理。
    } catch (AlipayApiException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 4
Source File: SDKExecuteTest.java    From alipay-sdk-java-all with Apache License 2.0 5 votes vote down vote up
private AlipayTradeAppPayRequest getTradeAppPayRequest() {
    AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
    AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
    model.setBody("我是测试数据");
    model.setSubject("App支付测试");
    model.setTotalAmount("0.01");
    model.setProductCode("QUICK_MSECURITY_PAY");
    model.setOutTradeNo("20170216test01");
    model.setTimeoutExpress("30m");
    request.setBizModel(model);
    request.setNotifyUrl("http://www.test.notify");
    return request;
}