From aba3f7b40058f4e2cc8c7b7b0f65aa5e8207651a Mon Sep 17 00:00:00 2001 From: shakun Date: Thu, 5 Oct 2023 21:46:39 +0545 Subject: [PATCH 1/2] update profile KYC verified payment gateway --- Business/Mobile/MobileServices.cs | 355 ++++++++++++++---- Business/MobileV2/IMobileV2Business.cs | 4 + Business/MobileV2/MobileV2Business.cs | 48 ++- Business/SendMoney/SendMoneyBusiness.cs | 67 +++- Business/TPApi/NotifierV2.cs | 54 +++ Common/APIJsonResponse.cs | 1 + Common/Common.csproj | 3 + .../Model/BankTransfer/PendingStatusModel.cs | 13 + .../CustomerRegister/CustomerKYCModel.cs | 1 + Common/Model/Enum/Notifications.cs | 36 +- Common/Model/ExRateCalculateRequest.cs | 2 + Common/Model/ExRateResponse.cs | 81 ++++ Common/Model/LoginResponse.cs | 4 + Common/Model/MobileV2/CustomerProfileV2.cs | 30 ++ Common/Model/Notification/SMSRequestModel.cs | 21 ++ Common/Model/PasswordReset.cs | 1 + Common/Model/RequestOTP/RequestOTPModel.cs | 2 + Common/Model/RewardFee.cs | 12 + Common/Model/StaticData.cs | 5 + Common/Model/TransactionResponse.cs | 13 + Common/Model/UserDetails.cs | 22 ++ Common/RestApiClient.cs | 7 +- JsonRx/Api/CustomerController.cs | 1 + JsonRx/Api/SendMoneyController.cs | 115 +++--- JsonRx/ApiV3/MobileV3Controller.cs | 64 ++++ JsonRx/ApiV3/SendTransactionController.cs | 34 +- .../TokenAuthenticationAttribute.cs | 4 +- JsonRx/Config/ResponseMsg.json | 26 +- JsonRx/Helper/Util.cs | 46 +++ JsonRx/Web.config | 2 + Repository/Dao.cs | 4 + Repository/Mobile/IMobileServicesRepo.cs | 3 +- Repository/Mobile/MobileServicesRepo.cs | 174 +++++---- Repository/MobileV2/IMobileV2Repo.cs | 1 + Repository/MobileV2/MobileV2Repo.cs | 10 + 35 files changed, 962 insertions(+), 304 deletions(-) create mode 100644 Common/Model/BankTransfer/PendingStatusModel.cs create mode 100644 Common/Model/ExRateResponse.cs create mode 100644 Common/Model/Notification/SMSRequestModel.cs create mode 100644 Common/Model/UserDetails.cs diff --git a/Business/Mobile/MobileServices.cs b/Business/Mobile/MobileServices.cs index 381b3f3..7cb2233 100644 --- a/Business/Mobile/MobileServices.cs +++ b/Business/Mobile/MobileServices.cs @@ -32,6 +32,7 @@ using Repository; using System.Configuration; using Business.TrustDoc; using Business.Addressy; +using System.Text; namespace Business.Mobile { @@ -152,42 +153,97 @@ namespace Business.Mobile if (jsonRx.ErrorCode == "0") { - // string msgBody = "Dear Customer, your OTP code is: " + requestOTPModel.OTP + " (Valid for " + jsonRx.Extra + " mins)."; + bool emailSent = false; + bool smsSent = false; if (requestOTPModel.userId.IsValidEmail()) { - if (!string.IsNullOrEmpty(jsonRx.Extra2) && jsonRx.Extra2.Equals("100")) + if (!string.IsNullOrEmpty(jsonRx.ErrorCode) && jsonRx.ErrorCode.Equals("0")) { List bodyMappings = new List(); + bodyMappings.Add(new Notify.Mapping() { SValue = "CustomerName", SText = jsonRx.Extra }); bodyMappings.Add(new Notify.Mapping() { SValue = "OTP_CODE", SText = requestOTPModel.OTP }); bodyMappings.Add(new Notify.Mapping() { SValue = "TYPE", SText = requestOTPModel.requestFor.Equals("REGISTER") ? "customer" : "receiver" }); - - SendNotificationRequest request = new SendNotificationRequest() + try { - IsBulkNotification = false, - UserName = requestOTPModel.userId, - ControlNo = requestOTPModel.receiverId, - ProviderId = "RequestOTP", - Template = Common.Model.Enum.NotifyTemplate.OTP_EMAIL, - Recipients = new List() + SendNotificationRequest request = new SendNotificationRequest() + { + IsBulkNotification = false, + UserName = requestOTPModel.userId, + ControlNo = requestOTPModel.receiverId, + ProviderId = "REQUESTOTP_EMAIL", + Template = Common.Model.Enum.NotifyTemplate.OTP_EMAIL, + Recipients = new List() + { + new RecipientViewModel() + { + NotificationContent = new NotificationDTO() { + Body = JsonConvert.SerializeObject(bodyMappings), + //Title will be set by mapping json + }, + Address= requestOTPModel.userId, + DeviceType = requestOTPModel.DeviceType, + } } + }; + + + Log.Debug("SendNotification.EMAIL | REQUEST : " + JsonConvert.SerializeObject(request)); + + var jsonRx1 = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL); + + Log.Debug("SendNotification.EMAIL | RESPONSE : " + JsonConvert.SerializeObject(jsonRx1)); + emailSent = true; + } + catch (Exception emailException) { - new RecipientViewModel() - { - NotificationContent = new NotificationDTO() - { - Body = JsonConvert.SerializeObject(bodyMappings), - //Title will be set by mapping json - }, - Address= requestOTPModel.userId, - DeviceType = requestOTPModel.DeviceType - } + Log.Error("Error sending email", emailException); } - }; - jsonRx = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL); + try + { + string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":sendSms"; + + string mobileNum = jsonRx.Extra2; + var mobNum = getSenderFormattedNumber(mobileNum); + SendSMSApiService _sendAPI = new SendSMSApiService(); + + StringBuilder s = new StringBuilder(); + s.AppendLine($"Dear { jsonRx.Extra}"); + s.AppendLine($"Your OTP code for Customer Registration is {requestOTPModel.OTP }."); + s.AppendLine("Regards, IME London"); + + SMSRequestModel _req = new SMSRequestModel + { + ProviderId = "onewaysms", + MobileNumber = mobileNum, + SMSBody = s.ToString(), + ProcessId = ProcessId.Substring(ProcessId.Length - 40, 40), + RequestedBy = requestOTPModel.userId, + UserName = requestOTPModel.userId, + method = "send", + ControlNo = "", // GetControlNo() + }; + + Log.Debug("SendNotification.SMS | REQUEST : " + JsonConvert.SerializeObject(_req)); + + APIJsonResponse _resp = _sendAPI.SMSTPApi(_req); + + Log.Debug("SendNotification.SMS | RESPONSE : " + JsonConvert.SerializeObject(_resp)); + + smsSent = true; + } + catch (Exception smsException) + { + Log.Error("Error sending SMS", smsException); + } + if (emailSent || smsSent) + { + jsonRx.ErrorCode = "0"; + jsonRx.SetResponse("0", "OTP has been Sent."); + return jsonRx; + } } - else - Log.Debug("RequestOTP | 103 : " + JsonConvert.SerializeObject(jsonRx)); + } else @@ -196,7 +252,6 @@ namespace Business.Mobile var map = Utilities.GetLanguageMapping(RESPONSE_MSG.OLD_USER_REGISTER_FAIL_11.ToString(), lang); return new JsonRxResponse { ErrorCode = jsonRx.ErrorCode, Msg = map.Message }; - ; } } @@ -210,6 +265,41 @@ namespace Business.Mobile return jsonRx; } } + private string getSenderFormattedNumber(string number) + { + string finalNo = number; + if (!number.Contains("+44")) + { + string mobileFirst = number.Substring(0, 1); + if (mobileFirst == "0") + { + if (number.Length == 11) + { + finalNo = "+44" + number.Substring(1, number.Length - 1); + return finalNo; + } + else if (number.Length < 11) + { + finalNo = $"+44{number}"; + } + } + else if (number.Substring(0, 1) != "0" && number.Length == 10) + { + finalNo = $"+44{number}"; + } + } + else if (number.Contains("+44")) + { + string MobN = number.Substring(4, 1); + if (MobN == "0" && number.Length > 14) + { + finalNo = number.Remove(4, 1); + } + } + if (!finalNo.Substring(0, 1).Contains("+")) + finalNo = $"+{finalNo}"; + return finalNo; + } public JsonRxResponse VerifyIdNumber(IDValidateModel iDValidate) { @@ -236,6 +326,45 @@ namespace Business.Mobile jsonRx = _requestServices.SubmitOTP(requestOTPModel); Log.Debug("SubmitOTP | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx)); + if (jsonRx.ErrorCode.Equals("0")) + { + string email = requestOTPModel.userId; + UserDetails userDetails = _requestServices.GetUserDetails(email); + + List bodyMappings = new List(); + + bodyMappings.Add(new Notify.Mapping() { SValue = "CustomerName", SText = userDetails.FullName }); + bodyMappings.Add(new Notify.Mapping() { SValue = "CustomerId", SText = userDetails.CustomerId.ToString() }); + bodyMappings.Add(new Notify.Mapping() { SValue = "UserId", SText = userDetails.MembershipId }); + bodyMappings.Add(new Notify.Mapping() { SValue = "FirstName", SText = userDetails.FirstName }); + bodyMappings.Add(new Notify.Mapping() { SValue = "MiddleName", SText = userDetails.MiddleName }); + bodyMappings.Add(new Notify.Mapping() { SValue = "LastName", SText = userDetails.LastName }); + bodyMappings.Add(new Notify.Mapping() { SValue = "MobileNo", SText = userDetails.Mobile }); + bodyMappings.Add(new Notify.Mapping() { SValue = "Address", SText = userDetails.Address }); + bodyMappings.Add(new Notify.Mapping() { SValue = "EMAIL_ID", SText = userDetails.Email }); + bodyMappings.Add(new Notify.Mapping() { SValue = "RegisteredDate", SText = userDetails.RegisteredDate.ToString("dd/MM/YYYY") }); + + SendNotificationRequest request = new SendNotificationRequest() + { + IsBulkNotification = false, + UserName = userDetails.Email, + ProviderId = "BasicRegistration", + NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(), + Template = Common.Model.Enum.NotifyTemplate.BASIC_REGISTRATION_EMAIL, + Recipients = new List() + { + new RecipientViewModel() + { + NotificationContent = new NotificationDTO() { + Body = JsonConvert.SerializeObject(bodyMappings), + //Title will be set by mapping json + }, + Address= userDetails.Email + } + } + }; + jsonRx = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL); + } return jsonRx; } @@ -281,7 +410,7 @@ namespace Business.Mobile RequestedBy = "mobile", SAgent = 0, SBranch = Convert.ToInt32(GetStatic.ReadWebConfig("sBranch", "")), - //SchemeId = m.schemeId, + SchemeId = m.schemeId, SCountry = Convert.ToInt32(m.sCountry == "" || m.sCountry == null ? "0" : m.sCountry), SCurrency = m.sCurrency, ServiceType = m.serviceType, @@ -522,6 +651,10 @@ namespace Business.Mobile mobile = httpRequest["mobile"], additionalAddress = httpRequest["additionalAddress"], idType = httpRequest["idType"], + idNumber = httpRequest["IdNumber"] != null ? httpRequest["IdNumber"] : "", + idIssuingCountry = httpRequest["IdIssuedCountry"] != null ? httpRequest["IdIssuedCountry"] : "", + idStartDate = httpRequest["idStartDate"] != null ? httpRequest["idStartDate"] : "", + idExpiryDate = httpRequest["IdEndDate"] != null ? httpRequest["IdEndDate"] : "", additionalIdType = httpRequest["additionalIdType"], employeerName = httpRequest["employeerName"], occupation = httpRequest["occupation"], @@ -548,8 +681,6 @@ namespace Business.Mobile } - - if (!string.IsNullOrEmpty(custKyc.RegistrationType) && custKyc.RegistrationType.Equals("EKYC")) { isKyc = true; @@ -564,6 +695,8 @@ namespace Business.Mobile // isBackRequired = id["isBackRequired"].ToString(); // } //} + + Log.Debug($"RegisterKYC | httpRequest : {httpRequest.Params}"); Log.Debug($"RegisterKYC | REQUEST : { JsonConvert.SerializeObject(custKyc)} | Files: { httpRequest.Files.Count}"); @@ -882,33 +1015,53 @@ namespace Business.Mobile //} - //if (string.IsNullOrEmpty(kyc.otherOccupation) && string.IsNullOrEmpty(kyc.occupation)) - //{ - // enumString = RESPONSE_MSG.VALIDATE_FORM_2.ToString(); - // var map = Utilities.GetLanguageMapping(enumString, lang); - // jsonRx.SetResponse("1", map.Message); + if (string.IsNullOrEmpty(kyc.otherOccupation) && string.IsNullOrEmpty(kyc.occupation)) + { + enumString = RESPONSE_MSG.VALIDATE_FORM_2.ToString(); + var map = Utilities.GetLanguageMapping(enumString, lang); + jsonRx.SetResponse("1", map.Message); + + return jsonRx; + } + else if (string.IsNullOrEmpty(kyc.occupation)) + { + if (string.IsNullOrEmpty(kyc.otherOccupation)) + { + enumString = RESPONSE_MSG.VALIDATE_FORM_9.ToString(); + var map = Utilities.GetLanguageMapping(enumString, lang); + jsonRx.SetResponse("1", map.Message); + + return jsonRx; + } + } + //if (string.IsNullOrEmpty(kyc.idNumber)) + //{ + + // jsonRx.SetResponse("1", "Id number is required"); // return jsonRx; //} - //else if (string.IsNullOrEmpty(kyc.occupation)) + + + //if (string.IsNullOrEmpty(kyc.idExpiryDate)) //{ - // if (string.IsNullOrEmpty(kyc.otherOccupation)) - // { - // enumString = RESPONSE_MSG.VALIDATE_FORM_9.ToString(); - // var map = Utilities.GetLanguageMapping(enumString, lang); - // jsonRx.SetResponse("1", map.Message); - - // return jsonRx; - // } + + // jsonRx.SetResponse("1", "IdExpiryDate is required"); + // return jsonRx; //} + //if (string.IsNullOrEmpty(kyc.idStartDate)) + //{ - //if (string.IsNullOrEmpty(kyc.monthlyIncome)) + // jsonRx.SetResponse("1", "Idissue Date is required"); + // return jsonRx; + //} + //if (string.IsNullOrEmpty(kyc.idIssuingCountry)) //{ - // enumString = RESPONSE_MSG.VALIDATE_FORM_3.ToString(); - // var map = Utilities.GetLanguageMapping(enumString, lang); - // jsonRx.SetResponse("1", map.Message); + + // jsonRx.SetResponse("1", "idIssuingCountry is required"); // return jsonRx; //} + //if (string.IsNullOrEmpty(kyc.additionalAddress)) //{ // enumString = RESPONSE_MSG.VALIDATE_FORM_4.ToString(); @@ -1790,32 +1943,47 @@ namespace Business.Mobile if (res.ErrorCode.Equals("0")) { - _trustDocBusiness.CompareData(new TrustDocRequest() { birth = res.Extra2, name = res.Msg }, res.Extra3, username, res.Id); + // _trustDocBusiness.CompareData(new TrustDocRequest() { birth = res.Extra2, name = res.Msg }, res.Extra3, username, res.Id); + res.Msg = "Thank you for completing your profile. You can now start sending transactions"; - SendNotificationRequest request = new SendNotificationRequest() + SendNotificationRequest pushNotificationRequest = new SendNotificationRequest() { IsBulkNotification = false, UserName = username, ProcessId = Guid.NewGuid().ToString(), ProviderId = "CustomerInfoAgree", NotificationTypeId = NOTIFICATION_TYPE.PUSH_NOTIFICATION.ToString(), - Template = Common.Model.Enum.NotifyTemplate.NEW_REGISTER_WELCOME, Recipients = new List() { - new RecipientViewModel() { Address= res.Extra , NotificationContent = new NotificationDTO() } + new RecipientViewModel() { Address = res.Extra, NotificationContent = new NotificationDTO() } }, Language = Convert.ToString(CallContext.GetData(Constants.Language)) }; - Task.Run(() => NotifierV2.SendNotification(request, NOTIFICATION_TYPE.PUSH_NOTIFICATION)); + Task.Run(() => NotifierV2.SendNotification(pushNotificationRequest, NOTIFICATION_TYPE.PUSH_NOTIFICATION)); + //SendNotificationRequest emailNotificationRequest = new SendNotificationRequest() + //{ + // IsBulkNotification = false, + // UserName = username, + // ProcessId = Guid.NewGuid().ToString(), + // ProviderId = "CustomerInfoAgree", + // NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(), + // Template = Common.Model.Enum.NotifyTemplate.KYC_VERIFICATION_EMAIL, + // Recipients = new List() + // { + // new RecipientViewModel() { Address= res.Extra , NotificationContent = new NotificationDTO() } + // }, + // Language = Convert.ToString(CallContext.GetData(Constants.Language)) + //}; + //Task.Run(() => NotifierV2.SendNotification(emailNotificationRequest, NOTIFICATION_TYPE.EMAIL)); } Log.Debug("CustomerInfoAgree.Agree | DB RESPONSE : " + JsonConvert.SerializeObject(res)); } - else if (agreeYn.Equals("N")) - { - res = _requestServices.CustomerInfoAgree(username, "agree-manual"); + //else if (agreeYn.Equals("N")) + //{ + // res = _requestServices.CustomerInfoAgree(username, "agree-manual"); - Log.Debug("CustomerInfoAgree.Manual | DB RESPONSE : " + JsonConvert.SerializeObject(res)); - } + // Log.Debug("CustomerInfoAgree.Manual | DB RESPONSE : " + JsonConvert.SerializeObject(res)); + //} } @@ -1859,18 +2027,24 @@ namespace Business.Mobile if (res.ErrorCode == "0") { - List bodyMappings = new List(); - bodyMappings.Add(new Notify.Mapping() { SValue = "PASS_WORD", SText = randomPassword }); - - SendNotificationRequest request = new SendNotificationRequest() + try { - IsBulkNotification = false, - UserName = pwdReset.Username, - ProcessId = processId, - ProviderId = "ResetPassword", - NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(), - Template = Common.Model.Enum.NotifyTemplate.RESET_PASSWORD, - Recipients = new List() + + + List bodyMappings = new List(); + bodyMappings.Add(new Notify.Mapping() { SValue = "CustomerName", SText = res.Extra2 }); + bodyMappings.Add(new Notify.Mapping() { SValue = "EMAIL_ID", SText = pwdReset.Username }); + bodyMappings.Add(new Notify.Mapping() { SValue = "PASS_WORD", SText = randomPassword }); + + SendNotificationRequest request = new SendNotificationRequest() + { + IsBulkNotification = false, + UserName = pwdReset.Username, + ProcessId = processId, + ProviderId = "ResetPassword", + NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(), + Template = Common.Model.Enum.NotifyTemplate.RESET_PASSWORD_EMAIL, + Recipients = new List() { new RecipientViewModel() { @@ -1881,10 +2055,29 @@ namespace Business.Mobile Address= pwdReset.Username } } - }; + }; - res = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL); + string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":sendSms"; + SendSMSApiService _sendAPI = new SendSMSApiService(); + SMSRequestModel _req = new SMSRequestModel + { + ProviderId = "onewaysms", + MobileNumber = pwdReset.mobileNo, + SMSBody = Common.Model.Enum.NotifyTemplate.RESET_PASSWORD_EMAIL.ToString(), + ProcessId = ProcessId.Substring(ProcessId.Length - 40, 40), + RequestedBy = pwdReset.Username, + UserName = pwdReset.Username, + method = "send", + ControlNo = "", // GetControlNo() + }; + APIJsonResponse _resp = _sendAPI.SMSTPApi(_req); + res = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL); + } + catch (Exception ex) + { + Log.Error("ResetPassword.SendNotification", ex); + } var map = Utilities.GetLanguageMapping(RESPONSE_MSG.SEND_EMAIL_FOR_RESETPASSWORD_SUCCESS.ToString(), lang); return new JsonRxResponse { ErrorCode = "0", Msg = map.Message }; @@ -2750,11 +2943,10 @@ namespace Business.Mobile return jsonRx; } - else if (type == Common.Model.Config.MappingType.REWARD_POINT) { var response1 = _requestServices.GetRewardFee(customerId); - response1.PaymentOptions = new PaymentOptions() { Options = Utilities.GetPaymetMethods(), HeaderText="How do like to pay?" }; + response1.PaymentOptions = new PaymentOptions() { Options = GetPaymentMethods(), HeaderText = "How do like to pay?" }; if (response1 != null) { @@ -2813,6 +3005,27 @@ namespace Business.Mobile } } + + public List