diff --git a/.classpath b/.classpath index 3496f14..d48976d 100644 --- a/.classpath +++ b/.classpath @@ -37,5 +37,6 @@ + diff --git a/src/main/java/com/test/world/DTO/RefundRequest.java b/src/main/java/com/test/world/DTO/RefundRequest.java new file mode 100644 index 0000000..7974efb --- /dev/null +++ b/src/main/java/com/test/world/DTO/RefundRequest.java @@ -0,0 +1,12 @@ +package com.test.world.DTO; + +import java.util.HashMap; + +public class RefundRequest { + + private HashMap merchant; + private HashMap transaction; + + + +} diff --git a/src/main/java/com/test/world/controller/PaymentController.java b/src/main/java/com/test/world/controller/PaymentController.java index a95035c..9348e79 100644 --- a/src/main/java/com/test/world/controller/PaymentController.java +++ b/src/main/java/com/test/world/controller/PaymentController.java @@ -4,6 +4,7 @@ import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; @@ -11,23 +12,28 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; +import com.test.world.service.PaymentGatewayService; + @Controller @RequestMapping("/payment") public class PaymentController { + + @Autowired + PaymentGatewayService paymentService; @GetMapping(value = {"","/","/index"}) public String startPayment(Model model) throws NoSuchAlgorithmException { - String txansactionId="1707115835222"; //create transaction Id unique from our side + String txansactionId="1707115835225"; //create transaction Id unique from our side String amt = "10"; //Amount of Community Hall from our side String merchantId="T955031|"; //This is Test Merchant ID from worldLine String txnId= txansactionId+"|"; String totalAmt=amt+"|"; String accountNo="|"; - String consumerId="c964634"+"|"; // Replace consumer ID in c964634 from our side - String consumerMobileNo="9879879870"+"|"; //Replace consumer Mobile no in 9879879870 from our side - String consumerEmailId="mohammedthaqi@bontonsoftwares.com"+"|"; //replace consumer email Id from our side + String consumerId="c964634|"; // Replace consumer ID in c964634 from our side + String consumerMobileNo="7845014181|"; //Replace consumer Mobile no in 9879879870 from our side + String consumerEmailId="mohammedthaqi@bontonsoftwares.com|"; //replace consumer email Id String debitStartDate="|"; String debitEndDate="|"; String maxAmount="|"; @@ -37,42 +43,49 @@ public class PaymentController { String expMonth="|"; String expYear="|"; String cvvCode="|"; - String salt="1025180466GPADTD"; //This is Test salt from worldLine + String salt="1025180466GPADTD"; String token=merchantId+txnId+totalAmt+accountNo+consumerId+consumerMobileNo+ consumerEmailId+debitStartDate+debitEndDate+maxAmount+amountType+ frequency+cardNumber+expMonth+expYear+cvvCode+salt; - - //Generate token using SHA-512 or SHA-256 - MessageDigest md = MessageDigest.getInstance("SHA-512"); - md.update(token.getBytes()); - - byte[] bytes = md.digest(); - - BigInteger bigInt = new BigInteger(1, bytes); - String encryptedtoken = bigInt.toString(16); - - while (encryptedtoken.length() < 128) { - encryptedtoken = "0" + encryptedtoken; - }; - System.out.println(token); - System.out.println("Encrypted Password: " + encryptedtoken); + + String encryptedtoken = paymentService.generateToken(token); + model.addAttribute("txansactionId",txansactionId); model.addAttribute("token",encryptedtoken); model.addAttribute("amount",amt); - //check the Index page Configuration of WorldLine return "index"; } @PostMapping(value = "/response") - public String response(Model model, @RequestParam(required = false) String msg){ - + public String response(Model model, @RequestParam(required = false) String msg) throws NoSuchAlgorithmException{ + String salt = "1025180466GPADTD"; //Here you will receive the response System.out.println(msg); - + String confirmToken=""; + String status="success"; String s = new String(msg); + String c = new String(); String res[] =s.split("\\|"); for(int i=0;i