diff --git a/src/main/java/com/jmfy/controller/VietnamGamotaRechargeController.java b/src/main/java/com/jmfy/controller/VietnamGamotaRechargeController.java index b756234..8f55152 100644 --- a/src/main/java/com/jmfy/controller/VietnamGamotaRechargeController.java +++ b/src/main/java/com/jmfy/controller/VietnamGamotaRechargeController.java @@ -47,15 +47,15 @@ public class VietnamGamotaRechargeController { return result.toString(); } - Map map = verifyOrder(parameterMap); + Map map = verifyOrder(parameterMap,md5key); if (map == null || map.isEmpty()){ LOGGER.error("verify order is error"); result.put("messsage", "verify order is error"); return result.toString(); } LOGGER.info("越南gamota支付验证结果:{}",map); - int errorCode = Integer.parseInt(map.get("error_code")); - if (errorCode != 0){ + String errorCode = map.get("error_code"); + if (!"0".equals(errorCode)){ LOGGER.error("verify order is false"); result.put("messsage", "verify order is false"); return result.toString(); @@ -70,8 +70,8 @@ public class VietnamGamotaRechargeController { return result.toString(); } - public static Map verifyOrder(Map map) { - String url = "https://paygate.gamota.com/v1/services/check_transaction"; + public static Map verifyOrder(Map map,String apiKey) { + String url = "https://paygate.gamota.com/v1/services/check_transaction?api_key = " + apiKey; Map parms = new HashMap<>(); parms.put("transaction_id",map.get("transaction_id")); try { @@ -109,8 +109,14 @@ public class VietnamGamotaRechargeController { } 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\"}}"; - Gson gson = new Gson(); - System.out.println(gson.fromJson(a, Map.class)); + String url = "https://paygate.gamota.com/v1/services/check_transaction?api_key=" +"GMA202401-4B0C8B6C-C3B7290DEC0B"; + Map parms = new HashMap<>(); + parms.put("transaction_id","GM250106688157G"); + try { + String data = HttpUtils.doPost(url, parms); + System.out.println("越南gamota支付验证" + data); + }catch (IOException e){ + e.printStackTrace(); + } } }