mirror of
https://github.com/dromara/payment-spring-boot.git
synced 2026-03-14 05:43:46 +08:00
优化异常处理
This commit is contained in:
@@ -7,6 +7,7 @@ import cn.felord.payment.wechat.enumeration.WechatPayV3Type;
|
|||||||
import cn.felord.payment.wechat.v3.model.ResponseSignVerifyParams;
|
import cn.felord.payment.wechat.v3.model.ResponseSignVerifyParams;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.*;
|
||||||
import org.springframework.http.converter.HttpMessageConverter;
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
import org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter;
|
import org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter;
|
||||||
@@ -196,14 +197,14 @@ public class WechatPayClient {
|
|||||||
ResponseEntity<ObjectNode> responseEntity = restOperations.exchange(requestEntity, ObjectNode.class);
|
ResponseEntity<ObjectNode> responseEntity = restOperations.exchange(requestEntity, ObjectNode.class);
|
||||||
HttpHeaders headers = responseEntity.getHeaders();
|
HttpHeaders headers = responseEntity.getHeaders();
|
||||||
ObjectNode body = responseEntity.getBody();
|
ObjectNode body = responseEntity.getBody();
|
||||||
if (!responseEntity.getStatusCode().is2xxSuccessful()) {
|
HttpStatus statusCode = responseEntity.getStatusCode();
|
||||||
throw new PayException("wechat pay server error,result : " + body);
|
if (!statusCode.is2xxSuccessful()) {
|
||||||
|
throw new PayException("wechat pay server error,statusCode "+ statusCode +",result : " + body);
|
||||||
}
|
}
|
||||||
if (Objects.isNull(body)) {
|
if (Objects.isNull(body)) {
|
||||||
throw new PayException("cant obtain wechat response body");
|
throw new PayException("cant obtain wechat response body");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ResponseSignVerifyParams params = new ResponseSignVerifyParams();
|
ResponseSignVerifyParams params = new ResponseSignVerifyParams();
|
||||||
// 微信请求回调id
|
// 微信请求回调id
|
||||||
// String RequestId = response.header("Request-ID");
|
// String RequestId = response.header("Request-ID");
|
||||||
@@ -233,8 +234,9 @@ public class WechatPayClient {
|
|||||||
ResponseEntity<String> responseEntity = restOperations.exchange(requestEntity, String.class);
|
ResponseEntity<String> responseEntity = restOperations.exchange(requestEntity, String.class);
|
||||||
|
|
||||||
String body = responseEntity.getBody();
|
String body = responseEntity.getBody();
|
||||||
if (!responseEntity.getStatusCode().is2xxSuccessful()) {
|
HttpStatus statusCode = responseEntity.getStatusCode();
|
||||||
throw new PayException("wechat pay server error,result : " + body);
|
if (!statusCode.is2xxSuccessful()) {
|
||||||
|
throw new PayException("wechat pay server error,statusCode "+ statusCode +",result : " + body);
|
||||||
}
|
}
|
||||||
if (Objects.isNull(body)) {
|
if (Objects.isNull(body)) {
|
||||||
throw new PayException("cant obtain wechat response body");
|
throw new PayException("cant obtain wechat response body");
|
||||||
|
|||||||
Reference in New Issue
Block a user