public SystemController() { var apiKey = ConfigurationManager.AppSettings["PaymentGateways.Stripe.ApiKey"].ToString(); var apiEndPoint = ConfigurationManager.AppSettings["PaymentGateways.Stripe.ApiEndpoint"].ToString(); var smtpInfo = AppService.Current.DataContext.SMTPAccounts.Where(x => x.AccountName == "Primary").SingleOrDefault(); if (smtpInfo == null) { throw new ArgumentNullException("Primary SMTP Account info has not been configured."); } var smtpAccount = new SMTPAccount() { Username = smtpInfo.AccountUsername, Password = smtpInfo.AccountPassword, Server = smtpInfo.AccountServer, Port = smtpInfo.AccountPort.Value, UseSSL = smtpInfo.AccountUseSSL.Value, AuthenticationMode = smtpInfo.AccountAuthMode.Value, FromAddress = smtpInfo.AccountDefaultFromAddress, ReplyToAddress = smtpInfo.AccountDefaultReplyAddress }; var connectionString = ConfigurationManager.ConnectionStrings["CoreConnection"].ConnectionString; var recipient = ConfigurationManager.AppSettings["Payments.RBTRecipientAddress"].ToString(); SystemService = SystemService.Create(apiKey, apiEndPoint, smtpAccount, recipient, connectionString); }
public Mailer(SMTPAccount smtpAccount, string recipient) { if (smtpAccount == null) { throw new ArgumentNullException(nameof(smtpAccount)); } if (string.IsNullOrEmpty(recipient)) { throw new ArgumentNullException(nameof(recipient)); } SMTPAccount = smtpAccount; Recipient = recipient; }
public static SystemService Create(string apiKey, string apiEndPoint, SMTPAccount smtpAccount, string recipient, string connectionString) { return(new SystemService(new StripeForRBT(apiKey, apiEndPoint), new Mailer(smtpAccount, recipient), new TransactionLogger(connectionString))); }