| | |
| | | package com.ruoyi.payment.ali.v2; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alipay.api.AlipayClient; |
| | | import com.alipay.api.AlipayConfig; |
| | | import com.alipay.api.DefaultAlipayClient; |
| | |
| | | //异步返回参数 |
| | | model.setPassbackParams(pojo.getPassbackParams()); |
| | | request.setBizModel(model); |
| | | request.setNotifyUrl(aliProperties.getNotifyUrl() + pojo.getNotifyUrl()); |
| | | |
| | | AlipayTradeCreateResponse response = alipayClient.execute(request); |
| | | log.info("-----调起支付宝支付-----"); |
| | | log.info("请求参数:{}", pojo); |
| | | log.info("请求参数:{}", JSON.toJSONString(request)); |
| | | log.info("返回结果:{}", response.getBody()); |
| | | if (response.isSuccess()) { |
| | | return PaymentResp.build(response.getOutTradeNo(), response.getTradeNo()); |
| | |
| | | log.info("请求参数:{}", req); |
| | | log.info("返回结果:{}", response.getBody()); |
| | | if (response.isSuccess()) { |
| | | return JSON.parseObject(response.getBody(), RefundResp.class); |
| | | JSONObject jsonObject = JSON.parseObject(response.getBody()); |
| | | RefundResp alipay_trade_refund_response = jsonObject.getObject("alipay_trade_refund_response", RefundResp.class); |
| | | return alipay_trade_refund_response; |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | alipayConfig.setSignType(SignType.RSA2.getType()); |
| | | //判断加签方式 |
| | | String signType = aliProperties.getSignType(); |
| | | if(SignType.CERT.getType().equals(signType)){ |
| | | if(SignType.SECRET_KEY.getType().equals(signType)){ |
| | | alipayConfig.setPrivateKey(aliProperties.getPrivateKey()); |
| | | alipayConfig.setAlipayPublicKey(aliProperties.getAlipayPublicKey()); |
| | | return alipayConfig; |
| | | } |
| | | if(SignType.SECRET_KEY.getType().equals(signType)){ |
| | | if(SignType.CERT.getType().equals(signType)){ |
| | | alipayConfig.setAppCertPath(aliProperties.getAppCertPath()); |
| | | alipayConfig.setAlipayPublicCertPath(aliProperties.getAlipayPublicCertPath()); |
| | | alipayConfig.setRootCertPath(aliProperties.getRootCertPath()); |