|
|
@ -144,25 +144,27 @@ namespace Business.Mobile |
|
|
|
{ |
|
|
|
var lang = Convert.ToString(CallContext.GetData(Constants.Language)); |
|
|
|
JsonRxResponse jsonRx = new JsonRxResponse(); |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
requestOTPModel.OTP = Utilities.GenerateOTP(); //implement the logic to send OTP SMS in customers mobile.
|
|
|
|
requestOTPModel.OTP = Utilities.GenerateOTP(); |
|
|
|
jsonRx = _requestServices.RequestOTP(requestOTPModel); |
|
|
|
Log.Debug("GenerateOTP | RESPONSE : " + JsonConvert.SerializeObject(jsonRx)); |
|
|
|
|
|
|
|
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")) |
|
|
|
{ |
|
|
|
List<Notify.Mapping> bodyMappings = new List<Notify.Mapping>(); |
|
|
|
//bodyMappings.Add(new Notify.Mapping() { SValue = "CustomerName", SText = requestOTPModel.customerName });
|
|
|
|
bodyMappings.Add(new Notify.Mapping() { SValue = "CustomerName", SText = requestOTPModel.customerName }); |
|
|
|
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" }); |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
SendNotificationRequest request = new SendNotificationRequest() |
|
|
|
{ |
|
|
|
IsBulkNotification = false, |
|
|
@ -184,9 +186,19 @@ namespace Business.Mobile |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
jsonRx = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL); |
|
|
|
emailSent = true; |
|
|
|
} |
|
|
|
catch (Exception emailException) |
|
|
|
{ |
|
|
|
Log.Error("Error sending email", emailException); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":sendSms"; |
|
|
|
SendSMSApiService _sendAPI = new SendSMSApiService(); |
|
|
|
//GetSMSTextForTxn
|
|
|
|
SMSRequestModel _req = new SMSRequestModel |
|
|
|
{ |
|
|
|
ProviderId = "onewaysms", |
|
|
@ -199,23 +211,28 @@ namespace Business.Mobile |
|
|
|
ControlNo = "", // GetControlNo()
|
|
|
|
}; |
|
|
|
APIJsonResponse _resp = _sendAPI.SMSTPApi(_req); |
|
|
|
jsonRx = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL); |
|
|
|
smsSent = true; |
|
|
|
} |
|
|
|
catch (Exception smsException) |
|
|
|
{ |
|
|
|
Log.Error("Error sending SMS", smsException); |
|
|
|
} |
|
|
|
if (emailSent || smsSent) |
|
|
|
{ |
|
|
|
jsonRx.ErrorCode = "0"; |
|
|
|
jsonRx.SetResponse("0", "OTP has been verified."); |
|
|
|
return jsonRx; |
|
|
|
} |
|
|
|
else |
|
|
|
Log.Debug("RequestOTP | 103 : " + JsonConvert.SerializeObject(jsonRx)); |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
jsonRx.ErrorCode = "1"; |
|
|
|
var map = Utilities.GetLanguageMapping(RESPONSE_MSG.OLD_USER_REGISTER_FAIL_11.ToString(), lang); |
|
|
|
return new JsonRxResponse { ErrorCode = jsonRx.ErrorCode, Msg = map.Message }; |
|
|
|
|
|
|
|
; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
jsonRx.ErrorCode = jsonRx.ErrorCode == "103" ? "0" : jsonRx.ErrorCode;//103 = previous OTP was not expired so same was used
|
|
|
|
jsonRx.ErrorCode = jsonRx.ErrorCode == "103" ? "0" : jsonRx.ErrorCode; // 103 = previous OTP was not expired, so the same was used
|
|
|
|
return jsonRx; |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
@ -224,6 +241,7 @@ namespace Business.Mobile |
|
|
|
jsonRx.SetResponse("1", "Error occurred while calling RequestOTP."); |
|
|
|
return jsonRx; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|