|
|
|
@ -4,7 +4,9 @@ import java.io.IOException;
|
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
@ -27,6 +29,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import au.com.royalpay.payment.core.exceptions.ChannelNetworkException;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.ofei.TopUpOrderMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.ofei.core.OfeiClient;
|
|
|
|
|
import au.com.royalpay.payment.manage.ofei.enums.OfeiType;
|
|
|
|
|
import au.com.royalpay.payment.tools.codec.MD5Hash;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
|
|
|
|
@ -55,6 +58,14 @@ public class OfeiClientImpl implements OfeiClient {
|
|
|
|
|
private final String flowTopUPUrl = "http://api2.ofpay.com/flowOrder.do";
|
|
|
|
|
private final String checkFlowUrl = "http://api2.ofpay.com/flowCheck.do";
|
|
|
|
|
private final String checkOrderUrl = "http://api2.ofpay.com/queryOrderInfo.do";
|
|
|
|
|
private final String qbTopUpUrl = "http://api2.ofpay.com/onlineorder.do";
|
|
|
|
|
private static final Map<String,String> qbCardId = new HashMap<>();
|
|
|
|
|
static {
|
|
|
|
|
qbCardId.put("10","220615");
|
|
|
|
|
qbCardId.put("30","220617");
|
|
|
|
|
qbCardId.put("50","220698");
|
|
|
|
|
qbCardId.put("100","220699");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void phoneTopUp(String price, boolean quickTopUp, String topUpDelayTime, String phoneNumber) {
|
|
|
|
@ -75,13 +86,13 @@ public class OfeiClientImpl implements OfeiClient {
|
|
|
|
|
params.add(new BasicNameValuePair("game_userid", phoneNumber));
|
|
|
|
|
params.add(new BasicNameValuePair("ret_url", "https://mpay.royalpay.com.au/ofei/notice/"+orderId));
|
|
|
|
|
|
|
|
|
|
saveOrder(orderId, now, "1", price, phoneNumber);
|
|
|
|
|
saveOrder(orderId, now, OfeiType.PHONE.getMask(), price, phoneNumber);
|
|
|
|
|
HttpRequestGenerator req = initRequest(topUPUrl, signAndEncryptForm(params), RequestMethod.GET);
|
|
|
|
|
Element respXml = executeRequestXML(req, "ofei phone top up fail");
|
|
|
|
|
handleResponse(orderId, respXml,phoneNumber);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void handleResponse(String orderId, Element respXml,String phoneNumber) {
|
|
|
|
|
private void handleResponse(String orderId, Element respXml,String customerNumber) {
|
|
|
|
|
JSONObject detail = new JSONObject();
|
|
|
|
|
if ("1".equals(respXml.elementText("retcode"))) {
|
|
|
|
|
detail.put("cardname", respXml.elementText("cardname"));
|
|
|
|
@ -103,7 +114,7 @@ public class OfeiClientImpl implements OfeiClient {
|
|
|
|
|
}else {
|
|
|
|
|
detail.put("err_msg",respXml.elementText("err_msg"));
|
|
|
|
|
updateOrder(orderId,"99",detail);
|
|
|
|
|
logger.debug("phone->"+phoneNumber+" top up error orderId->"+orderId);
|
|
|
|
|
logger.debug("Customer NUmber->"+customerNumber+" top up error orderId->"+orderId);
|
|
|
|
|
throw new ServerErrorException("System error");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -145,7 +156,7 @@ public class OfeiClientImpl implements OfeiClient {
|
|
|
|
|
params.add(new BasicNameValuePair("effectTime", "1"));
|
|
|
|
|
params.add(new BasicNameValuePair("netType", "4G"));
|
|
|
|
|
params.add(new BasicNameValuePair("sporderId", orderId));
|
|
|
|
|
saveOrder(orderId, new Date(), "2", perValue, phoneNumber);
|
|
|
|
|
saveOrder(orderId, new Date(), OfeiType.FLOW.getMask(), perValue, phoneNumber);
|
|
|
|
|
HttpRequestGenerator req = initRequest(flowTopUPUrl, signAndEncryptForm(params), RequestMethod.GET);
|
|
|
|
|
Element respXml = executeRequestXML(req, "ofei flowTopUp");
|
|
|
|
|
handleResponse(orderId, respXml,phoneNumber);
|
|
|
|
@ -188,6 +199,35 @@ public class OfeiClientImpl implements OfeiClient {
|
|
|
|
|
return executeRequestXML(req,"ofei check order status error");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void qbTopUp(String price, String qqNumber) {
|
|
|
|
|
if(price.contains(".")){
|
|
|
|
|
throw new BadRequestException("Invalid Price");
|
|
|
|
|
}
|
|
|
|
|
String orderId = "ofei-" + DateFormatUtils.format(new Date(), "yyyyMMddHHmmss") + "-" + RandomStringUtils.random(5, true, true);
|
|
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
|
|
String md5Pwd = MD5Hash.hashToHex(pwd);
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
params.add(new BasicNameValuePair("userid", spCode));
|
|
|
|
|
params.add(new BasicNameValuePair("userpws", md5Pwd));
|
|
|
|
|
if(qbCardId.containsKey(price)){
|
|
|
|
|
params.add(new BasicNameValuePair("cardid", qbCardId.get(price)));
|
|
|
|
|
params.add(new BasicNameValuePair("cardnum", "1"));
|
|
|
|
|
}else {
|
|
|
|
|
params.add(new BasicNameValuePair("cardid", "220612"));
|
|
|
|
|
params.add(new BasicNameValuePair("cardnum", price));
|
|
|
|
|
}
|
|
|
|
|
params.add(new BasicNameValuePair("sporder_id", orderId));
|
|
|
|
|
params.add(new BasicNameValuePair("sporder_time", DateFormatUtils.format(now, "yyyyMMddHHmmss")));
|
|
|
|
|
params.add(new BasicNameValuePair("game_userid", qqNumber));
|
|
|
|
|
params.add(new BasicNameValuePair("ret_url", "https://mpay.royalpay.com.au/ofei/notice/"+orderId));
|
|
|
|
|
saveOrder(orderId, now, OfeiType.QB.getMask(), price, qqNumber);
|
|
|
|
|
HttpRequestGenerator req = initRequest(qbTopUpUrl, signAndEncryptForm(params), RequestMethod.POST);
|
|
|
|
|
Element respXml = executeRequestXML(req, "ofei QB top up fail");
|
|
|
|
|
handleResponse(orderId, respXml,qqNumber);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<NameValuePair> signAndEncryptForm(List<NameValuePair> params) {
|
|
|
|
|
String signStr = "";
|
|
|
|
|
for (NameValuePair pair : params) {
|
|
|
|
|