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.

271 lines
8.8 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <script type="text/javascript">
  2. var token = "";
  3. token = "[[${token}]]"
  4. //console.log(token);
  5. var txansactionId = "";
  6. txansactionId = "[[${txansactionId}]]"
  7. //console.log(txansactionId);
  8. var amount = "";
  9. amount = "[[${amount}]]"
  10. //console.log(amount);
  11. var merchantId = "";
  12. merchantId = "[[${merchantId}]]"
  13. //console.log(merchantId);
  14. var ConsumerId = "";
  15. ConsumerId = "[[${consumerId}]]"
  16. //console.log(ConsumerId);
  17. var ConsumerMobileNo = "";
  18. ConsumerMobileNo = "[[${consumerMobileNo}]]"
  19. //console.log(ConsumerMobileNo);
  20. var ConsumerEmailId = "";
  21. ConsumerEmailId = "[[${consumerEmailId}]]"
  22. //console.log(ConsumerEmailId);
  23. $(document).ready(function () {
  24. function handleResponse(res) {
  25. if (typeof res != "undefined" && typeof res.paymentMethod != "undefined" && typeof res.paymentMethod.paymentTransaction != "undefined" && typeof res.paymentMethod.paymentTransaction.statusCode != "undefined" && res.paymentMethod.paymentTransaction.statusCode == "0300") {
  26. // success block
  27. //console.log("Success ");
  28. //console.log(res);
  29. } 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") {
  30. // initiated block
  31. //console.log("Initiated ");
  32. //console.log(res);
  33. } else {
  34. //console.log("error ");
  35. //console.log(res);
  36. // error block
  37. }
  38. };
  39. $(document).off("click", "#btnSubmit").on("click", "#btnSubmit", function (e) {
  40. e.preventDefault();
  41. var reqJson = {
  42. "features": {
  43. "enableAbortResponse": true,
  44. "enableExpressPay": true,
  45. "enableInstrumentDeRegistration": true,
  46. "enableMerTxnDetails": true,
  47. "enableNewWindowFlow": true //for hybrid applications please disable this by passing false
  48. },
  49. "consumerData": {
  50. "deviceId": "WEBSH2", //possible values "WEBSH1" or "WEBSH2"
  51. "token": token,
  52. "returnUrl": "/communityhall/payment/response", //merchant response page URL
  53. "responseHandler": handleResponse,
  54. "paymentMode": "all",
  55. "merchantLogoUrl": "https://upload.wikimedia.org/wikipedia/commons/a/a8/Chennai_Corporation_Emblem.png", //provided merchant logo will be displayed
  56. "merchantName": "Greater Chennai Corporation",
  57. "merchantMsg": "Community Hall Booking",
  58. "merchantId": merchantId,
  59. "currency": "INR",
  60. "consumerId": consumerId,
  61. "consumerMobileNo": consumerMobileNo,
  62. "consumerEmailId": consumerEmailId,
  63. "txnId": txansactionId, //Unique merchant transaction ID
  64. "items": [{
  65. "itemId": "FIRST",
  66. "amount": amount,
  67. "comAmt": "0"
  68. }],
  69. "customStyle": {
  70. "PRIMARY_COLOR_CODE": "#45beaa", //merchant primary color code
  71. "SECONDARY_COLOR_CODE": "#FFFFFF", //provide merchant's suitable color code
  72. "BUTTON_COLOR_CODE_1": "#2d8c8c", //merchant's button background color code
  73. "BUTTON_COLOR_CODE_2": "#FFFFFF" //provide merchant's suitable color code for button text
  74. }
  75. }
  76. };
  77. //console.log(reqJson);
  78. $.pnCheckout(reqJson);
  79. if (reqJson.features.enableNewWindowFlow) {
  80. pnCheckoutShared.openNewWindow();
  81. }
  82. });
  83. });
  84. function paymentStart(counterUserId, counterBookingId, counterOption) {
  85. //alert(this.userId);
  86. if (counterOption) {
  87. this.userId = counterUserId;
  88. this.bookingId = counterBookingId;
  89. } else {
  90. if (this.userId == 0) {
  91. alert("Please Login & Retry");
  92. return false;
  93. }
  94. if (this.bookingId == 0) {
  95. alert("Please try retry booking");
  96. return false;
  97. }
  98. }
  99. if (this.userId != 0 && this.bookingId != 0) {
  100. var userIdd = userId;
  101. var bookingIdd = bookingId;
  102. //console.log("userIdd:-" + userIdd);
  103. //console.log("bookingIdd:-" + bookingIdd);
  104. $.ajax({
  105. type: "POST",
  106. url: '/communityhall/payment/api/payment-request',
  107. data: {'userId': userIdd, 'bookingId': bookingIdd},
  108. success: function (response) {
  109. console.log(response);
  110. if (response.error) {
  111. alert("please Contact Admin..")
  112. } else {
  113. txansactionId = response.txansactionId;
  114. consumerMobileNo = response.consumerMobileNo;
  115. consumerEmailId = response.consumerEmailId;
  116. token = response.token;
  117. merchantId = response.merchantId;
  118. consumerId = response.consumerId;
  119. amount = response.amount;
  120. //console.log(txansactionId);
  121. //console.log(consumerMobileNo);
  122. //console.log(token);
  123. //console.log(merchantId);
  124. //console.log(consumerId);
  125. //console.log(amount);
  126. $("#btnSubmit").click();
  127. }
  128. },
  129. error: function () {
  130. //console.log("Error");// Handle error here
  131. }
  132. });
  133. }
  134. else {
  135. alert("please logout & retry")
  136. }
  137. return false;
  138. }
  139. function extrapaymentStart(userId, bookingId) {
  140. if (this.userId != 0 && this.bookingId != 0) {
  141. var userIdd = userId;
  142. var bookingIdd = bookingId;
  143. //console.log("userIdd:-" + userIdd);
  144. //console.log("bookingIdd:-" + bookingIdd);
  145. $.ajax({
  146. type: "POST",
  147. url: '/communityhall/payment/api/additionaldamage-payment-request',
  148. data: {'userId': userIdd, 'bookingId': bookingIdd},
  149. success: function (response) {
  150. console.log(response);
  151. if (response.error) {
  152. alert("please Contact Admin..")
  153. } else {
  154. txansactionId = response.txansactionId;
  155. consumerMobileNo = response.consumerMobileNo;
  156. consumerEmailId = response.consumerEmailId;
  157. token = response.token;
  158. merchantId = response.merchantId;
  159. consumerId = response.consumerId;
  160. amount = response.amount;
  161. //console.log(txansactionId);
  162. //console.log(consumerMobileNo);
  163. //console.log(token);
  164. //console.log(merchantId);
  165. //console.log(consumerId);
  166. //console.log(amount);
  167. $("#extrapaymentbtnSubmit").click();
  168. }
  169. },
  170. error: function () {
  171. //console.log("Error");// Handle error here
  172. }
  173. });
  174. }
  175. else {
  176. alert("please logout & retry")
  177. }
  178. return false;
  179. }
  180. $(document).ready(function () {
  181. function handleResponseED(res) {
  182. if (typeof res != "undefined" && typeof res.paymentMethod != "undefined" && typeof res.paymentMethod.paymentTransaction != "undefined" && typeof res.paymentMethod.paymentTransaction.statusCode != "undefined" && res.paymentMethod.paymentTransaction.statusCode == "0300") {
  183. // success block
  184. //console.log("Success ");
  185. //console.log(res);
  186. } 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") {
  187. // initiated block
  188. //console.log("Initiated ");
  189. //console.log(res);
  190. } else {
  191. //console.log("error ");
  192. //console.log(res);
  193. // error block
  194. }
  195. };
  196. $(document).off("click", "#extrapaymentbtnSubmit").on("click", "#extrapaymentbtnSubmit", function (e) {
  197. e.preventDefault();
  198. console.log(txansactionId);
  199. console.log(consumerMobileNo);
  200. console.log(token);
  201. console.log(merchantId);
  202. console.log(consumerId);
  203. console.log(amount);
  204. var reqJson = {
  205. "features": {
  206. "enableAbortResponse": true,
  207. "enableExpressPay": true,
  208. "enableInstrumentDeRegistration": true,
  209. "enableMerTxnDetails": true,
  210. "enableNewWindowFlow": true //for hybrid applications please disable this by passing false
  211. },
  212. "consumerData": {
  213. "deviceId": "WEBSH2", //possible values "WEBSH1" or "WEBSH2"
  214. "token": token,
  215. "returnUrl": "/communityhall/payment/additionaldamage-response", //merchant response page URL
  216. "responseHandler": handleResponseED,
  217. "paymentMode": "all",
  218. "merchantLogoUrl": "https://upload.wikimedia.org/wikipedia/commons/a/a8/Chennai_Corporation_Emblem.png", //provided merchant logo will be displayed
  219. "merchantName": "Greater Chennai Corporation",
  220. "merchantMsg": "Community Hall Booking",
  221. "merchantId": merchantId,
  222. "currency": "INR",
  223. "consumerId": consumerId,
  224. "consumerMobileNo": consumerMobileNo,
  225. "consumerEmailId": consumerEmailId,
  226. "txnId": txansactionId, //Unique merchant transaction ID
  227. "items": [{
  228. "itemId": "FIRST",
  229. "amount": amount,
  230. "comAmt": "0"
  231. }],
  232. "customStyle": {
  233. "PRIMARY_COLOR_CODE": "#45beaa", //merchant primary color code
  234. "SECONDARY_COLOR_CODE": "#FFFFFF", //provide merchant's suitable color code
  235. "BUTTON_COLOR_CODE_1": "#2d8c8c", //merchant's button background color code
  236. "BUTTON_COLOR_CODE_2": "#FFFFFF" //provide merchant's suitable color code for button text
  237. }
  238. }
  239. };
  240. $.pnCheckout(reqJson);
  241. if (reqJson.features.enableNewWindowFlow) {
  242. pnCheckoutShared.openNewWindow();
  243. }
  244. });
  245. });
  246. </script>