You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
4.3 KiB

3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!doctype html>
  2. <html xmlns:th="http://www.thymeleaf.org">
  3. <head>
  4. <title>Checkout Demo</title>
  5. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1" />
  6. <script src="https://www.paynimo.com/paynimocheckout/client/lib/jquery.min.js" type="text/javascript"></script>
  7. </head>
  8. <body>
  9. <button id="btnSubmit">Proceed to Pay</button>
  10. <h1 th:text="${token}"></h1>
  11. <script type="text/javascript" src="https://www.paynimo.com/paynimocheckout/server/lib/checkout.js"></script>
  12. <script type="text/javascript">
  13. var token="";
  14. token = "[[${token}]]"
  15. console.log(token);
  16. var txansactionId="";
  17. txansactionId="[[${txansactionId}]]"
  18. console.log(txansactionId);
  19. var amount="";
  20. amount="[[${amount}]]"
  21. console.log(amount);
  22. $(document).ready(function() {
  23. function handleResponse(res) {
  24. if (typeof res != "undefined" && typeof res.paymentMethod != "undefined" && typeof res.paymentMethod.paymentTransaction != "undefined" && typeof res.paymentMethod.paymentTransaction.statusCode != "undefined" && res.paymentMethod.paymentTransaction.statusCode == "0300") {
  25. // success block
  26. console.log("Success ");
  27. console.log(res);
  28. } else if (typeof res != "undefined" && typeof res.paymentMethod != "undefined" && typeof res.paymentMethod.paymentTransaction != "undefined" && typeof res.paymentMethod.paymentTransaction.statusCode != "undefined" && res.paymentMethod.paymentTransaction.statusCode == "0398") {
  29. // initiated block
  30. console.log("Initiated ");
  31. console.log(res);
  32. } else {
  33. console.log("error ");
  34. console.log(res);
  35. // error block
  36. }
  37. };
  38. $(document).off("click", "#btnSubmit").on("click", "#btnSubmit", function(e) {
  39. e.preventDefault();
  40. var reqJson = {
  41. "features": {
  42. "enableAbortResponse": true,
  43. "enableExpressPay": true,
  44. "enableInstrumentDeRegistration" : true,
  45. "enableMerTxnDetails": true,
  46. "enableNewWindowFlow": true //for hybrid applications please disable this by passing false
  47. },
  48. "consumerData": {
  49. "deviceId": "WEBSH2", //possible values "WEBSH1" or "WEBSH2"
  50. "token": token,
  51. "returnUrl": "/payment/response", //merchant response page URL
  52. "responseHandler": handleResponse,
  53. "paymentMode": "all",
  54. "merchantLogoUrl": "https://upload.wikimedia.org/wikipedia/commons/a/a8/Chennai_Corporation_Emblem.png", //provided merchant logo will be displayed
  55. "merchantName": "Greater Chennai Corporation",
  56. "merchantMsg": "Community Hall Booking",
  57. "merchantId": "T955031",
  58. "currency": "INR",
  59. "consumerId": "c964634",
  60. "consumerMobileNo": "7845014181",
  61. "consumerEmailId": "mohammedthaqi@bontonsoftwares.com",
  62. "txnId": txansactionId, //Unique merchant transaction ID
  63. "items": [{
  64. "itemId": "FIRST",
  65. "amount": amount,
  66. "comAmt": "0"
  67. }],
  68. "customStyle": {
  69. "PRIMARY_COLOR_CODE": "#45beaa", //merchant primary color code
  70. "SECONDARY_COLOR_CODE": "#FFFFFF", //provide merchant's suitable color code
  71. "BUTTON_COLOR_CODE_1": "#2d8c8c", //merchant's button background color code
  72. "BUTTON_COLOR_CODE_2": "#FFFFFF" //provide merchant's suitable color code for button text
  73. }
  74. }
  75. };
  76. $.pnCheckout(reqJson);
  77. if(reqJson.features.enableNewWindowFlow){
  78. pnCheckoutShared.openNewWindow();
  79. }
  80. });
  81. });
  82. </script>
  83. </body>
  84. </html>