创建代付订单接口调用示例(JAVA):
~~~
try {
Map<String, Object> map = new HashMap<>();
map.put("mchNo", paymentChannelSplit.getMerchantId());//商户ID
map.put("appId", paymentChannelSplit.getMerchantPwd());//appId
map.put("mchOrderNo", paymentWithDraw.getMsgId());
map.put("amount", paymentWithDraw.getAmount());
map.put("currency", paymentWithDraw.getChannelCurrency());
map.put("accountNo", paymentWithDraw.getBankAccount());
map.put("ifscCode", paymentWithDraw.getIfscCode());
map.put("accountName", paymentWithDraw.getUserName());
map.put("phone", paymentWithDraw.getPhone());
map.put("email", paymentWithDraw.getEmail());
map.put("address", paymentWithDraw.getUserName());
map.put("transferDesc", "withdraw");
map.put("sign", OopaySignUtil.getSign(map, paymentChannelSplit.getPrivateKey()));
OopayWithdrawResponse response = oopayApi.oopayReq(OopayWithdrawResponse.class, map, "/api/transferOrder");
if (null != response && response.getCode() == 2000) {
if (null != response.getData() && null != response.getData().getTransferId()) {
paymentWithDraw.setChannelOrderId(response.getData().getTransferId());
} else {
paymentWithDraw.setStatus(FAIL.value);
}
paymentWithDraw.setBizRespMsg(response.getMsg());
}
} finally {
}
~~~
~~~
public <T> T oopayReq(Class<T> clazz, Map<String, Object> params, String endpoint) throws IOException {
String url = applicationProperites.getOopayUrl() + endpoint;
HttpClient httpClient = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
// 构造消息头
post.setHeader("Content-type", "application/json; charset=utf-8");
// 构建消息实体
StringEntity entity = new StringEntity(JSONUtil.toJsonStr(params), Charset.forName("UTF-8"));
entity.setContentEncoding("UTF-8");
// 发送Json格式的数据请求
entity.setContentType("application/json");
post.setEntity(entity);
HttpResponse response = httpClient.execute(post);
org.apache.http.HttpEntity responseEntity = response.getEntity();
String result = EntityUtils.toString(responseEntity,"UTF-8").trim();
logger.info("Oopay response data:{}",result);
return JSONUtil.toBean(result, clazz);
}
~~~
