private static void SendPaymentConfirmationMail(string sessionId, string authenticationId, Account userAccount) { var sessionProvider = SessionProviderFactory.GetSessionProvider(); string errorMessage; var sessionDataResponse = sessionProvider.GetSession(authenticationId, sessionId, out errorMessage); if (sessionDataResponse != null) { var emailProvider = EmailProviderFactory.GetEmailProvider(); var token = sessionDataResponse.Token; var requestId = string.Empty; var paxCount = 0; var paymentAmount = 0M; if (token != null) { paxCount = token.PassengersCount; requestId = token.RequestId; paymentAmount = token.PayableAmount; } else { paymentAmount = sessionDataResponse.ToPayAmount; if (sessionDataResponse.Request != null) { requestId = sessionDataResponse.Request.RequestId; if (sessionDataResponse.Request.Passengers != null) { paxCount = sessionDataResponse.Request.Passengers.Count; } } } emailProvider.SendPaymentConfirmationEmail(requestId, paymentAmount, userAccount.ToModel(), paxCount, sessionDataResponse.PaymentTransaction.InternalReferenceNumber); } }
public ValidatePaymentResponse ValidatePaymentResponse(string amountToCharge, string provider, string sessionId, List<KeyValue> variables, Account userAccount, string authenticationId, string voucherCode) { var paymentProvider = PaymentProviderFactory.GetPaymentProvider(provider); if (paymentProvider != null) { var nameValueCollection = new NameValueCollection(); foreach (var keyValue in variables) { nameValueCollection.Add(keyValue.Key, keyValue.Value); } string error; Core.Model.Charge charge; var success = paymentProvider.IsValidResponse(decimal.Parse(amountToCharge), nameValueCollection, userAccount.ToModel(), voucherCode, out error, out charge); if(success && string.IsNullOrEmpty(error)) { SendPaymentConfirmationMail(sessionId, authenticationId, userAccount); } return new ValidatePaymentResponse { ErrorMessage = error, IsSuccess = success, Charge = charge.ToDataContract() }; } return new ValidatePaymentResponse { ErrorMessage = "Provider not found.", IsSuccess = false }; }
public string GetPostData(string transactionId, string toChargeAmount, string productInfo, string sessionId, Account userAccount, Address contactAddress, string voucherCode) { IPaymentProvider paymentProvider = PaymentProviderFactory.GetPaymentProvider(); if (paymentProvider != null) { return paymentProvider.GetPostData(transactionId, decimal.Parse(toChargeAmount), productInfo, userAccount.ToModel(), contactAddress.ToModel(), voucherCode); } return string.Empty; }
public void UpdatePersonalInfo() { var account = new Account(); account.FirstName = "Upcurve"; account.LastName = "Udchalo"; account.BillingAddress = new Address { Id = 0, AddressLine1 = "EON, Kharadi", AddressLine2 = "Tavisca Solutions, Pune", AddressType = "Billing", City = "Pune", Country = "IN", State = "Maharashtra", ZipCode = "4110001" }; ChangePersonalInfoResponse response = LoginService.ChangePersonalInfo(_sessionId, TestUserAccount.AuthenticationId, account); Assert.IsNotNull(response, "Change EmailId response returns not successful"); Assert.IsTrue(response.IsSuccess, "Change EmailId failed"); }
public ChangePersonalInfoResponse ChangePersonalInfo(string sessionId, string authenticationId, Account account) { var response = new ChangePersonalInfoResponse { IsSuccess = true }; using (new ApplicationContextScope(new ApplicationContext())) { ApplicationContext.SetSessionId(sessionId); try { IAccountProvider accountProvider = AccountProviderFactory.GetAccountProvider(); IAuthenticationProvider authenticationProvider = AuthenticationProviderFactory.GetAuthenticationProvider(); IEmailProvider verificationProvider = EmailProviderFactory.GetEmailProvider(); Core.Model.Account authenticatedAccount = accountProvider.GetAccount(authenticationProvider.GetAccountId(authenticationId)); if (authenticatedAccount != null) { string errorMessage = null; authenticatedAccount.FirstName = account.FirstName; authenticatedAccount.LastName = account.LastName; var address = account.BillingAddress.ToModel(); if (address != null && authenticatedAccount.BillingAddress != null) { address.Id = authenticatedAccount.BillingAddress.Id; } authenticatedAccount.BillingAddress = address; Core.Model.Account updatedAccount = accountProvider.UpdatePersonalInfo(authenticatedAccount, out errorMessage); if (updatedAccount == null) { response.ErrorMessage = !string.IsNullOrEmpty(errorMessage) ? errorMessage : "Not able to save your information. Please retry with valid information."; response.IsSuccess = false; } } else { response.ErrorMessage = "Invalid Account or EmailId. Please retry with valid information."; response.IsSuccess = false; } } catch (Exception exception) { response.ErrorMessage = "Something is not quite right here. Please try again later."; response.IsSuccess = false; Logger.LogException(exception, Source, "ChangePersonalInfoResponse", Severity.Critical); } } return response; }
public ChangePersonalInfoResponse ChangePersonalInfo(string sessionId, string authenticationId, Account account) { using (new ApplicationContextScope(new ApplicationContext())) { ApplicationContext.SetSessionId(sessionId); try { var channelFactory = new WebChannelFactory<ILoginServiceRest>(Configuration.LoginServiceConfigurationName); ILoginServiceRest channel = channelFactory.CreateChannel(); if (channel is IContextChannel) using (new OperationContextScope(channel as IContextChannel)) { WebOperationContext.Current.OutgoingRequest.Headers.Add("X-MethodName", "ChangePersonalInfo"); return channel.ChangePersonalInfo(sessionId, authenticationId, account); } } catch (Exception exception) { Logger.LogException(exception, Source, "ChangePersonalInfo", Severity.Major); } } return null; }