com.alipay.api.request.AlipayTradeQueryRequest Java Examples
The following examples show how to use
com.alipay.api.request.AlipayTradeQueryRequest.
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 |
/** * 交易状态查询 * @param query 查询参数 * @return return */ public AlipayTradeQueryResult tradeQuery(AlipayTradeQuery query){ AlipayTradeQueryResult result = null; AlipayTradeQueryRequest request = new AlipayTradeQueryRequest(); String json = BeanUtil.object2json(query); request.setBizContent(json); try { AlipayTradeQueryResponse res = client.execute(request); result = new AlipayTradeQueryResult(res); } catch (AlipayApiException e) { result = new AlipayTradeQueryResult(); e.printStackTrace(); }finally{ log.warn("[单笔转账到支付宝账户][data:{}][result:{}]", json,BeanUtil.object2json(result)); } return result; }
Example #2
Source File: PayUtil.java From NutzSite with Apache License 2.0 | 6 votes |
/** * 查询 * * @param out_trade_no 商户订单号,商户网站订单系统中唯一订单号,必填 * @param trade_no 支付宝交易号 */ public static void TradeQuery(String out_trade_no, String trade_no) { /**********************/ // SDK 公共请求类,包含公共请求参数,以及封装了签名与验签,开发者无需关注签名与验签 AlipayClient client = new DefaultAlipayClient(AlipayConfig.URL, AlipayConfig.APPID, AlipayConfig.RSA_PRIVATE_KEY, AlipayConfig.FORMAT, AlipayConfig.CHARSET, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.SIGNTYPE); AlipayTradeQueryRequest alipay_request = new AlipayTradeQueryRequest(); AlipayTradeQueryModel model = new AlipayTradeQueryModel(); model.setOutTradeNo(out_trade_no); model.setTradeNo(trade_no); alipay_request.setBizModel(model); AlipayTradeQueryResponse alipay_response = null; try { alipay_response = client.execute(alipay_request); } catch (AlipayApiException e) { e.printStackTrace(); } System.out.println(alipay_response.getBody()); }
Example #3
Source File: AliPayUtil.java From roncoo-pay with Apache License 2.0 | 6 votes |
/** * 订单查询 * * @return */ public static Map<String, Object> tradeQuery(String outTradeNo) { logger.info("======>支付宝交易查询"); String charset = "UTF-8"; String format = "json"; String signType = "RSA2"; AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfigUtil.trade_query_url, AlipayConfigUtil.app_id, AlipayConfigUtil.mch_private_key, format, charset, AlipayConfigUtil.ali_public_key, signType); SortedMap<String, Object> bizContentMap = new TreeMap<>(); bizContentMap.put("out_trade_no", outTradeNo); AlipayTradeQueryRequest request = new AlipayTradeQueryRequest(); request.setBizContent(JSONObject.toJSONString(bizContentMap)); try { AlipayTradeQueryResponse response = alipayClient.execute(request); JSONObject responseJSON = JSONObject.parseObject(JSONObject.toJSONString(response)); logger.info("支付宝订单查询返回结果:{}", responseJSON); return responseJSON; } catch (AlipayApiException e) { logger.error("支付宝交易查询异常:{}", e); return null; } }
Example #4
Source File: AbsAlipayTradeService.java From MeetingFilm with Apache License 2.0 | 5 votes |
protected AlipayTradeQueryResponse tradeQuery(AlipayTradeQueryRequestBuilder builder) { validateBuilder(builder); AlipayTradeQueryRequest request = new AlipayTradeQueryRequest(); request.putOtherTextParam("app_auth_token", builder.getAppAuthToken()); request.setBizContent(builder.toJsonString()); log.info("trade.query bizContent:" + request.getBizContent()); return (AlipayTradeQueryResponse) getResponse(client, request); }
Example #5
Source File: OrderInfoServiceImpl.java From blog-sample with Apache License 2.0 | 5 votes |
@Override public boolean syncStatus(String orderId, String alipayNo) { OrderInfo orderInfo = getByIdOrAlipayNo(orderId, alipayNo); if(orderInfo == null) { return false; } // 1、设置请求参数 AlipayTradeQueryRequest alipayRequest = new AlipayTradeQueryRequest(); Map<String, String> map = new HashMap<>(16); map.put("out_trade_no", orderId); map.put("trade_no", alipayNo); alipayRequest.setBizContent(JsonUtils.objectToJson(map)); try { // 2、请求 String json = alipayClient.execute(alipayRequest).getBody(); Map<String, Object> resMap = JsonUtils.jsonToPojo(json, Map.class); Map<String, String> responseMap = (Map)resMap.get("alipay_trade_query_response"); // 获得返回状态码,具体参考:https://docs.open.alipay.com/common/105806 String code = responseMap.get("code"); if("10000".equals(code)) { // 当查询的订单状态不等于数据库订单状态时,更新状态 String tradeStatus = responseMap.get("trade_status"); if(!orderInfo.getStatus().equals(tradeStatus)) { orderInfo.setStatus(tradeStatus); orderInfoMapper.updateById(orderInfo); return true; } } else { log.error("【状态同步Service】错误码:{},错误信息:{}",code ,responseMap.get("sub_msg")); } } catch (Exception e) { log.error("【状态同步Service】异常,错误信息:{}", e.getMessage()); e.printStackTrace(); } return false; }
Example #6
Source File: AliPayServiceImpl.java From common-project with Apache License 2.0 | 5 votes |
@Override public OrderQueryResponse orderQuery(String orderNum) throws AlipayApiException { //TODO 根据实际业务参数填写 Integer orderFrom=0; AliPayConfig aliPayConfig= (AliPayConfig) getPayConfig(orderFrom); AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",aliPayConfig.getAppId(),aliPayConfig.getAppPrivateKey(),"json",aliPayConfig.getCharset(),aliPayConfig.getAliPayPublicKey(),"RSA2"); AlipayTradeQueryRequest request = new AlipayTradeQueryRequest(); request.setBizContent("{\"out_trade_no\":\""+orderNum+"\"}"); AlipayTradeQueryResponse response = alipayClient.execute(request); if(!response.isSuccess()){ return null; } return null; }
Example #7
Source File: AlipayServiceImpl.java From fast-family-master with Apache License 2.0 | 4 votes |
@Override public AlipayTradeQueryResponse selectOrder(AlipayTradeQueryModel model) throws AlipayApiException { AlipayTradeQueryRequest request = new AlipayTradeQueryRequest(); request.setBizModel(model); return alipayClient.execute(request); }
Example #8
Source File: PayController.java From blog-sample with Apache License 2.0 | 4 votes |
/** * 交易查询 * 以下两个参数任一即可 * @param orderId 订单ID * @param alipayNo 支付宝交易号 * @author jitwxs * @since 2018/6/4 19:15 */ @PostMapping("/alipay/query") @ResponseBody public Result queryOrder(String orderId, String alipayNo) { // 1、设置请求参数 AlipayTradeQueryRequest alipayRequest = new AlipayTradeQueryRequest(); Map<String, String> map = new HashMap<>(16); map.put("out_trade_no", orderId); map.put("trade_no", alipayNo); alipayRequest.setBizContent(JsonUtils.objectToJson(map)); try { // 2、请求 String json = alipayClient.execute(alipayRequest).getBody(); Map<String, Object> resMap = JsonUtils.jsonToPojo(json, Map.class); Map<String, String> responseMap = (Map)resMap.get("alipay_trade_query_response"); // 获得返回状态码,具体参考:https://docs.open.alipay.com/common/105806 String code = responseMap.get("code"); if("10000".equals(code)) { // 获取查询结果 String outTradeNo = responseMap.get("out_trade_no"); OrderInfo orderInfo = orderInfoService.selectById(outTradeNo); Map<String, Object> result = new HashMap<>(16); result.put("orderInfo", orderInfo); result.put("buyer_logon_id", responseMap.get("buyer_logon_id")); result.put("trade_status", responseMap.get("trade_status")); return Result.ok(null, result); } else { log.error("【支付宝查询】错误,错误码:{},错误信息:{}", code, responseMap.get("sub_msg")); return Result.error(ResultEnum.ALIPAY_QUERY_ERROR); } } catch (Exception e) { log.error("【支付宝查询】异常,异常信息:{}", e.getMessage()); e.printStackTrace(); } return Result.error(ResultEnum.ALIPAY_QUERY_ERROR); /* { "alipay_trade_query_response":{ "code":"10000", "msg":"Success", "buyer_logon_id":"uce***@sandbox.com", "buyer_pay_amount":"0.00", "buyer_user_id":"2088102176077881", "buyer_user_type":"PRIVATE", "invoice_amount":"0.00", "out_trade_no":"152810603232866", "point_amount":"0.00", "receipt_amount":"0.00", "send_pay_date":"2018-06-04 17:54:04", "total_amount":"2.00", "trade_no":"2018060421001004880200500828", "trade_status":"TRADE_SUCCESS" }, "sign":"HqdTcGWWhW4ivZxPNpdZfUkwHsVKg9eQZ2/Z17XA4wngMk3bOFmYYgYX5DwGPxccywyvxa+L7sUDZXQoxMYg2zcbPCLkn2poLCC51IAqCibo8R9F98cLFsjeKIFQ6Mw4a30lcFjr+esRTa8T7bJsoqRl4HX7B1qvMcarWJdBGN8AX3MIRmAWrqs2N4AULUghPucJKsApTi/CVebGYlf2e3cakxUhTos/Rw0Y3kvjwFaDBm18QZAt8xQ5dkYfFEEQuxDNkPYrxZTuAlp5M6BbEzbIf3z1iRBSkLuA7VfpZiZUNDw6dXLmpIaZZJK+3/Ltu3aOUJLlRR7EQ9PX7rDJ6g==" } { "alipay_trade_query_response":{ "code":"40004", "msg":"Business Failed", "sub_code":"ACQ.TRADE_NOT_EXIST", "sub_msg":"交易不存在", "buyer_pay_amount":"0.00", "invoice_amount":"0.00", "out_trade_no":"1528106032328", "point_amount":"0.00", "receipt_amount":"0.00" }, "sign":"BcGLHOlzPryBbF8FvuvvtA/8vItcZRawWJ7kX4SRKRxomB+h6kq+SzJG9xMs8N24CPA144D9EXBBCqAGPoj149pBBFHhmFwnBEFDpNrBrfB4MAfsJndK6xvYeaCoOXqgqs3f7tfOiDbUVOMuLKZYZTSm0N/UA2OKXUXT1aPVeLLMVuKPwBXZY7MvpbWxNVLqRz2Qmf6n1i4o4hl9p5ywiNIR9FgvAvN2Dwyd32QED1cYcfPXWJWGjWKucrsCcZIfetput+ZyYWxxG4l3GBQ32fXrAx1vbkfDtAdRmeStAfvUL3adiZpplEXil3AGgIckSlUfDF7hHG92Bnd1U9LYNg==" } */ }
Example #9
Source File: PayQueryChain.java From alipay with Apache License 2.0 | 2 votes |
/** * Building Query * <p> * 构建查询 * * @return String * @throws AlipayApiException AlipayApiException */ public String query() throws AlipayApiException { AlipayTradeQueryRequest queryRequest = new AlipayTradeQueryRequest (); queryRequest.setBizModel (alipayTradeQueryModel); return alipayClient.execute (queryRequest).getBody (); }
Example #10
Source File: PayQueryChain.java From alipay with Apache License 2.0 | 2 votes |
/** * Custom Build QueryRequest * <p> * 自定义构建QueryRequest * * @param queryRequest queryRequest * @return String * @throws AlipayApiException AlipayApiException */ public String query(AlipayTradeQueryRequest queryRequest) throws AlipayApiException { return alipayClient.execute (queryRequest).getBody (); }