com.alipay.api.response.AlipayTradePayResponse Java Examples

The following examples show how to use com.alipay.api.response.AlipayTradePayResponse. 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: AlipayF2FPayResult.java    From MeetingFilm with Apache License 2.0 4 votes vote down vote up
public AlipayF2FPayResult(AlipayTradePayResponse response) {
    this.response = response;
}
 
Example #2
Source File: AlipayF2FPayResult.java    From MeetingFilm with Apache License 2.0 4 votes vote down vote up
public void setResponse(AlipayTradePayResponse response) {
    this.response = response;
}
 
Example #3
Source File: AlipayF2FPayResult.java    From MeetingFilm with Apache License 2.0 4 votes vote down vote up
public AlipayTradePayResponse getResponse() {
    return response;
}
 
Example #4
Source File: AlipayTradeWithHBServiceImpl.java    From MeetingFilm with Apache License 2.0 4 votes vote down vote up
private AlipayTradePayResponse getResponse(AlipayClient client, AlipayTradePayRequest request,
                                             final String outTradeNo, final long beforeCall) {
    try {
        AlipayTradePayResponse response = client.execute(request);
        if (response != null) {
            log.info(response.getBody());
        }
        return response;

    } catch (AlipayApiException e) {
        // 获取异常真实原因
        Throwable cause = e.getCause();

        if (cause instanceof ConnectException ||
                cause instanceof NoRouteToHostException) {
            // 建立连接异常
            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    listener.onConnectException(outTradeNo, beforeCall);
                }
            });

        } else if (cause instanceof SocketException) {
            // 报文上送异常
            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    listener.onSendException(outTradeNo, beforeCall);
                }
            });

        } else if (cause instanceof SocketTimeoutException) {
            // 报文接收异常
            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    listener.onReceiveException(outTradeNo, beforeCall);
                }
            });
        }

        e.printStackTrace();
        return null;
    }
}
 
Example #5
Source File: AlipayTradePayRequest.java    From alipay-sdk-java-all with Apache License 2.0 4 votes vote down vote up
public Class<AlipayTradePayResponse> getResponseClass() {
	return AlipayTradePayResponse.class;
}
 
Example #6
Source File: AlipayTradePayRequest.java    From alipay-sdk with Apache License 2.0 4 votes vote down vote up
public Class<AlipayTradePayResponse> getResponseClass() {
	return AlipayTradePayResponse.class;
}
 
Example #7
Source File: AlipayTradePayRequest.java    From pay with Apache License 2.0 4 votes vote down vote up
public Class<AlipayTradePayResponse> getResponseClass() {
	return AlipayTradePayResponse.class;
}
 
Example #8
Source File: AliPayUtil.java    From roncoo-pay with Apache License 2.0 4 votes vote down vote up
/**
 * 支付宝被扫(扫码设备)
 *
 * @param outTradeNo
 * @param authCode
 * @param subject
 * @param amount
 * @param body
 * @param roncooPayGoodsDetailses
 * @return
 */
public static Map<String, Object> tradePay(String outTradeNo, String authCode, String subject, BigDecimal amount, String body, List<RoncooPayGoodsDetails> roncooPayGoodsDetailses) {
    logger.info("======>支付宝被扫");
    String charset = "UTF-8";
    String format = "json";
    String signType = "RSA2";
    String scene = "bar_code";//支付场景--条码支付
    String totalAmount = amount.toString();//订单金额
    String discountableAmount = "0.0";//默认折扣金额为0,建议由业务系统记录折扣金额,值传递给支付宝实际支付金额
    String storeId = "ykt_pay_store_id"; // (必填) 商户门店编号,通过门店号和商家后台可以配置精准到门店的折扣信息,详询支付宝技术支持
    String timeExpress = "5m";// 支付超时,线下扫码交易定义为5分钟

    AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfigUtil.trade_pay_url, AlipayConfigUtil.app_id, AlipayConfigUtil.mch_private_key, format, charset, AlipayConfigUtil.ali_public_key, signType);

    SortedMap<String, Object> paramMap = new TreeMap<>();
    paramMap.put("out_trade_no", outTradeNo);
    paramMap.put("scene", scene);
    paramMap.put("auth_code", authCode);
    paramMap.put("subject", subject);
    paramMap.put("total_amount", totalAmount);
    paramMap.put("discountable_amount", discountableAmount);
    paramMap.put("body", body);
    paramMap.put("store_id", storeId);
    paramMap.put("timeout_express", timeExpress);

    // 商品明细列表,需填写购买商品详细信息,
    if (roncooPayGoodsDetailses != null && roncooPayGoodsDetailses.size() > 0) {
        List<SortedMap<String, Object>> goodsList = new ArrayList<>();
        for (RoncooPayGoodsDetails roncooPayGoodsDetails : roncooPayGoodsDetailses) {
            SortedMap<String, Object> goodsMap = new TreeMap<>();
            goodsMap.put("goods_id", roncooPayGoodsDetails.getGoodsId());
            goodsMap.put("goods_name", roncooPayGoodsDetails.getGoodsName());
            goodsMap.put("quantity", roncooPayGoodsDetails.getNums());
            goodsMap.put("price", roncooPayGoodsDetails.getSinglePrice());
            goodsList.add(goodsMap);
        }
        paramMap.put("goods_detail", goodsList);
    }

    SortedMap<String, Object> extendParamsMap = new TreeMap<>();
    extendParamsMap.put("sys_service_provider_id", AlipayConfigUtil.partner);
    paramMap.put("extend_params", extendParamsMap);

    AlipayTradePayRequest request = new AlipayTradePayRequest();
    System.out.println(JSONObject.toJSONString(paramMap));
    request.setBizContent(JSONObject.toJSONString(paramMap));
    try {
        AlipayTradePayResponse response = alipayClient.execute(request);
        JSONObject responseJSON = JSONObject.parseObject(JSONObject.toJSONString(response));
        logger.info("支付宝返回结果:{}", responseJSON);
        return responseJSON;
    } catch (AlipayApiException e) {
        logger.error("支付宝扫码,支付异常:{}", e);
        JSONObject resultJSON = new JSONObject();
        resultJSON.put("outTradeNo", outTradeNo);
        resultJSON.put("totalAmount", amount);
        resultJSON.put("errorCode", "9999");
        return resultJSON;
    }
}