diff --git a/Dockerfile b/Dockerfile index 54c4e42..9005a4c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ FROM openjdk:17-jdk-alpine ARG JAR_FILE=target/*.jar -COPY ./target/Nagad-Payment-0.0.1-SNAPSHOT.jar Nagad_payment.jar +COPY ./target/Nagad-Payment-0.0.2-SNAPSHOT.jar Nagad_payment.jar ENTRYPOINT ["java","-jar", "Nagad_payment.jar"] \ No newline at end of file diff --git a/pom.xml b/pom.xml index 72d29a7..9e273f7 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ com.tomal Nagad-Payment - 0.0.1-SNAPSHOT + 0.0.2-SNAPSHOT Nagad-Payment Nagad project for Spring Boot diff --git a/src/main/java/com/tomal/Nagad/Payment/CryptoUtility/CryptoCommon.java b/src/main/java/com/tomal/Nagad/Payment/CryptoUtility/CryptoCommon.java index 593edd3..561b4a6 100644 --- a/src/main/java/com/tomal/Nagad/Payment/CryptoUtility/CryptoCommon.java +++ b/src/main/java/com/tomal/Nagad/Payment/CryptoUtility/CryptoCommon.java @@ -23,9 +23,6 @@ public class CryptoCommon { - //InputStream inputStream = getClass().getResourceAsStream("/marchent_private.pem"); - //InputStream publicKey = getClass().getResourceAsStream("/marchent_public.pem"); - public byte[] sign(PrivateKey merchantPrivateKey, byte[] bytes) { Object var4 = null; @@ -67,7 +64,7 @@ public PublicKey getPublic() throws Exception { InputStream inputStream = resource.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String content = reader.readLine(); - System.out.println(content); + //System.out.println(content); content = content.replaceAll("\\s", ""); @@ -82,7 +79,7 @@ public PrivateKey getPrivate() throws Exception { InputStream inputStream = resource.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String content = reader.readLine(); - System.out.println(content); + //System.out.println(content); content = content.replaceAll("\\s", ""); diff --git a/src/main/java/com/tomal/Nagad/Payment/services/NagadServices.java b/src/main/java/com/tomal/Nagad/Payment/services/NagadServices.java index a706efa..1ad7d05 100644 --- a/src/main/java/com/tomal/Nagad/Payment/services/NagadServices.java +++ b/src/main/java/com/tomal/Nagad/Payment/services/NagadServices.java @@ -18,6 +18,9 @@ import java.nio.file.Paths; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; import java.util.Base64; import java.util.Date; import java.util.HashMap; @@ -44,9 +47,11 @@ public class NagadServices { public String create(Map data, String ipAddress) throws Throwable { byte[] KPG_DefaultSeed = ("nagad-dfs-service-ltd" + System.currentTimeMillis() + "").getBytes();; String random = common.generateRandomString(20, KPG_DefaultSeed); - Date date = new Date(); - DateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); - String datetime = format.format(date); + ZoneId dhakaZone = ZoneId.of("Asia/Dhaka"); + ZonedDateTime currentDhakaTime = ZonedDateTime.now(dhakaZone); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); + //DateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); + String datetime = formatter.format(currentDhakaTime); Long orderId = System.currentTimeMillis(); Map rawData = new HashMap<>(); rawData.put("merchantId", marchentId); @@ -85,7 +90,7 @@ public String create(Map data, String ipAddress) throws Throwabl Response response = client.newCall(request).execute(); String responsedata = response.body().string(); - //System.out.println(responsedata); + ApiInitializeModel apiData = new Gson().fromJson(responsedata, ApiInitializeModel.class); byte[] dataDecode = common.decrypt(common.getPrivate(), decoder.decode(apiData.getSensitiveData())); String responseSensitiveData = new String(dataDecode, StandardCharsets.UTF_8); @@ -103,15 +108,16 @@ public String create(Map data, String ipAddress) throws Throwabl //System.out.println(mapper.writeValueAsString(data)); rawDataToBeEncrypted = mapper.writeValueAsString(data); - rawEncryptedBytes = common.encrypt(common.getPublic(), rawDataToBeEncrypted.getBytes("UTF-8")); - rawSignatureBytes = common.sign(common.getPrivate(), rawDataToBeEncrypted.getBytes("UTF-8")); + System.out.println(rawDataToBeEncrypted); + rawEncryptedBytes = common.encrypt(common.getPublic(), rawDataToBeEncrypted.getBytes(StandardCharsets.UTF_8)); + rawSignatureBytes = common.sign(common.getPrivate(), rawDataToBeEncrypted.getBytes(StandardCharsets.UTF_8)); sensitiveData = encoder.encodeToString(rawEncryptedBytes); signature = encoder.encodeToString(rawSignatureBytes); - + System.out.println("work "); Map productInfo = new HashMap<>(); productInfo.put("productName", "T-Shirt"); productInfo.put("quantity", "1"); - String pro = mapper.writeValueAsString(productInfo); + //String pro = mapper.writeValueAsString(productInfo); //System.out.println(pro); JSONObject object = new JSONObject();