提交 7eb0eb3f authored 作者: zgy's avatar zgy

修改flutterwave退款代码

上级 037472e6
...@@ -29,7 +29,6 @@ import org.springframework.beans.BeanUtils; ...@@ -29,7 +29,6 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.util.Date; import java.util.Date;
...@@ -152,10 +151,17 @@ public class FlutterWaveServiceImpl implements FlutterWaveService { ...@@ -152,10 +151,17 @@ public class FlutterWaveServiceImpl implements FlutterWaveService {
} }
try { try {
String post = HttpClientUtil.sendPostWithBodyParameter(FLUTTERWAVE_REFUND_URL, params); String post = HttpClientUtil.sendPostWithBodyParameter(FLUTTERWAVE_REFUND_URL, params);
result.setData(post).setMessage("Refund success!"); net.sf.json.JSONObject object = net.sf.json.JSONObject.fromObject(post);
logger.info("Refund success!"); System.out.println(object.getString("status"));
String status = object.getString("status");
if ("success".equals(status)) {
result.setData(object).setMessage("Refund success!");
logger.info("Refund success!");
} else {
result.setCode(ResultCodeEnum.REFUND_PAY_ERROR.getCode()).setMessage("Refund failure!");
}
} catch (IOException e) { } catch (IOException e) {
result.setCode(ResultCodeEnum.ORDER_PAY_ERROR.getCode()).setMessage(e.getMessage()); result.setCode(ResultCodeEnum.REFUND_PAY_ERROR.getCode()).setMessage(e.getMessage());
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
return result; return result;
} }
......
...@@ -3,6 +3,7 @@ package com.diaoyun.zion.master.enums; ...@@ -3,6 +3,7 @@ package com.diaoyun.zion.master.enums;
public enum ResultCodeEnum { public enum ResultCodeEnum {
SUCCESS(1,"success"), SUCCESS(1,"success"),
ORDER_PAY_ERROR(9008,"payment failure"), ORDER_PAY_ERROR(9008,"payment failure"),
REFUND_PAY_ERROR(9009,"payment failure"),
ERROR(9999,"unknown error"), ERROR(9999,"unknown error"),
APPLICATION_ERROR(9000,"application error"), APPLICATION_ERROR(9000,"application error"),
VALIDATE_ERROR(9001,"validate error"), VALIDATE_ERROR(9001,"validate error"),
......
...@@ -15,14 +15,10 @@ public class PayTest { ...@@ -15,14 +15,10 @@ public class PayTest {
public static void main(String[] args) { public static void main(String[] args) {
String str = "{\"error\":0,\"content\":{\"rknums\":2,\"data\":[{\"sid\":\"46777865677\",\"rktime\":\"2019-09-29 11:03:35\"},{\"sid\":\"ceshi20190929\",\"rktime\":\"2019-09-29 15:07:16\"}]}}"; String str="{\"status\":\"fail\",\"data\":\"Error: Cannot refund non-existent transaction\",\"message\":\"request failed\"}";
JSONObject jsonObject = JSONObject.fromObject(str).getJSONObject("content"); String s = str.replaceAll("'\'", " ");
JSONArray data = jsonObject.getJSONArray("data"); JSONObject jsonObject = JSONObject.fromObject(s);
for (int i = 0; i < data.size(); i++) { System.out.println(jsonObject.getString("status"));
//System.out.println(data.getString(i));
JSONObject object = JSONObject.fromObject(data.getString(i));
System.out.println(object.getString("sid"));
}
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论