2.4.5: hotfix-bsbno check

master
Yixian 3 years ago
parent fa42e449d0
commit 0bfbc8e5c9

@ -1,10 +1,13 @@
package au.com.royalpay.payment.manage.gateway.beans;
import au.com.royalpay.payment.core.exceptions.ParamInvalidException;
import au.com.royalpay.payment.manage.merchants.core.bank.AustraliaBank;
import au.com.royalpay.payment.manage.merchants.core.bank.AustraliaBankInfo;
import au.com.royalpay.payment.manage.system.core.impl.ClientContractServiceImpl;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@ -18,6 +21,7 @@ import java.lang.reflect.Field;
import java.text.ParseException;
import java.util.Arrays;
import java.util.Date;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -47,7 +51,7 @@ public class ClientSettleConfig {
private String activeTime;
@JSONField(name = "expire_time")
private String expireTime;
private JSONObject bankQueryInfo;
private AustraliaBankInfo bankQueryInfo;
private Date activeTimeDate;
private static String[] WHITE_LIST = {"bankQueryInfo", "activeTimeDate"};
@ -79,10 +83,10 @@ public class ClientSettleConfig {
}
if (sandboxMode) {
bankQueryInfo = new JSONObject();
bankQueryInfo = new AustraliaBankInfo();
} else {
bankQueryInfo = getBankInfo(bsbNo);
if (bankQueryInfo == null || bankQueryInfo.isEmpty() || !bankQueryInfo.getBooleanValue("valid")) {
bankQueryInfo = AustraliaBank.getBankInfo(bsbNo);
if (bankQueryInfo.isNone()) {
throw new BadRequestException("PARAM_ERROR:BSB No is invalid");
}
}
@ -99,25 +103,7 @@ public class ClientSettleConfig {
bankInfo.put("bsb_no", bsbNo);
bankInfo.put("account_no", accountNo);
bankInfo.put("account_name", accountName);
bankInfo.putAll(bankQueryInfo);
bankInfo.putAll((JSONObject) JSON.toJSON(bankQueryInfo));
return bankInfo;
}
private JSONObject getBankInfo(String bsb_no) {
// bd451cc3e3ad66c75165dc852507e8f0
// 收费 ab9379cfdab559509bbdcdd11923489f
String url = "https://api.bank.codes/au-bsb/json/ab9379cfdab559509bbdcdd11923489f/" + bsb_no;
JSONObject res = new JSONObject();
try {
HttpRequestResult result = new HttpRequestGenerator(url, RequestMethod.GET).execute();
if (result.isSuccess()) {
res = result.getResponseContentJSONObj();
} else {
logger.error("Request bsb info error {}-->{}", bsb_no, result.getResponseContentString());
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
return res;
}
}

Loading…
Cancel
Save