This commit is contained in:
liaozetao
2024-01-05 18:34:50 +08:00
parent 08e308aca2
commit 346e4f31b1
2 changed files with 11 additions and 14 deletions

View File

@@ -134,15 +134,14 @@ public class MyCardBizServiceImpl implements MyCardBizService {
@Override
public String callback(CallbackDto callback) {
BaseResult result = new BaseResult();
try {
result.setReturnCode(callback.getReturnCode());
result.setReturnMsg(URLDecoder.decode(callback.getReturnMsg(), StandardCharsets.UTF_8.name()));
} catch (Exception e) {
log.error(e.getMessage(), e);
}
if (!callback.isSuccess()) {
return JSONObject.toJSONString(result);
String returnMsg = callback.getReturnMsg();
try {
returnMsg = URLDecoder.decode(returnMsg, StandardCharsets.UTF_8.name());
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return returnMsg;
}
String preHashValue = callback.getReturnCode() + callback.getPayResult() + callback.getFacTradeSeq() + callback.getPaymentType() + callback.getAmount() + callback.getCurrency() + callback.getMyCardTradeNo() + callback.getMyCardType() + callback.getPromoCode() + myCardConfig.getSecretKey();
String encodeHashValue = StrUtil.EMPTY;
@@ -159,7 +158,7 @@ public class MyCardBizServiceImpl implements MyCardBizService {
String payResult = callback.getPayResult();
if (StrUtil.isEmpty(payResult) || !payResult.equals(PAY_SUCCESS)) {
log.error("支付非成功状态, payResult : {}", payResult);
return JSONObject.toJSONString(result);
return "交易失敗";
}
String chargeRecordId = callback.getFacTradeSeq();
String currency = callback.getCurrency();
@@ -169,13 +168,11 @@ public class MyCardBizServiceImpl implements MyCardBizService {
updateOrder(chargeRecordId, currency, amount, myCardTradeNo);
ChargeRecord chargeRecord = chargeRecordMapper.selectByPrimaryKey(chargeRecordId);
if (chargeRecord == null) {
result.setReturnMsg("交易失敗");
return JSONObject.toJSONString(result);
return "交易失敗";
}
String metadata = chargeRecord.getMetadata();
if (StrUtil.isEmpty(metadata)) {
result.setReturnMsg("交易失敗");
return JSONObject.toJSONString(result);
return "交易失敗";
}
AuthGlobalResp authGlobalResp = JSONObject.parseObject(metadata, AuthGlobalResp.class);
String successUrl = authGlobalResp.getSuccessUrl();

View File

@@ -96,7 +96,7 @@ public class MyCardController {
}
try {
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
response.setContentType(MediaType.TEXT_PLAIN_VALUE);
response.getWriter().write(result);
} catch (Exception e) {
log.error(e.getMessage(), e);