Built files from Bizgaze WebServer
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

subscribeuserregistrations.js 44KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  2. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  3. return new (P || (P = Promise))(function (resolve, reject) {
  4. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  5. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  6. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  7. step((generator = generator.apply(thisArg, _arguments || [])).next());
  8. });
  9. };
  10. var Bizgaze;
  11. (function (Bizgaze) {
  12. let Apps;
  13. (function (Apps) {
  14. let Transact;
  15. (function (Transact) {
  16. let Controls;
  17. (function (Controls) {
  18. let Subscriptions;
  19. (function (Subscriptions) {
  20. class SubcribeUserRegistrations extends Unibase.Platform.Core.BaseComponent {
  21. cssFiles() {
  22. return ['apps/transact/controls/subscriptions/style.subscription.css'];
  23. }
  24. jsFiles() {
  25. return ["platform/bundle/index.subscriptions.components.min.js"];
  26. }
  27. html(id, containerid) {
  28. var html = `<div class="row p-md-5"> <div class="col-sm-8"> <div class="registration_form d-none"> <form class="biz-contact-form" id="biz-contact-form"><div class="d-flex align-items-center"><a class="btn btn-flush-biz-theme btn-icon back_report btn-rounded flush-soft-hover d-26 mr-2 registration_back_btn" onclick="Bizgaze.Apps.Transact.Controls.Subscriptions.OrderDetails.Instance().backProceedHtml();"><span class="btn-icon-wrap"><i data-icon="l"></i></span></a> <h2 class="font-weight-700 form-heading"> Registration </h2></div> <div class="row"> <div class="col-6"> <div><input type="text" class="mb-0 " placeholder="Company Name" name="companyName*" id="companyName" required autocomplete="off"></div><div><input type="text" class="mb-0 " placeholder="Contact Name*" name="contactName" id="contactName" required autocomplete="off"> </div><div><input type="email" class="mb-0 " placeholder="Email*" name="email" id="contactEmail" required autocomplete="off"></div><div class="text-danger emailValidText d-none"> Please enter a valid email </div><div><input type="text" class="mb-0 " placeholder="Address Line*" name="AddressName" id="AddressName" required autocomplete="off"> </div></div><div class="col-6"> <div class="mt-4 biz-select2-wrap"><input type="hidden" id="hf_CitiId"><select type="text" class="form-control floating-label-control" id="txt_city" data-label="Select" value=""><option></option></select><input type="hidden" id="hf_txtcity"></div><div><input type="text" class="mb-0 " placeholder="GSTIN" name="GSTIN" id="GSTIN" required autocomplete="off" maxlength="15"> </div><div class="text-danger gstValidText d-none"> Please enter a valid GSTIN </div><div> <div class="position-relative"><input type="number" maxlength="10" oninput="javascript: if (this.value.length > this.maxLength) this.value=this.value.slice(0, this.maxLength);" ; class="mb-0 " placeholder="Phone*" name="phone" id="contactPhone" required autocomplete="off"> <div class="position-absolute d-none" style="right:10px;top:40px"> <button type="submit" id="verify_btn" class="py-1 btn btn-primary btn-block">verify</button> </div></div></div></div></div></form> </div><div id="addon-list"></div></div><div class="col-sm-4"> <div class="ml-auto w-50"><img src="../../../../imgs/biz-logo.svg" class="img-fluid" alt="Bizgaze-Logo"></div><div id="errordiv"><span id="error_message" style="word-wrap: break-word; " class="text-danger"></span> </div><div id="cart_items_list"></div></div></div>`;
  29. return html;
  30. }
  31. load(id, containerid, callback) {
  32. var instance = this;
  33. Unibase.Platform.Helpers.FileCacheHelper.Instance().addCacheFiles(["apps/transact/controls/subscriptions/addons.component.js", "apps/transact/controls/subscriptions/registeremail.component.js"]);
  34. SubcribeUserRegistrations.Instance().autoComplete();
  35. Bizgaze.Apps.Transact.Controls.Subscriptions.OrderDetails.Instance().getPlanItem_List(instance.PlanItemId, instance.Tenureid);
  36. $(`#${containerid}`).addClass("registration-modal bg-white bg-registration").removeClass('bg-light');
  37. instance.isVerified = false;
  38. $('.biz-contact-form').find('input[type = "email"]').on("input", function () {
  39. var enteredEmail = $(this).val();
  40. if (enteredEmail == "") {
  41. if ($('.emailValidText').hasClass('d-none') == false) {
  42. $('.emailValidText').addClass('d-none');
  43. }
  44. }
  45. });
  46. $('.biz-contact-form').find('input').on("input", function () {
  47. if ($(this).attr('id') == 'contactEmail') {
  48. var enteredEmail = $(this).val();
  49. if (enteredEmail) {
  50. $('.emailValidText').addClass('d-none');
  51. $(this).attr("style", "");
  52. }
  53. }
  54. else {
  55. $(this).attr("style", "");
  56. }
  57. });
  58. $('.biz-contact-form').find('#txt_city').on("input", function () {
  59. $(this).parent().find('.select2-selection').removeClass('border-red');
  60. });
  61. function alphaOnly(event) {
  62. var key = event.keyCode;
  63. if (((key >= 65 && key <= 90) || key == 8) == false) {
  64. MessageHelper.Instance().showError("Please Enter valid GST Number", "div_errroMessage");
  65. }
  66. else if ((key >= 65 && key <= 90) || key == 8) {
  67. if ($('#Bizgaze-messageInfo')) {
  68. $('#Bizgaze-messageInfo').click();
  69. }
  70. }
  71. return ((key >= 65 && key <= 90) || key == 8);
  72. }
  73. ;
  74. function numericOnly(event) {
  75. var key = event.keyCode;
  76. if (((key >= 47 && key <= 58) || key == 8 || (key > 95 && key < 106)) == false) {
  77. MessageHelper.Instance().showError("Please Enter valid GST Number", "div_errroMessage");
  78. }
  79. else if ((key >= 47 && key <= 58) || key == 8 || (key > 95 && key < 106)) {
  80. if ($('#Bizgaze-messageInfo')) {
  81. $('#Bizgaze-messageInfo').click();
  82. }
  83. }
  84. return ((key > 47 && key < 58) || key == 8 || (key > 95 && key < 106));
  85. }
  86. ;
  87. function alphaNumeric(event) {
  88. var key = event.keyCode;
  89. return ((key > 47 && key < 58) || key == 8 || (key >= 65 && key <= 90));
  90. }
  91. ;
  92. $('#GSTIN').on('keydown', function () {
  93. $(this).addClass('text-uppercase');
  94. var gst_val = $('#GSTIN').val().toString();
  95. if (gst_val.length < 2) {
  96. return numericOnly(event);
  97. }
  98. else if ((gst_val.length >= 2) && (gst_val.length < 7)) {
  99. return alphaOnly(event);
  100. }
  101. else if ((gst_val.length >= 7) && (gst_val.length < 11)) {
  102. return numericOnly(event);
  103. }
  104. else if ((gst_val.length >= 11) && (gst_val.length < 12)) {
  105. return alphaOnly(event);
  106. }
  107. else if ((gst_val.length >= 12) && (gst_val.length < 13)) {
  108. return numericOnly(event);
  109. }
  110. else if ((gst_val.length >= 13) && (gst_val.length < 14)) {
  111. return alphaOnly(event);
  112. }
  113. else if ((gst_val.length >= 14) && (gst_val.length < 15)) {
  114. return alphaNumeric(event);
  115. }
  116. });
  117. }
  118. init() {
  119. }
  120. saveDetails() {
  121. var companyName = $("#companyName").val();
  122. var contactName = $("#contactName").val();
  123. var contactEmail = $("#contactEmail").val();
  124. var contactPhone = $("#contactPhone").val();
  125. var AddressName = $("#AddressName").val();
  126. var cityName = $("#txt_city").val();
  127. var GSTIN = $("#GSTIN").val();
  128. function validEmail(email) {
  129. var regex = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
  130. return regex.test(email);
  131. }
  132. function validGst(gstin) {
  133. var regex = /^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$/;
  134. /^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$/;
  135. return regex.test(gstin);
  136. }
  137. $('.biz-contact-form').find('input').on("input", function () {
  138. if ($(this).attr('id') == 'GSTIN') {
  139. var enteredGstin = $(this).val();
  140. if (validGst(enteredGstin)) {
  141. $('.gstValidText').addClass('d-none');
  142. }
  143. }
  144. });
  145. $('#biz-contact-form input').each(function () {
  146. var val = $(this).val();
  147. if (val == "") {
  148. var id = $(this).attr('id');
  149. if (id != 'companyName' && id != 'GSTIN') {
  150. $(this).css("border-color", "red");
  151. }
  152. }
  153. else {
  154. $(this).attr("style", "");
  155. }
  156. });
  157. if ($('#txt_city').val() == '') {
  158. $('#txt_city').parent().find('.select2-selection').addClass('border-red');
  159. }
  160. else {
  161. $('#txt_city').parent().find('.select2-selection').removeClass('border-red');
  162. }
  163. if (contactName == "" || contactPhone == "" || contactEmail == "" || AddressName == "" || cityName == "") {
  164. MessageHelper.Instance().showError("Mandatory fields are missing", "error_message");
  165. $('.emailValidText').addClass('d-none');
  166. }
  167. else {
  168. if (validEmail(contactEmail) == false) {
  169. $('.emailValidText').removeClass('d-none');
  170. $('#contactEmail').css("border-color", "red");
  171. return;
  172. }
  173. if (GSTIN != '') {
  174. if (validGst(GSTIN.toString().toUpperCase()) == false) {
  175. MessageHelper.Instance().showError("Please enter valid GSTIN", "error_message");
  176. return;
  177. }
  178. }
  179. if (this.isVerified == false) {
  180. $('#Bizgaze-messageInfo').click();
  181. if ($('.emailValidText').hasClass('d-none') == false) {
  182. $('.emailValidText').addClass('d-none');
  183. }
  184. var obj = {};
  185. obj = {
  186. UserName: contactName.toString().trim(),
  187. Email: contactEmail,
  188. ContactNumber: contactPhone,
  189. Organigationname: companyName.toString().trim(),
  190. };
  191. this.fileCacheHelper.loadJsFile('apps/transact/managers/subscriptions/subscriptionmanager.js', function () {
  192. Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().SubscriptionsUserValidationInfo(obj).then(function (response) {
  193. var res = response.result;
  194. if (response.result == null) {
  195. MessageHelper.Instance().showError(response.message, "error_message");
  196. }
  197. else {
  198. Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().sendOtp();
  199. }
  200. });
  201. });
  202. }
  203. }
  204. }
  205. autoComplete() {
  206. Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().getCityName().then(function (res) {
  207. return __awaiter(this, void 0, void 0, function* () {
  208. let response = res.result, data = [];
  209. response.forEach(function (item, index) {
  210. data.push({ id: item.cityid, text: item.cityname });
  211. });
  212. $('#txt_city').select2({
  213. placeholder: "Select City*",
  214. allowClear: true,
  215. data: data
  216. });
  217. });
  218. });
  219. }
  220. subcribeUserRegistration(planid, tenureid) {
  221. Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading();
  222. SubcribeUserRegistrations.instance.PlanItemId = Number(planid);
  223. SubcribeUserRegistrations.instance.Tenureid = Number(tenureid);
  224. var instance = this;
  225. instance.navigationHelper.popup(0, "", Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance(), null, Unibase.Platform.Helpers.Size.ExtraLarge);
  226. }
  227. proceedToPay() {
  228. this.saveDetails();
  229. }
  230. sendOtp() {
  231. var instance = this;
  232. var ContactText = $("#contactPhone").val().toString();
  233. let Ismail = ContactText.includes("@");
  234. if (ContactText != "") {
  235. if (Ismail == false) {
  236. if (ContactText.length == 10) {
  237. var token = "123456";
  238. SubcribeUserRegistrations.instance.isMail = Ismail;
  239. instance.fileCacheHelper.loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () {
  240. Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().getUserInfoByContactNo(ContactText).then(function (response) {
  241. var data = response.result;
  242. Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().getContactnumuberdetails(ContactText).then(function (res) {
  243. var info = res.result;
  244. if (data != null && data != "" || info != null && info != "") {
  245. MessageHelper.Instance().showError("Contact Number Alredy Exist", "error_message");
  246. }
  247. else {
  248. Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().otpVerificationModal();
  249. Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().sendEmail(ContactText, Ismail);
  250. }
  251. });
  252. });
  253. });
  254. }
  255. else {
  256. $('#contactPhone').css("border-color", "red");
  257. MessageHelper.Instance().showError("Please Enter Valid Mobile Number!", "error_message");
  258. }
  259. }
  260. if (Ismail == true) {
  261. SubcribeUserRegistrations.instance.isMail = Ismail;
  262. var token = "123456";
  263. Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().otpVerificationModal();
  264. Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().sendEmail(ContactText, Ismail);
  265. }
  266. }
  267. else {
  268. MessageHelper.Instance().showError("Please Enter Valid Input Details!", "error_message");
  269. }
  270. }
  271. otpVerificationModal() {
  272. const html = `<div class="modal fade otp-verification-modal" id="otpVerificationModal">
  273. <div class="modal-dialog modal-dialog-centered" role="document">
  274. <div class="modal-content">
  275. <div class="modal-body">
  276. <div class="otp-err-msg" id="otpErrMsg"></div>
  277. <img src="./imgs/otp-verify-img.png" class="otp-verify-img h-100p w-100p">
  278. <div class="otp-heading-wrap">
  279. <h5 class="otp-heading font-weight-bold mb-10">OTP Verification</h5>
  280. <p class="otp-desc">Enter 6 Digit Verification Code sent</p>
  281. </div>
  282. <div class="otp-input-group">
  283. <input class="otp-input" type="text" onkeyup="Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().otpInputTabChange(1);" maxlength=1>
  284. <input class="otp-input" type="text" onkeyup="Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().otpInputTabChange(2);" maxlength=1>
  285. <input class="otp-input" type="text" onkeyup="Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().otpInputTabChange(3);" maxlength=1>
  286. <input class="otp-input" type="text" onkeyup="Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().otpInputTabChange(4);" maxlength=1>
  287. <input class="otp-input" type="text" onkeyup="Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().otpInputTabChange(5);" maxlength=1>
  288. <input class="otp-input" type="text" onkeyup="Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().otpInputTabChange(6);" maxlength=1>
  289. </div>
  290. <div class="otp-modal-footer mt-30">
  291. <p class="otp-timer text-danger d-none">Time: <span class="otp-expire-time">00:46</span></p>
  292. <a href="javascript:;" onclick="Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().sendOtp();" class="otp-resend-link">Resend Code</a>
  293. <a href="javascript:;" class="btn subs-btn-outline-primary otp-submit-btn" id="otpSubmitBtn" onclick="Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().otpSubmitHandler();">Submit</a>
  294. </div>
  295. <a href="javascript:;" class="modal-close-btn btn btn-icon btn-flush-danger btn-rounded flush-soft-hover w-30p h-30p" id="otpModalCloseBtn"><span class="btn-icon-wrap"><i class="las la-times"></i></span></a>
  296. </div>
  297. </div>
  298. </div>
  299. </div>`;
  300. const containerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
  301. $('.otp-verification-modal').remove();
  302. $(`#${containerId}`).append(html);
  303. const otpModalEl = $('#otpVerificationModal');
  304. otpModalEl.addClass('show d-block');
  305. $('.otp-input').first().focus();
  306. $('#otpModalCloseBtn').click(function () {
  307. otpModalEl.removeClass('show d-block');
  308. });
  309. $('.otp-input-group .otp-input').on('input', function (e) {
  310. const inputEl = this;
  311. inputEl.value = inputEl.value.replace(/[^0-9]/g, '');
  312. });
  313. }
  314. sendEmail(email, Ismail) {
  315. this.fileCacheHelper.loadJsFile('apps/transact/managers/subscriptions/subscriptionmanager.js', function () {
  316. Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().sendRegistrationMail(email, Ismail).then(function (response) {
  317. var resinfo = response.result;
  318. var res = response.message;
  319. if (resinfo == null || resinfo == "") {
  320. MessageHelper.Instance().showError('OTP sending failed', 'otpErrMsg');
  321. }
  322. else {
  323. SubcribeUserRegistrations.instance.registertoken = response.result;
  324. MessageHelper.Instance().showSuccess('OTP Send Succefully', 'otpErrMsg');
  325. }
  326. });
  327. });
  328. }
  329. otpInputTabChange(val) {
  330. const ele = $('.otp-input');
  331. if (ele[val - 1].value != '') {
  332. if (ele[val])
  333. ele[val].focus();
  334. }
  335. else if (ele[val - 1].value == '') {
  336. if (ele[val - 2])
  337. ele[val - 2].focus();
  338. }
  339. }
  340. otpSubmitHandler() {
  341. var instance = this;
  342. let enteredOtp = '';
  343. $('.otp-input').each(function () {
  344. enteredOtp += $(this).val();
  345. });
  346. if (enteredOtp != '' || enteredOtp != "") {
  347. let otpId = SubcribeUserRegistrations.instance.registertoken;
  348. this.fileCacheHelper.loadJsFile('apps/transact/managers/subscriptions/subscriptionmanager.js', function () {
  349. Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().VerifyOtp(otpId, enteredOtp).then(function (response) {
  350. var res = response.result;
  351. if (res != null && res == true) {
  352. $('#otpVerificationModal').removeClass('show d-block');
  353. instance.isVerified = true;
  354. $('.registration-proceed-btn').removeClass('d-none');
  355. MessageHelper.Instance().showSuccess('Mobile Number verified Successfully', '');
  356. Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().SaveSubcriptionUserInfo();
  357. }
  358. else {
  359. MessageHelper.Instance().showError('Invalid OTP!', 'otpErrMsg');
  360. }
  361. });
  362. });
  363. }
  364. else {
  365. MessageHelper.Instance().showError('Please Enter OTP!', 'otpErrMsg');
  366. }
  367. }
  368. SaveSubcriptionUserInfo() {
  369. var companyName = $("#companyName").val();
  370. var contactName = $("#contactName").val();
  371. var contactEmail = $("#contactEmail").val();
  372. var contactPhone = $("#contactPhone").val();
  373. var AddressName = $("#AddressName").val();
  374. var cityName = $("#txt_city").val();
  375. var GSTIN = $("#GSTIN").val();
  376. var tenurePeriod = $('#select_period').val();
  377. if (tenurePeriod == 'select' || tenurePeriod == "" || tenurePeriod == null) {
  378. tenurePeriod = 0;
  379. }
  380. if (contactName == "") {
  381. MessageHelper.Instance().showError("Mandatory fields are missing", "error_message");
  382. }
  383. else {
  384. var instance = this;
  385. instance.navigationHelper.showLoading();
  386. var jsFiles = ["apps/transact/enums/enum.js", "apps/transact/managers/orders/ordermanager.js", "apps/transact/managers/subscriptions/subscriptionmanager.js"];
  387. instance.fileCacheHelper.loadJsFiles(jsFiles, function () {
  388. Subscriptions.OrderDetails.instance.OrderData = [];
  389. Subscriptions.OrderDetails.instance.ItemData = [];
  390. for (var i = 0; i < Subscriptions.OrderDetails.instance.CartItems.length; ++i) {
  391. var addonQuantity = Subscriptions.OrderDetails.instance.CartItems[i].addonQuantity;
  392. var addonSku = Subscriptions.OrderDetails.instance.CartItems[i].addonSku;
  393. var addonItemId = Subscriptions.OrderDetails.instance.CartItems[i].addonItemId;
  394. var unitPrice = Subscriptions.OrderDetails.instance.CartItems[i].unitPrice;
  395. var discountPercent = Subscriptions.OrderDetails.instance.CartItems[i].discountPercent;
  396. var discountValue = Subscriptions.OrderDetails.instance.CartItems[i].discountValue;
  397. var refItemId = Number($(this).find("#hf_refItemId").val());
  398. Subscriptions.OrderDetails.instance.ItemData.push({
  399. SKU: addonSku,
  400. Quantity: addonQuantity,
  401. ItemId: addonItemId,
  402. UnitPrice: unitPrice,
  403. DiscountPercent: isNaN(discountPercent) ? 0 : discountPercent,
  404. DiscountValue: isNaN(discountValue) ? 0 : discountValue,
  405. RefItemId: isNaN(refItemId) ? 0 : refItemId
  406. });
  407. }
  408. instance.ItemObj = JSON.stringify(Subscriptions.OrderDetails.instance.ItemData);
  409. var PlanId = SubcribeUserRegistrations.instance.PlanItemId;
  410. var TenureId = SubcribeUserRegistrations.instance.Tenureid;
  411. SubcribeUserRegistrations.instance.contactNumber = contactPhone;
  412. SubcribeUserRegistrations.instance.contactEmail = contactEmail;
  413. var obj = {};
  414. obj = {
  415. UserName: contactName.toString().trim(),
  416. Email: contactEmail,
  417. ContactNumber: contactPhone,
  418. Organigationname: companyName.toString().trim(),
  419. PlanId: PlanId,
  420. TenureId: TenureId,
  421. GSTNO: GSTIN,
  422. City: cityName,
  423. AddressLine1: AddressName.toString().trim(),
  424. TenurePeriod: Number(tenurePeriod),
  425. OrderObject: instance.ItemObj
  426. };
  427. Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().SaveSubscriptionsUserInfo(obj).then(function (response) {
  428. var res = response.result;
  429. if (response.result == null) {
  430. instance.navigationHelper.hideLoading();
  431. MessageHelper.Instance().showError(response.message, "error_message");
  432. }
  433. else {
  434. var customerUserId = res.SubscriptionsUserId;
  435. var PaymentStatus = true;
  436. var TotalAmt = Subscriptions.OrderDetails.instance.NetTotal;
  437. Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().paymentgateway(TotalAmt, customerUserId, PaymentStatus);
  438. }
  439. });
  440. });
  441. }
  442. }
  443. paymentgateway(invoiceamount, customerUserId, PaymentStatus) {
  444. var customerdetails = {};
  445. var subcribeuserobj = {};
  446. SubcribeUserRegistrations.instance.data = [];
  447. var customerUserId = customerUserId;
  448. if (isNaN(customerUserId)) {
  449. customerUserId = customerUserId;
  450. }
  451. var custContactNumber = SubcribeUserRegistrations.instance.contactNumber;
  452. var custEmailAdress = SubcribeUserRegistrations.instance.contactEmail;
  453. var instance = this;
  454. instance.fileCacheHelper.loadJsFiles(['apps/transact/managers/subscriptions/subscriptionmanager.js', 'settings/settings.js', 'platform/core/infos/status.js'], function () {
  455. var retunrUrl = window.location.origin + '/#/paymentorder/order_id={order_id}/order_token={order_token}';
  456. var dt = new Date();
  457. dt.setDate(dt.getDate() + 5);
  458. customerdetails = {
  459. CustomerId: String(customerUserId),
  460. CustomerEmail: custEmailAdress,
  461. CustomerPhone: custContactNumber,
  462. };
  463. SubcribeUserRegistrations.instance.data.push({
  464. OrderAmount: invoiceamount,
  465. OrderCurrency: "INR",
  466. customer_details: customerdetails,
  467. order_meta: {
  468. "ReturnUrl": retunrUrl
  469. },
  470. OrderExpiryTime: dt
  471. });
  472. Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().createGateWayOrder(instance.data[0]).then(function (response) {
  473. var res = response.result;
  474. if (response.status === Unibase.Data.Status.Error) {
  475. instance.navigationHelper.hideLoading();
  476. MessageHelper.Instance().showError(response.message, "error_message");
  477. }
  478. if (response.result != null) {
  479. var res = response.result;
  480. var url = res.payment_link;
  481. subcribeuserobj = {
  482. SubscriptionsUserId: customerUserId,
  483. OrderId: res.order_id,
  484. OrderToken: res.order_token,
  485. TotalAmount: invoiceamount
  486. };
  487. var paymentDetails = {};
  488. paymentDetails = {
  489. OrderId: res.order_id,
  490. OrderToken: res.order_token,
  491. TenureId: Number(SubcribeUserRegistrations.instance.Tenureid),
  492. TotalAmount: invoiceamount,
  493. };
  494. var obj = {};
  495. if (PaymentStatus == true) {
  496. obj = {
  497. SubscriptionsUserId: customerUserId,
  498. PaymentDetails: paymentDetails
  499. };
  500. }
  501. instance.fileCacheHelper.loadJsFile('apps/transact/managers/subscriptions/subscriptionmanager.js', function () {
  502. if (PaymentStatus == true) {
  503. Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().SaveSubscriptionsUserInfo(subcribeuserobj).then(function (response) {
  504. var savinfo = response.result;
  505. instance.navigationHelper.hideLoading();
  506. window.open(url, "_self");
  507. });
  508. }
  509. });
  510. }
  511. });
  512. });
  513. }
  514. retryPayement(invoiceamount, customerUserId, PaymentStatus, Cust_Email, custContactNumber) {
  515. var customerdetails = {};
  516. var subcribeuserobj = {};
  517. SubcribeUserRegistrations.instance.data = [];
  518. var customerUserId = customerUserId;
  519. if (isNaN(customerUserId)) {
  520. customerUserId = customerUserId;
  521. }
  522. var custContactNumber = custContactNumber;
  523. var custEmailAdress = Cust_Email;
  524. var instance = this;
  525. instance.fileCacheHelper.loadJsFiles(['apps/transact/managers/subscriptions/subscriptionmanager.js', 'settings/settings.js', 'platform/core/infos/status.js'], function () {
  526. var retunrUrl = window.location.origin + '/#/paymentorder/order_id ={order_id}/order_token={order_token}';
  527. var dt = new Date();
  528. dt.setDate(dt.getDate() + 5);
  529. customerdetails = {
  530. CustomerId: String(customerUserId),
  531. CustomerEmail: custEmailAdress,
  532. CustomerPhone: custContactNumber,
  533. };
  534. SubcribeUserRegistrations.instance.data.push({
  535. OrderAmount: invoiceamount,
  536. OrderCurrency: "INR",
  537. customer_details: customerdetails,
  538. order_meta: {
  539. "ReturnUrl": retunrUrl
  540. },
  541. OrderExpiryTime: dt
  542. });
  543. Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().createGateWayOrder(instance.data[0]).then(function (response) {
  544. var res = response.result;
  545. if (res.status === Unibase.Data.Status.Error) {
  546. instance.navigationHelper.hideLoading();
  547. MessageHelper.Instance().showError(res.message, "error_message");
  548. }
  549. if (response.result != null) {
  550. var res = response.result;
  551. var url = res.payment_link;
  552. subcribeuserobj = {
  553. SubscriptionsUserId: customerUserId,
  554. OrderId: res.order_id,
  555. OrderToken: res.order_token,
  556. TotalAmount: invoiceamount
  557. };
  558. var paymentDetails = {};
  559. paymentDetails = {
  560. OrderId: res.order_id,
  561. OrderToken: res.order_token,
  562. TenureId: Number(SubcribeUserRegistrations.instance.Tenureid),
  563. TotalAmount: invoiceamount,
  564. };
  565. var obj = {};
  566. if (PaymentStatus == true) {
  567. obj = {
  568. SubscriptionsUserId: customerUserId,
  569. PaymentDetails: paymentDetails
  570. };
  571. }
  572. instance.fileCacheHelper.loadJsFile('apps/transact/managers/subscriptions/subscriptionmanager.js', function () {
  573. if (PaymentStatus == true) {
  574. Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().SaveSubscriptionsUserInfo(subcribeuserobj).then(function (response) {
  575. var savinfo = response.result;
  576. instance.navigationHelper.hideLoading();
  577. window.open(url, "_self");
  578. });
  579. }
  580. });
  581. }
  582. });
  583. });
  584. }
  585. static Instance() {
  586. if (this.instance === undefined) {
  587. this.instance = new SubcribeUserRegistrations();
  588. }
  589. return this.instance;
  590. }
  591. }
  592. Subscriptions.SubcribeUserRegistrations = SubcribeUserRegistrations;
  593. })(Subscriptions = Controls.Subscriptions || (Controls.Subscriptions = {}));
  594. })(Controls = Transact.Controls || (Transact.Controls = {}));
  595. })(Transact = Apps.Transact || (Apps.Transact = {}));
  596. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  597. })(Bizgaze || (Bizgaze = {}));