internal static OTA_AirBookRQRequest CreateAirBookRequest(SupplierInfo supplierInfo, AirItinerary airItinerary, List<Passenger> passengers, List<Charge> charges, Account account) { OTA_AirBookRQRequest request = new OTA_AirBookRQRequest(); request.IsOnlyMockBooking = supplierInfo.IsOnlyMockBooking; request.IsMockEnabled = supplierInfo.IsMockEnabled; request.MessageHeader = CreateMessageHeader(supplierInfo, "OTA_AirBookRQ", "Create PNR"); request.Security = CreateSecurityHeader(supplierInfo, airItinerary[Constants.SecurityToken]); request.OTA_AirBookRQ = new OTA_AirBookRQ(); request.OTA_AirBookRQ.Version = 1.0m; request.OTA_AirBookRQ.TransactionStatusCode = TransactionStatusCode.End; request.OTA_AirBookRQ.TransactionStatusCodeSpecified = true; List<AirTravelerType> travellers = new List<AirTravelerType>(); int infantsCnt = passengers.GetInfantCount(); foreach (Passenger passenger in passengers) { AirTravelerType traveller = GetTravellerDetails(passenger, account, (travellers.Count).ToString()); travellers.Add(traveller); } List<AirTravelerType> adultTravellers = travellers.FindAll(tv => string.Equals(tv.PassengerTypeCode, "ADT")); for (int i = 0; i < adultTravellers.Count;i++) { if (i == 0) { adultTravellers[i].Telephone = new AirTravelerTypeTelephone[] { new AirTravelerTypeTelephone() { RPH = "1", PhoneLocationType = "M", PhoneNumber = account.Mobile, Operation = ActionType.Add, OperationSpecified = true } }; adultTravellers[i].Email = new Email[] { new Email() { RPH = "1", Value = account.Email, Operation = ActionType.Add, OperationSpecified = true } }; } if ((i + 1) <= infantsCnt) adultTravellers[i].AccompaniedByInfant = true; } if(string.Equals(supplierInfo.Mode,"Test")) { adultTravellers[0].PersonName.GivenName[0] = "ECOMM"; adultTravellers[0].PersonName.Surname = "ECOMMERCE"; } request.OTA_AirBookRQ.TravelerInfo = new TravelerInfoType(); request.OTA_AirBookRQ.TravelerInfo.AirTraveler = travellers.ToArray(); request.OTA_AirBookRQ.TravelerInfo.SpecialReqDetails = new SpecialReqDetailsType[1]; request.OTA_AirBookRQ.TravelerInfo.SpecialReqDetails[0] = new SpecialReqDetailsType(); return request; }
public string GetPostData(string transactionId, decimal toChargeAmount, string productInfo, Account userAccount, Address contactAddress, string voucherCode) { string url = _providerDetails.PostUrl; const string method = "post"; const string formName = "form1"; string returnUrl = ConfigSettings.PaymentReturnUrl; //key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||<SALT> string input = _providerDetails.MerchantId + "|" + transactionId + "|" + toChargeAmount + "|" + productInfo + "|" + userAccount.FirstName + "|" + userAccount.Email + "|" + _providerDetails.Name + "||||||||||" + _providerDetails.AdditionalInfo["SALT"]; var response = new StringBuilder(); string secureHash = Generatehash512(input); var formFields = new NameValueCollection { {"key", _providerDetails.MerchantId}, {"txnid", transactionId}, {"amount", toChargeAmount.ToString()}, {"productinfo", productInfo}, {"Firstname", userAccount.FirstName}, {"Lastname", userAccount.LastName}, {"address1", contactAddress.AddressLine1}, {"address2", contactAddress.AddressLine2}, {"City", contactAddress.City}, {"State", contactAddress.State}, {"Country", contactAddress.Country}, {"Zipcode", contactAddress.ZipCode}, {"Email", userAccount.Email}, {"phone", userAccount.Mobile}, {"udf1", _providerDetails.Name}, {"surl", returnUrl}, {"furl", returnUrl}, {"curl", returnUrl}, {"Hash", secureHash}, {"Pg", "CC"}, }; response.Append("<html><head>"); response.Append(string.Format("</head><body onload=\"document.{0}.submit()\">", formName)); response.Append(string.Format("<form name=\"{0}\" method=\"{1}\" action=\"{2}\" >", formName, method, url)); for (int i = 0; i < formFields.Keys.Count; i++) { response.Append(string.Format("<input name=\"{0}\" type=\"hidden\" value=\"{1}\">", formFields.Keys[i], formFields[formFields.Keys[i]])); } response.Append("</form>"); response.Append("</body></html>"); return response.ToString(); }
public string Book(AirItinerary airItinerary, List<Passenger> passengers, List<Charge> charges, Account account, out List<string> ticketNumbers) { using (new ApplicationContextScope(new ApplicationContext())) { ApplicationContext.Current.Items["SessionId"] = _supplierInfo["SessionId"]; string pnr = string.Empty; ticketNumbers = new List<string>(); try { //1. Get the securityToken airItinerary[Constants.SecurityToken] = CreateJetSession(); //2. Sell the flight segment SellFlightSegments(airItinerary); //3. Add passenger information JetConnector connector = new JetConnector(_supplierInfo.GetAirBookService()); JetModel.OTA_AirBookRQRequest bookRequest = RequestTranslators.CreateAirBookRequest(_supplierInfo, airItinerary, passengers, charges, account); JetModel.OTA_AirBookRQResponse bookResponse = connector.DoTransaction<JetModel.OTA_AirBookRQRequest, JetModel.OTA_AirBookRQResponse>( bookRequest); pnr = ResponseTranslators.GetPnrFromBookResponse(bookResponse, airItinerary); //4.Get Ticket Number try { connector._url = _supplierInfo.GetTicketService(); JetModel.AirTicketRQRequest ticketRequest = RequestTranslators.CreateAitTicketRequest(_supplierInfo, airItinerary, pnr); JetModel.AirTicketRQResponse ticketResponse = connector.DoTransaction<JetModel.AirTicketRQRequest, JetModel.AirTicketRQResponse>( ticketRequest); ticketNumbers = ResponseTranslators.GetTicketNumbers(ticketResponse, airItinerary); } catch (Exception ex) { Logger.LogException(ex, Source, "Ticket", Severity.Major); } } catch (Exception ex) { Logger.LogException(ex, Source, "Book", Severity.Major); } finally { Task.Factory.StartNew(() => CloseJetSession(airItinerary[Constants.SecurityToken], _supplierInfo["SessionId"])); } return pnr; } }
public bool VerifyMobile(Account account, string verificationCode) { if (account != null) { ICodeVerificationDataProvider codeVerificationDataProvider = CodeVerificationDataProviderFactory.CreateCodeVerificationDataProvider(); if (codeVerificationDataProvider.IsValid(account.AccountId, verificationCode, Type)) { codeVerificationDataProvider.Remove(account.AccountId, Type); return true; } } return false; }
public bool IsValidResponse(decimal amountToCharge, NameValueCollection variables, Account userAccount, string voucherCode, out string errorMessage, out Charge charge) { errorMessage = string.Empty; charge = new Charge { Amount = amountToCharge, Currency = "INR", CustomerPaymentId = "bank_ref_num", ExternalReferenceId = "mihpayid", InternalReferenceId = "txnid", IsRefund = false, Provider = "PayU", Type = "PG_TYPE" }; return true; }
public void ResendEmailVerification(Account account) { string verificationCode = GetVerificationCode(account); try { string contentBody = EmailTemplateHelper.EmailVerificationTemplate; contentBody = contentBody.Replace(EmailTemplateHelper.Keys.Key_EmailVerification_Url, string.Format(ConfigHelper.EmailVerificationBaseUrl, account.Email, verificationCode)); SendEmail(ConfigHelper.CustomerCareEmail, account.Email, "UdChalo Email Verification.", contentBody, "ResendEmailVerification"); } catch (Exception ex) { Logger.LogException(ex, Source, "ResendEmailVerification", Severity.Critical); } }
public void SendPaymentConfirmationEmail(string requestId, decimal paymentAmount, Account account, int passengerCount, string paymentRefId) { try { var contentBody = EmailTemplateHelper.PaymentConfirmationTemplate; contentBody = contentBody.Replace(EmailTemplateHelper.Keys.Key_Amount, paymentAmount.ToString()); contentBody = contentBody.Replace(EmailTemplateHelper.Keys.Key_RequestId, requestId); contentBody = contentBody.Replace(EmailTemplateHelper.Keys.Key_Email, account.Email); contentBody = contentBody.Replace(EmailTemplateHelper.Keys.Key_User, string.Format("{0} {1}", account.FirstName, account.LastName)); contentBody = contentBody.Replace(EmailTemplateHelper.Keys.Key_Mobile, account.Mobile); contentBody = contentBody.Replace(EmailTemplateHelper.Keys.Key_Travellers, passengerCount.ToString()); contentBody = contentBody.Replace(EmailTemplateHelper.Keys.Key_PaymentReferenceId, paymentRefId); SendEmail(ConfigHelper.CustomerCareEmail, ConfigHelper.SupportUdChaloEmail, "Payment Successful!", contentBody, "SendPaymentConfirmationEmail"); } catch (Exception ex) { Logger.LogException(ex, Source, "SendPaymentConfirmationEmail", Severity.Critical); } }
public void ResendMobileCode(Account account) { string verificationCode = VerificationCodeGenerator.GenerateNewVerificationCode(); bool isSuccessful = false; if (!Configuration.IsMobileMock) { var helper = new RequestResponseBuilder(); string url = string.Format( Configuration.MobileVerificationBaseUrl + Configuration.MobileVerificationFormat, account.Mobile, verificationCode); WebRequest request = helper.CreateRequest<WebRequest>(url, null); string responseString; WebResponse response = helper.GetResponse(request, out responseString); if (response != null && !string.IsNullOrEmpty(responseString)) { isSuccessful = true; } } else { verificationCode = "123456"; isSuccessful = true; } if (isSuccessful) { ICodeVerificationDataProvider codeVerificationDataProvider = CodeVerificationDataProviderFactory.CreateCodeVerificationDataProvider(); if (codeVerificationDataProvider.Remove(account.AccountId, Type)) { codeVerificationDataProvider.SaveNewCode(account.AccountId, verificationCode, Type); } } }
public bool Book(string requestId, AirItinerary airItinerary, List<Passenger> passengers, List<Charge> charges, Account account, out string errorMessage, out Booking booking) { errorMessage = string.Empty; var mode = ConfigSettings.SupplierMode; booking = null; try { var supplierInfo = SupplierDataProviderFactory.GetSupplierDataProvider().GetSupplier(airItinerary.Provider, mode); var supplier = GetSupplier(supplierInfo); if (supplier != null) { List<string> ticketNumbers; string pnr = supplier.Book(airItinerary, passengers, charges, account, out ticketNumbers); if (!string.IsNullOrEmpty(pnr)) { var bookingDataProvider = BookingDataProviderFactory.CreateBookingDataProvider(); booking = CreateBooking(airItinerary, passengers, charges, pnr, requestId, account.AccountId, ticketNumbers); booking.TicketNumbers = ticketNumbers; return bookingDataProvider.CreateBooking(booking); } } } catch (Exception exception) { errorMessage = exception.Message; Logger.LogException(exception, "FlightProvider", "Price", Severity.Major); } return false; }
public void SetEmailActivated(Account account) { }
public void MyTestInitialize() { if (accountId == null) { accountId = _accountDataProvider.GetAccountId(email); if (!string.IsNullOrEmpty(accountId)) account = _accountDataProvider.GetAccount(accountId); } if (accountId == null) { account = _accountDataProvider.CreateAccount(email, firstName, lastName, mobile, hashPwd); accountId = account.AccountId; } }
private void ValidateAccount(Account actual) { Assert.AreEqual(actual.Email, email); Assert.AreEqual(actual.FirstName, firstName); Assert.AreEqual(actual.LastName, lastName); Assert.AreEqual(actual.Mobile, mobile); }
public string GetPostData(string transactionId, decimal toChargeAmount, string productInfo, Account userAccount, Address contactAddress, string voucherCode) { return string.Empty; }
public bool Book(string requestId, AirItinerary airItinerary, List<Passenger> passengers, List<Charge> charges, Account account, out string errorMessage, out Booking booking) { errorMessage = null; booking = null; return true; }
public void MyTestInitialize() { if (accountId == null) { accountId = _accountDataProvider.GetAccountId(email); } if (accountId == null) { accountId = _accountDataProvider.CreateAccount(email, firstName, lastName, mobile, hashPwd).AccountId; } account = _accountDataProvider.GetAccount(accountId); }
public void SendRegistrationEmail(Account account, string password) { string verificationCode = GetVerificationCode(account); try { string contentBody = EmailTemplateHelper.RegistrationTemplate; contentBody = contentBody.Replace(EmailTemplateHelper.Keys.Key_User, account.FirstName); contentBody = contentBody.Replace(EmailTemplateHelper.Keys.Key_Email, account.Email); contentBody = contentBody.Replace(EmailTemplateHelper.Keys.Key_Password, password); contentBody = contentBody.Replace(EmailTemplateHelper.Keys.Key_Year, DateTime.Today.Year.ToString()); contentBody = contentBody.Replace(EmailTemplateHelper.Keys.Key_EmailVerification_Url, string.Format(ConfigHelper.EmailVerificationBaseUrl, account.Email, verificationCode)); SendEmail(ConfigHelper.CustomerCareEmail, account.Email, "Welcome to udChalo", contentBody, "SendRegistrationEmail"); } catch (Exception ex) { Logger.LogException(ex, Source, "SendRegistrationEmail", Severity.Critical); } }
public string GetPostData(string transactionId, decimal toChargeAmount, string productInfo, Account userAccount, Address contactAddress, string voucherCode) { string url = _providerDetails.PostUrl; const string method = "post"; const string formName = "form1"; string returnUrl = ConfigSettings.PaymentReturnUrl + "?DR={DR}"; string input = _providerDetails.MerchantSecretKey + "|" + _providerDetails.MerchantId + "|" + toChargeAmount + "|" + transactionId + "|" + returnUrl + "|" + _providerDetails.Mode; var response = new StringBuilder(); var md5 = MD5.Create(); byte[] inputBytes = Encoding.ASCII.GetBytes(input); byte[] hashBytes = md5.ComputeHash(inputBytes); var sb = new StringBuilder(); for (int i = 0; i < hashBytes.Length; i++) { sb.Append(hashBytes[i].ToString("X2")); } string secureHash = sb.ToString(); var formFields = new NameValueCollection { {"account_id", _providerDetails.MerchantId}, {"reference_no", transactionId}, {"amount", toChargeAmount.ToString()}, {"description", productInfo}, {"name", userAccount.FirstName + " " + userAccount.LastName}, {"address", contactAddress.AddressLine1}, {"city", contactAddress.City}, {"state", contactAddress.State}, {"postal_code", contactAddress.ZipCode}, {"country", contactAddress.Country}, {"email", userAccount.Email}, {"phone", userAccount.Mobile}, {"ship_name", userAccount.FirstName + " " + userAccount.LastName}, {"ship_address", contactAddress.AddressLine1}, {"ship_city", contactAddress.City}, {"ship_state", contactAddress.State}, {"ship_postal_code", contactAddress.ZipCode}, {"ship_country", contactAddress.Country}, {"ship_phone", userAccount.Mobile}, {"return_url", returnUrl}, {"mode", _providerDetails.Mode}, {"secure_hash", secureHash} }; response.Append("<html><head>"); response.Append(string.Format("</head><body onload=\"document.{0}.submit()\">", formName)); response.Append(string.Format("<form name=\"{0}\" method=\"{1}\" action=\"{2}\" >", formName, method, url)); for (int i = 0; i < formFields.Keys.Count; i++) { response.Append(string.Format("<input name=\"{0}\" type=\"hidden\" value=\"{1}\">", formFields.Keys[i], formFields[formFields.Keys[i]])); } response.Append("</form>"); response.Append("</body></html>"); return response.ToString(); }
public bool VerifyMobile(Account account, string verificationCode) { if (verificationCode == "123456") return true; return false; }
public void SetMobileVerified(Account account) { }
private static AirTravelerType GetTravellerDetails(Passenger passenger, Account account, string rph) { int age = passenger.GetAge(); string paxCode = "CNN"; if(age < 2) paxCode = "INF"; else if(age >=12 ) paxCode = "ADT"; string title; if (string.Equals(paxCode, "CNN")) title = string.Equals(passenger.Gender, "Male") ? "Master" : "Miss"; else title = passenger.Title; AirTravelerType traveller = new AirTravelerType() { PassengerTypeCode = paxCode, PersonName = new PersonNameType() { NamePrefix = new string[] { title }, GivenName = new string[] { passenger.FirstName }, Surname = passenger.LastName }, BirthDateSpecified = true, BirthDate = passenger.DateOfBirth, TravelerRefNumber = new AirTravelerTypeTravelerRefNumber() { RPH = rph }, }; return traveller; }
public bool VerifyEmail(Account account, string emailCode) { try { if (account != null) { ICodeVerificationDataProvider codeVerificationDataProvider = CodeVerificationDataProviderFactory.CreateCodeVerificationDataProvider(); if (codeVerificationDataProvider.IsValid(account.AccountId, emailCode, Type)) { codeVerificationDataProvider.Remove(account.AccountId, Type); return true; } } } catch (Exception ex) { Logger.LogException(ex, Source, "VerifyEmail", Severity.Critical); } return false; }
private static string GetVerificationCode(Account account) { string verificationCode = VerificationCodeGenerator.GenerateNewVerificationCode(); ICodeVerificationDataProvider codeVerificationDataProvider = CodeVerificationDataProviderFactory.CreateCodeVerificationDataProvider(); codeVerificationDataProvider.SaveNewCode(account.AccountId, verificationCode, Type); return verificationCode; }
public Account UpdatePersonalInfo(Account account, out string errorMessage) { errorMessage = string.Empty; return account; }
public void SetEmailActivated(Account account) { if (account != null) { IAccountDataProvider accountDataProvider = AccountDataProviderFactory.CreateAccountDataProvider(); accountDataProvider.SetEmailActivated(account.Email); } }
public void ResendMobileCode(Account account) { }
public void SetMobileVerified(Account account) { if (account != null) { IAccountDataProvider accountDataProvider = AccountDataProviderFactory.CreateAccountDataProvider(); accountDataProvider.SetMobileVerified(account.Email); } }
public bool IsValidResponse(decimal amountToCharge, NameValueCollection variables, Account userAccount, string voucherCode, out string errorMessage, out Charge charge) { var providerResponse = string.Empty; charge = null; try { string dr = variables["DR"]; dr = dr.Replace(' ', '+'); var sQS = Base64Decode(dr); providerResponse = RC4.Decrypt(_providerDetails.MerchantSecretKey, sQS, false); errorMessage = string.Empty; } catch { errorMessage = "Invalid response received. Please try again later."; return false; } if (!string.IsNullOrEmpty(providerResponse)) { var response = HttpUtility.ParseQueryString(providerResponse); charge = new Charge { Amount = amountToCharge, Currency = "INR", CustomerPaymentId = response["TransactionID"], ExternalReferenceId = response["PaymentID"], InternalReferenceId = response["MerchantRefNo"], IsRefund = false, IsSuccess = response["ResponseCode"] == "0", Provider = "EBS", Type = response["PaymentMethod"], Mode = _providerDetails.Mode, }; if (response["ResponseCode"] == "0") return true; errorMessage = string.IsNullOrEmpty(response["ResponseMessage"]) ? "Payment failed. Transaction has been cancelled." : response["ResponseMessage"]; charge.ErrorMessage = errorMessage; } else { errorMessage = "Invalid response received. Please try again later."; } return false; }
public Account UpdatePersonalInfo(Account account, out string errorMessage) { errorMessage = string.Empty; IAccountDataProvider accountDataProvider = AccountDataProviderFactory.CreateAccountDataProvider(); if (accountDataProvider != null) { Account updatedAccount = accountDataProvider.UpdatePersonalInfo(account, out errorMessage); return updatedAccount; } return null; }
public void UpdatePersonalInfoTest() { IAuthenticationProvider authenticationProvider = new AuthenticationProvider(new HttpRuntimeCache()); ICaptchaProvider captchaProvider = new ReCaptchaProvider(); IEmailProvider emailProvider = new EmailProvider(); IMobileProvider mobileProvider = new MobileProvider(); var target = new AccountProvider(authenticationProvider, captchaProvider, emailProvider, mobileProvider); string errorMessage = null; var account = new Account(); account.FirstName = "Upcurve"; account.LastName = "Udchalo"; account.BillingAddress = new Address { Id = 0, AddressLine1 = "EON, Kharadi", AddressLine2 = "Tavisca Solutions, Pune", AddressType = AddressType.Billing, City = "Pune", Country = "IN", State = "Maharashtra", ZipCode = "4110001" }; Account updatedAccount = target.UpdatePersonalInfo(account, out errorMessage); Assert.IsTrue(updatedAccount != null); Assert.IsTrue(string.IsNullOrEmpty(errorMessage)); }
public bool IsValidResponse(decimal amountToCharge, NameValueCollection variables, Account userAccount, string voucherCode, out string errorMessage, out Charge charge) { //<SALT>|status||||||udf5|udf4|udf3|udf2|udf1|email|firstname|productinfo|amount|txnid|key charge = null; string input = _providerDetails.AdditionalInfo["SALT"] + "|" + variables["status"] + "||||||||||" + variables["udf1"] + "|" + userAccount.Email + "|" + userAccount.FirstName + "|" + variables["productInfo"] + "|" + amountToCharge.ToString("0.00") + "|" + variables["txnid"] + "|" + _providerDetails.MerchantId; var hash = Generatehash512(input); errorMessage = string.Empty; if (string.Equals(hash, variables["hash"])) { charge = new Charge { Amount = amountToCharge, Currency = "INR", CustomerPaymentId = string.IsNullOrEmpty(variables["cardnum"]) ? variables["bank_ref_num"] : variables["cardnum"], ExternalReferenceId = variables["mihpayid"], InternalReferenceId = variables["txnid"], IsRefund = false, Provider = "PayU", Type = variables["mode"] }; if (string.Equals(variables["status"], "SUCCESS", StringComparison.OrdinalIgnoreCase)) { charge.IsSuccess = true; UpdateVoucherCount(voucherCode); return true; } errorMessage = "Payment failed. Transaction has been cancelled."; } else { errorMessage = "Invalid response received. Please try again after login."; } return false; }