修改越南支付

master
DESKTOP-C3M45P4\dengdan 2025-01-06 16:06:50 +08:00
parent 527e56a00b
commit 2d0abed593
1 changed files with 14 additions and 8 deletions

View File

@ -47,15 +47,15 @@ public class VietnamGamotaRechargeController {
return result.toString(); return result.toString();
} }
Map<String, String> map = verifyOrder(parameterMap); Map<String, String> map = verifyOrder(parameterMap,md5key);
if (map == null || map.isEmpty()){ if (map == null || map.isEmpty()){
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支付验证结果:{}",map);
int errorCode = Integer.parseInt(map.get("error_code")); String errorCode = map.get("error_code");
if (errorCode != 0){ if (!"0".equals(errorCode)){
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();
@ -70,8 +70,8 @@ public class VietnamGamotaRechargeController {
return result.toString(); return result.toString();
} }
public static Map<String, String> verifyOrder(Map<String,String> map) { public static Map<String, String> verifyOrder(Map<String,String> map,String apiKey) {
String url = "https://paygate.gamota.com/v1/services/check_transaction"; 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"));
try { try {
@ -109,8 +109,14 @@ public class VietnamGamotaRechargeController {
} }
public static void main(String[] args) { public static void main(String[] args) {
String a = "{\"error_code\":0,\"message\":\"Charging successfully!\",\"data\":{\"transaction_id\":\"AP20102226662769G\",\"type\":\"GOOGLE\",\"amount\":\"1.99\",\"vendor\":\"\",\"currency\":\"USD\",\"target\":\"username:XuanXuXu|userid:2618078\",\"state\":\"4_637389746321354058_9_1_1603352647\",\"sandbox\":1,\"time\":\"22\\/10\\/2020 14:44:20 GMT+7\",\"product_id\":\"com.gunx.item1.199\"}}"; String url = "https://paygate.gamota.com/v1/services/check_transaction?api_key=" +"GMA202401-4B0C8B6C-C3B7290DEC0B";
Gson gson = new Gson(); Map<String,String> parms = new HashMap<>();
System.out.println(gson.fromJson(a, Map.class)); parms.put("transaction_id","GM250106688157G");
try {
String data = HttpUtils.doPost(url, parms);
System.out.println("越南gamota支付验证" + data);
}catch (IOException e){
e.printStackTrace();
}
} }
} }