generated from root/miduo_server
增加越南支付类
parent
2d0abed593
commit
e4bb01d181
|
@ -4,25 +4,18 @@ import com.google.gson.Gson;
|
||||||
import com.jmfy.paramBean.PaySdkEnum;
|
import com.jmfy.paramBean.PaySdkEnum;
|
||||||
import com.jmfy.util.HttpUtils;
|
import com.jmfy.util.HttpUtils;
|
||||||
import com.jmfy.util.JsonUtil;
|
import com.jmfy.util.JsonUtil;
|
||||||
import com.jmfy.util.MD5Util;
|
import com.jmfy.vo.GamotaObj;
|
||||||
import net.sf.json.JSON;
|
|
||||||
import org.dom4j.Document;
|
|
||||||
import org.dom4j.DocumentException;
|
|
||||||
import org.dom4j.Element;
|
|
||||||
import org.dom4j.io.SAXReader;
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.xml.sax.InputSource;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.util.Date;
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
import java.util.regex.Matcher;
|
import java.util.Map;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class VietnamGamotaRechargeController {
|
public class VietnamGamotaRechargeController {
|
||||||
|
@ -47,21 +40,20 @@ public class VietnamGamotaRechargeController {
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> map = verifyOrder(parameterMap,md5key);
|
GamotaObj obj = verifyOrder(parameterMap,md5key);
|
||||||
if (map == null || map.isEmpty()){
|
if (obj == null){
|
||||||
LOGGER.error("verify order is error");
|
LOGGER.error("verify order is error");
|
||||||
result.put("messsage", "verify order is error");
|
result.put("messsage", "verify order is error");
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
LOGGER.info("越南gamota支付验证结果:{}",map);
|
LOGGER.info("越南gamota支付验证结果:{}",obj);
|
||||||
String errorCode = map.get("error_code");
|
int errorCode = obj.getError_code();
|
||||||
if (!"0".equals(errorCode)){
|
if (errorCode != 0){
|
||||||
LOGGER.error("verify order is false");
|
LOGGER.error("verify order is false");
|
||||||
result.put("messsage", "verify order is false");
|
result.put("messsage", "verify order is false");
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
Gson gson = new Gson();
|
Map<String, String> data = obj.getData();
|
||||||
Map<String, String> data = gson.fromJson(map.get("data"), Map.class);
|
|
||||||
String inserted = insertOrder(parameterMap, data);
|
String inserted = insertOrder(parameterMap, data);
|
||||||
if ("SUCCESS".equals(inserted)) {
|
if ("SUCCESS".equals(inserted)) {
|
||||||
result.put("error_code",0);
|
result.put("error_code",0);
|
||||||
|
@ -70,7 +62,7 @@ public class VietnamGamotaRechargeController {
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, String> verifyOrder(Map<String,String> map,String apiKey) {
|
public static GamotaObj verifyOrder(Map<String,String> map,String apiKey) {
|
||||||
String url = "https://paygate.gamota.com/v1/services/check_transaction?api_key = " + apiKey;
|
String url = "https://paygate.gamota.com/v1/services/check_transaction?api_key = " + apiKey;
|
||||||
Map<String,String> parms = new HashMap<>();
|
Map<String,String> parms = new HashMap<>();
|
||||||
parms.put("transaction_id",map.get("transaction_id"));
|
parms.put("transaction_id",map.get("transaction_id"));
|
||||||
|
@ -78,7 +70,8 @@ public class VietnamGamotaRechargeController {
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
String data = HttpUtils.doPost(url, parms);
|
String data = HttpUtils.doPost(url, parms);
|
||||||
LOGGER.info("越南gamota支付验证请求结果:{}",data);
|
LOGGER.info("越南gamota支付验证请求结果:{}",data);
|
||||||
return gson.fromJson(data, Map.class);
|
GamotaObj obj = gson.fromJson(data, GamotaObj.class);
|
||||||
|
return gson.fromJson(data, GamotaObj.class);
|
||||||
}catch (IOException e){
|
}catch (IOException e){
|
||||||
LOGGER.error("越南gamota支付验证请求报错",e);
|
LOGGER.error("越南gamota支付验证请求报错",e);
|
||||||
return null;
|
return null;
|
||||||
|
@ -113,9 +106,20 @@ public class VietnamGamotaRechargeController {
|
||||||
Map<String,String> parms = new HashMap<>();
|
Map<String,String> parms = new HashMap<>();
|
||||||
parms.put("transaction_id","GM250106688157G");
|
parms.put("transaction_id","GM250106688157G");
|
||||||
try {
|
try {
|
||||||
String data = HttpUtils.doPost(url, parms);
|
String r = HttpUtils.doPost(url, parms);
|
||||||
System.out.println("越南gamota支付验证" + data);
|
System.out.println("越南gamota支付验证" + r);
|
||||||
}catch (IOException e){
|
Gson gson = new Gson();
|
||||||
|
GamotaObj obj = gson.fromJson(r, GamotaObj.class);
|
||||||
|
//
|
||||||
|
System.out.println(obj.getError_code() + "----" + Double.parseDouble(obj.getData().get("amount")));
|
||||||
|
// String errorCode = map.get("error_code").toString();
|
||||||
|
// String data = map.get("data").toString();
|
||||||
|
// System.out.println(data);
|
||||||
|
// if (!"0.0".equals(errorCode)){
|
||||||
|
// System.out.println(errorCode + "----" + errorCode);
|
||||||
|
// }
|
||||||
|
// Map<String, Object> map = gson.fromJson(r,Map.class);
|
||||||
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.jmfy.vo;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 越南gamota支付返回的对象数据
|
||||||
|
*/
|
||||||
|
public class GamotaObj {
|
||||||
|
private int error_code;
|
||||||
|
private String message;
|
||||||
|
private Map<String,String> data = new HashMap<String,String>();
|
||||||
|
|
||||||
|
public int getError_code() {
|
||||||
|
return error_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setError_code(int error_code) {
|
||||||
|
this.error_code = error_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(Map<String, String> data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue