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

修改flutterwave退款代码

上级 037472e6
......@@ -29,7 +29,6 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.Date;
......@@ -152,10 +151,17 @@ public class FlutterWaveServiceImpl implements FlutterWaveService {
}
try {
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);
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) {
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);
return result;
}
......
......@@ -3,6 +3,7 @@ package com.diaoyun.zion.master.enums;
public enum ResultCodeEnum {
SUCCESS(1,"success"),
ORDER_PAY_ERROR(9008,"payment failure"),
REFUND_PAY_ERROR(9009,"payment failure"),
ERROR(9999,"unknown error"),
APPLICATION_ERROR(9000,"application error"),
VALIDATE_ERROR(9001,"validate error"),
......
......@@ -15,14 +15,10 @@ public class PayTest {
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\"}]}}";
JSONObject jsonObject = JSONObject.fromObject(str).getJSONObject("content");
JSONArray data = jsonObject.getJSONArray("data");
for (int i = 0; i < data.size(); i++) {
//System.out.println(data.getString(i));
JSONObject object = JSONObject.fromObject(data.getString(i));
System.out.println(object.getString("sid"));
}
String str="{\"status\":\"fail\",\"data\":\"Error: Cannot refund non-existent transaction\",\"message\":\"request failed\"}";
String s = str.replaceAll("'\'", " ");
JSONObject jsonObject = JSONObject.fromObject(s);
System.out.println(jsonObject.getString("status"));
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论