Built files from Bizgaze WebServer
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.

subscribeuserregistrations.js 43KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  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 (contactName == "") {
  378. MessageHelper.Instance().showError("Mandatory fields are missing", "error_message");
  379. }
  380. else {
  381. var instance = this;
  382. instance.navigationHelper.showLoading();
  383. var jsFiles = ["apps/transact/enums/enum.js", "apps/transact/managers/orders/ordermanager.js", "apps/transact/managers/subscriptions/subscriptionmanager.js"];
  384. instance.fileCacheHelper.loadJsFiles(jsFiles, function () {
  385. Subscriptions.OrderDetails.instance.OrderData = [];
  386. Subscriptions.OrderDetails.instance.ItemData = [];
  387. for (var i = 0; i < Subscriptions.OrderDetails.instance.CartItems.length; ++i) {
  388. var addonQuantity = Subscriptions.OrderDetails.instance.CartItems[i].addonQuantity;
  389. var addonSku = Subscriptions.OrderDetails.instance.CartItems[i].addonSku;
  390. var addonItemId = Subscriptions.OrderDetails.instance.CartItems[i].addonItemId;
  391. var unitPrice = Subscriptions.OrderDetails.instance.CartItems[i].unitPrice;
  392. var discountPercent = Subscriptions.OrderDetails.instance.CartItems[i].discountPercent;
  393. var discountValue = Subscriptions.OrderDetails.instance.CartItems[i].discountValue;
  394. var refItemId = Number($(this).find("#hf_refItemId").val());
  395. Subscriptions.OrderDetails.instance.ItemData.push({
  396. SKU: addonSku,
  397. Quantity: addonQuantity,
  398. ItemId: addonItemId,
  399. UnitPrice: unitPrice,
  400. DiscountPercent: isNaN(discountPercent) ? 0 : discountPercent,
  401. DiscountValue: isNaN(discountValue) ? 0 : discountValue,
  402. RefItemId: isNaN(refItemId) ? 0 : refItemId
  403. });
  404. }
  405. instance.ItemObj = JSON.stringify(Subscriptions.OrderDetails.instance.ItemData);
  406. var PlanId = SubcribeUserRegistrations.instance.PlanItemId;
  407. var TenureId = SubcribeUserRegistrations.instance.Tenureid;
  408. SubcribeUserRegistrations.instance.contactNumber = contactPhone;
  409. SubcribeUserRegistrations.instance.contactEmail = contactEmail;
  410. var obj = {};
  411. obj = {
  412. UserName: contactName.toString().trim(),
  413. Email: contactEmail,
  414. ContactNumber: contactPhone,
  415. Organigationname: companyName.toString().trim(),
  416. PlanId: PlanId,
  417. TenureId: TenureId,
  418. GSTNO: GSTIN,
  419. City: cityName,
  420. AddressLine1: AddressName.toString().trim(),
  421. TenurePeriod: Number(tenurePeriod),
  422. OrderObject: instance.ItemObj
  423. };
  424. Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().SaveSubscriptionsUserInfo(obj).then(function (response) {
  425. var res = response.result;
  426. if (response.result == null) {
  427. instance.navigationHelper.hideLoading();
  428. MessageHelper.Instance().showError(response.message, "error_message");
  429. }
  430. else {
  431. var customerUserId = res.SubscriptionsUserId;
  432. var PaymentStatus = true;
  433. var TotalAmt = Subscriptions.OrderDetails.instance.NetTotal;
  434. Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().paymentgateway(TotalAmt, customerUserId, PaymentStatus);
  435. }
  436. });
  437. });
  438. }
  439. }
  440. paymentgateway(invoiceamount, customerUserId, PaymentStatus) {
  441. var customerdetails = {};
  442. var subcribeuserobj = {};
  443. SubcribeUserRegistrations.instance.data = [];
  444. var customerUserId = customerUserId;
  445. if (isNaN(customerUserId)) {
  446. customerUserId = customerUserId;
  447. }
  448. var custContactNumber = SubcribeUserRegistrations.instance.contactNumber;
  449. var custEmailAdress = SubcribeUserRegistrations.instance.contactEmail;
  450. var instance = this;
  451. instance.fileCacheHelper.loadJsFiles(['apps/transact/managers/subscriptions/subscriptionmanager.js', 'settings/settings.js', 'platform/core/infos/status.js'], function () {
  452. var retunrUrl = window.location.origin + '/#/paymentorder/order_id={order_id}/order_token={order_token}';
  453. var dt = new Date();
  454. dt.setDate(dt.getDate() + 5);
  455. customerdetails = {
  456. CustomerId: String(customerUserId),
  457. CustomerEmail: custEmailAdress,
  458. CustomerPhone: custContactNumber,
  459. };
  460. SubcribeUserRegistrations.instance.data.push({
  461. OrderAmount: invoiceamount,
  462. OrderCurrency: "INR",
  463. customer_details: customerdetails,
  464. order_meta: {
  465. "ReturnUrl": retunrUrl
  466. },
  467. OrderExpiryTime: dt
  468. });
  469. Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().createGateWayOrder(instance.data[0]).then(function (response) {
  470. var res = response.result;
  471. if (response.status === Unibase.Data.Status.Error) {
  472. instance.navigationHelper.hideLoading();
  473. MessageHelper.Instance().showError(response.message, "error_message");
  474. }
  475. if (response.result != null) {
  476. var res = response.result;
  477. var url = res.payment_link;
  478. subcribeuserobj = {
  479. SubscriptionsUserId: customerUserId,
  480. OrderId: res.order_id,
  481. OrderToken: res.order_token,
  482. TotalAmount: invoiceamount
  483. };
  484. var paymentDetails = {};
  485. paymentDetails = {
  486. OrderId: res.order_id,
  487. OrderToken: res.order_token,
  488. TenureId: Number(SubcribeUserRegistrations.instance.Tenureid),
  489. TotalAmount: invoiceamount,
  490. };
  491. var obj = {};
  492. if (PaymentStatus == true) {
  493. obj = {
  494. SubscriptionsUserId: customerUserId,
  495. PaymentDetails: paymentDetails
  496. };
  497. }
  498. instance.fileCacheHelper.loadJsFile('apps/transact/managers/subscriptions/subscriptionmanager.js', function () {
  499. if (PaymentStatus == true) {
  500. Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().SaveSubscriptionsUserInfo(subcribeuserobj).then(function (response) {
  501. var savinfo = response.result;
  502. instance.navigationHelper.hideLoading();
  503. window.open(url, "_self");
  504. });
  505. }
  506. });
  507. }
  508. });
  509. });
  510. }
  511. retryPayement(invoiceamount, customerUserId, PaymentStatus, Cust_Email, custContactNumber) {
  512. var customerdetails = {};
  513. var subcribeuserobj = {};
  514. SubcribeUserRegistrations.instance.data = [];
  515. var customerUserId = customerUserId;
  516. if (isNaN(customerUserId)) {
  517. customerUserId = customerUserId;
  518. }
  519. var custContactNumber = custContactNumber;
  520. var custEmailAdress = Cust_Email;
  521. var instance = this;
  522. instance.fileCacheHelper.loadJsFiles(['apps/transact/managers/subscriptions/subscriptionmanager.js', 'settings/settings.js', 'platform/core/infos/status.js'], function () {
  523. var retunrUrl = window.location.origin + '/#/paymentorder/order_id ={order_id}/order_token={order_token}';
  524. var dt = new Date();
  525. dt.setDate(dt.getDate() + 5);
  526. customerdetails = {
  527. CustomerId: String(customerUserId),
  528. CustomerEmail: custEmailAdress,
  529. CustomerPhone: custContactNumber,
  530. };
  531. SubcribeUserRegistrations.instance.data.push({
  532. OrderAmount: invoiceamount,
  533. OrderCurrency: "INR",
  534. customer_details: customerdetails,
  535. order_meta: {
  536. "ReturnUrl": retunrUrl
  537. },
  538. OrderExpiryTime: dt
  539. });
  540. Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().createGateWayOrder(instance.data[0]).then(function (response) {
  541. var res = response.result;
  542. if (res.status === Unibase.Data.Status.Error) {
  543. instance.navigationHelper.hideLoading();
  544. MessageHelper.Instance().showError(res.message, "error_message");
  545. }
  546. if (response.result != null) {
  547. var res = response.result;
  548. var url = res.payment_link;
  549. subcribeuserobj = {
  550. SubscriptionsUserId: customerUserId,
  551. OrderId: res.order_id,
  552. OrderToken: res.order_token,
  553. TotalAmount: invoiceamount
  554. };
  555. var paymentDetails = {};
  556. paymentDetails = {
  557. OrderId: res.order_id,
  558. OrderToken: res.order_token,
  559. TenureId: Number(SubcribeUserRegistrations.instance.Tenureid),
  560. TotalAmount: invoiceamount,
  561. };
  562. var obj = {};
  563. if (PaymentStatus == true) {
  564. obj = {
  565. SubscriptionsUserId: customerUserId,
  566. PaymentDetails: paymentDetails
  567. };
  568. }
  569. instance.fileCacheHelper.loadJsFile('apps/transact/managers/subscriptions/subscriptionmanager.js', function () {
  570. if (PaymentStatus == true) {
  571. Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().SaveSubscriptionsUserInfo(subcribeuserobj).then(function (response) {
  572. var savinfo = response.result;
  573. instance.navigationHelper.hideLoading();
  574. window.open(url, "_self");
  575. });
  576. }
  577. });
  578. }
  579. });
  580. });
  581. }
  582. static Instance() {
  583. if (this.instance === undefined) {
  584. this.instance = new SubcribeUserRegistrations();
  585. }
  586. return this.instance;
  587. }
  588. }
  589. Subscriptions.SubcribeUserRegistrations = SubcribeUserRegistrations;
  590. })(Subscriptions = Controls.Subscriptions || (Controls.Subscriptions = {}));
  591. })(Controls = Transact.Controls || (Transact.Controls = {}));
  592. })(Transact = Apps.Transact || (Apps.Transact = {}));
  593. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  594. })(Bizgaze || (Bizgaze = {}));