public Result <List <Method> > CreateMethods(CreateMethods createMethods) { List <Method> methods = createMethods.Methods.Select(m => new Method(m.Creator, m.Name, m.ApplicationRate)).ToList(); MethodValidator methodValidator = new MethodValidator(); List <string> errors = new List <string>(); foreach (var method in methods) { var validationResult = methodValidator.Validate(method); if (!validationResult.IsValid) { errors.AddRange(validationResult.Errors.Select(e => e.ToString())); } } if (errors.Count() > 0) { return(Result.Fail <List <Method> >(string.Join(" ", errors))); } foreach (var method in methods) { method.SetId(++lastIdValue); methodsMemoryDatabase.Add(method); } return(Result.Ok <List <Method> >(methods)); }
/// <summary> /// Validates the debit card number against the BIN file /// </summary> /// <param name="debitCardNumber"></param> /// <returns></returns> public bool IsDebitCardNumberValid( [RequiredItem()][RegEx(@"^\d{12,19}$", RegexOptions.None)] string debitCardNumber) { //Validate the arguments MethodValidator validator = new MethodValidator( MethodBase.GetCurrentMethod(), debitCardNumber); validator.Validate(); return(_IsDebitCardNumberValid(debitCardNumber)); }
/// <summary> /// This method returns the telephone numbers for digital telephone service for a statement. /// </summary> /// <param name="accountNumber13"></param> /// <param name="phoneNumber"></param> /// <returns></returns> public string InquireStatementCode( [RequiredItem()][StringLength(13, 13)][CustomerAccountNumber()] string accountNumber13, [RequiredItem()][StringLength(4, 4)] string phoneNumber) { BillingLogEntry logEntry = new BillingLogEntry(eBillingActivityType.StatementCodeInquiry, accountNumber13, phoneNumber); using (Log log = CreateLog(logEntry)) { try { // validate the parameters. MethodValidator validator = new MethodValidator(MethodBase.GetCurrentMethod(), accountNumber13, phoneNumber); validator.Validate(); // convert the accountNumber. CustomerAccountNumber accountNumber = (CustomerAccountNumber)TypeDescriptor.GetConverter( typeof(CustomerAccountNumber)).ConvertFrom(accountNumber13); // get the siteid/sitecode information PopulateSiteInfo(accountNumber); logEntry.SiteId = this.SiteId; // use dal to get statement code string statementCode = null; DalAccount dalAccount = new DalAccount(); statementCode = dalAccount.GetStatementCode(SiteId, SiteCode, accountNumber.AccountNumber9, phoneNumber); // if no statement code is found throw ex if (statementCode == null || statementCode == string.Empty) { throw new InvalidAccountNumberException( string.Format(__noStatementCodeForAccountExceptionMessage, accountNumber.AccountNumber13, phoneNumber)); } return(statementCode.PadLeft(3, '0')); } catch (ValidationException ve) { logEntry.SetError(new ExceptionFormatter(ve).Format()); throw; } catch (BusinessLogicLayerException blle) { logEntry.SetError(new ExceptionFormatter(blle).Format()); throw; } catch (Exception e) { logEntry.SetError(new ExceptionFormatter(e).Format()); throw new UnexpectedSystemException(e); } } }
/// <summary> /// This method returns the account address information for the given Phone Number. /// </summary> /// <param name="phoneNumber10"></param> /// <returns></returns> public List <CustomerContactInformation> getAccountAddressesbyPhoneNumber( [RequiredItem()][StringLength(10, 10)][RegEx(@"\d{10}", RegexOptions.Compiled)] string phoneNumber10, bool getNeverAndFormerAsWell) { //create log and begin logging CustomerAccountLogEntry logEntry = new CustomerAccountLogEntry(eCustomerAccountActivityType.GetCustomerAccountInformation, phoneNumber10); using (Log log = CreateLog(logEntry)) { try { //Assigned note property of logEntry object to log the phonenumber10 on 4-Feb-2010 logEntry.Note = "PhoneNumber10:" + phoneNumber10; // validate the parameters. MethodValidator validator = new MethodValidator(MethodBase.GetCurrentMethod(), phoneNumber10); validator.Validate(); try { if (Convert.ToUInt64(phoneNumber10) == 0) { throw new Exception(); } } catch { throw new ValidationException("Invalid PhoneNumber"); } // setup the return List <CustomerContactInformation> contactInformation = new List <CustomerContactInformation>(); CustomerAccountInfo.MultipleReturns(contactInformation, phoneNumber10, getNeverAndFormerAsWell); return(contactInformation); } catch (ValidationException ve) { logEntry.SetError(new ExceptionFormatter(ve).Format()); throw; } catch (BusinessLogicLayerException blle) { logEntry.SetError(new ExceptionFormatter(blle).Format()); throw; } catch (Exception e) { logEntry.SetError(new ExceptionFormatter(e).Format()); throw new UnexpectedSystemException(e); } } }
//[23-02-2009] End Changes for improving performance of CustomerAccount service #endregion ctors #region inquireAccount /// <summary> /// This method returns account and statement information for the given account. /// </summary> /// <param name="accountNumber13"></param> /// <returns></returns> public Account InquireAccount([RequiredItem()][StringLength(13, 13)][CustomerAccountNumberAttribute()] string accountNumber13) { BillingLogEntry logEntry = new BillingLogEntry(eBillingActivityType.AccountInquiry, accountNumber13 != null?accountNumber13.PadLeft(16, '0'):string.Empty); using (Log log = CreateLog(logEntry)) { try { // validate the parameters. MethodValidator validator = new MethodValidator(MethodBase.GetCurrentMethod(), accountNumber13); validator.Validate(); // convert the accountNumber. CustomerAccountNumber accountNumber = (CustomerAccountNumber)TypeDescriptor.GetConverter( typeof(CustomerAccountNumber)).ConvertFrom(accountNumber13); // get the siteid/sitecode information PopulateSiteInfo(accountNumber); logEntry.SiteId = this.SiteId; // setup return Account account = new Account(); // setup adapter and fill account object. AccountAdapter adapter = new AccountAdapter(accountNumber, _userName, _siteId, _siteCode); adapter.Fill(account); //set the AllowOnlineOrdering flag SetAllowOnlineOrderingFlag(ref account); // all done. return(account); } catch (ValidationException ve) { logEntry.SetError(new ExceptionFormatter(ve).Format()); throw; } catch (BusinessLogicLayerException blle) { logEntry.SetError(new ExceptionFormatter(blle).Format()); throw; } catch (Exception e) { logEntry.SetError(new ExceptionFormatter(e).Format()); throw new UnexpectedSystemException(e); } } }
/// <summary> /// This method returns the account address information for the given account. /// </summary> /// <param name="accountNumber13"></param> /// <returns></returns> public AccountAddress InquireServiceAddress( [RequiredItem()][StringLength(13, 13)] [CustomerAccountNumber()] string accountNumber13) { BillingLogEntry logEntry = new BillingLogEntry( eBillingActivityType.AccountAddress, accountNumber13.PadLeft(16, '0')); using (Log log = CreateLog(logEntry)) { try { // validate the parameters. MethodValidator validator = new MethodValidator(MethodBase.GetCurrentMethod(), accountNumber13); validator.Validate(); // convert the accountNumber. CustomerAccountNumber accountNumber = (CustomerAccountNumber)TypeDescriptor.GetConverter( typeof(CustomerAccountNumber)).ConvertFrom(accountNumber13); // setup site information. PopulateSiteInfo(accountNumber); logEntry.SiteId = SiteId; // setup the return AccountAddress accountAddress = new AccountAddress(); AccountAdapter adapter = new AccountAdapter(accountNumber, _userName, _siteId, _siteCode); adapter.Fill(accountAddress); return(accountAddress); } catch (ValidationException ve) { logEntry.SetError(new ExceptionFormatter(ve).Format()); throw; } catch (BusinessLogicLayerException blle) { logEntry.SetError(new ExceptionFormatter(blle).Format()); throw; } catch (Exception e) { logEntry.SetError(new ExceptionFormatter(e).Format()); throw new UnexpectedSystemException(e); } } }
public Result <Method> CreateMethod(CreateMethod createMethod) { Method method = new Method(createMethod.Creator, createMethod.Name, createMethod.ApplicationRate); MethodValidator methodValidator = new MethodValidator(); var validationResult = methodValidator.Validate(method); if (!validationResult.IsValid) { return(Result.Fail <Method>(string.Join(" ", validationResult.Errors))); } method.SetId(++lastIdValue); methodsMemoryDatabase.Add(method); return(Result.Ok <Method>(method)); }
/// <summary>GetCustomerAcount</summary> /// <param name="siteId">Site Id for the customer</param> /// <param name="accountNumber9">9 digit customer account</param> /// <returns><CategoryActiveOutage></returns> public CustomerAccountProfile GetCustomerAcount( [RequiredItem()][SiteId()] int siteId, [RequiredItem()][RegEx(@"^(\d{7}(?<=\d*?[1-9]{1}\d*?)(?=\d*?[1-9]{1}\d*?)\d{2})?$", RegexOptions.None)] string accountNumber9) { //create log and begin logging CustomerAccountLogEntry logEntry = new CustomerAccountLogEntry(eCustomerAccountActivityType.GetCustomerAccountByAccountNumberAndSiteId, siteId, accountNumber9); using (Log log = CreateLog(logEntry)) try { //perform validation MethodValidator validator = new MethodValidator(MethodBase.GetCurrentMethod(), siteId, accountNumber9); validator.Validate(); //start changes for activity logging on 4-Feb-2010 logEntry.SiteId = siteId; //get a data access obj to work with CustomerAccountProfile customerAccountProfile = GetCustomerAccountProfile(siteId, accountNumber9); //End changes for activity logging on 4-Feb-2010 // Changes for Self Reg **END**// return(customerAccountProfile); } catch (ValidationException vex) { logEntry.SetError(new ExceptionFormatter(vex).Format()); throw vex; } catch (BusinessLogicLayerException bllex) { logEntry.SetError(new ExceptionFormatter(bllex).Format()); throw bllex; } catch (DataSourceException dse) { logEntry.SetError(new ExceptionFormatter(dse).Format()); throw new DataSourceUnavailableException(dse); } catch (Exception e) { logEntry.SetError(new ExceptionFormatter(e).Format()); //need to convert to bll exception throw new UnexpectedSystemException(e); } }
//[02-02-09] Start Changes for Q-matic #region GetCustomerAccountByAccountNumber /// <summary> /// /// </summary> /// <param name="accountNumber13"></param> /// <returns></returns> public CustomerAccountProfile GetCustomerAccountByAccountNumber([RequiredItem()][StringLength(13, 13)][CustomerAccountNumberAttribute()] string accountNumber13) { //create log and begin logging CustomerAccountLogEntry logEntry = new CustomerAccountLogEntry(); using (Log log = CreateLog(logEntry)) { try { logEntry.CustomerAccountActivityType = eCustomerAccountActivityType.GetCustomerAccountByAccountNumber; logEntry.CustomerAccountNumber = accountNumber13; // validate the parameters. MethodValidator validator = new MethodValidator(MethodBase.GetCurrentMethod(), accountNumber13); validator.Validate(); // convert the accountNumber. CustomerAccountNumber accountNumber = (CustomerAccountNumber)TypeDescriptor.GetConverter( typeof(CustomerAccountNumber)).ConvertFrom(accountNumber13); // get the siteid/sitecode information PopulateSiteInfo(accountNumber); logEntry.SiteId = this.SiteId; string accountNumber9 = accountNumber13.Substring(4); return(GetCustomerAccountProfile(SiteId, accountNumber9)); } catch (ValidationException ve) { logEntry.SetError(new ExceptionFormatter(ve).Format()); throw; } catch (BusinessLogicLayerException blle) { logEntry.SetError(new ExceptionFormatter(blle).Format()); throw; } catch (Exception e) { logEntry.SetError(new ExceptionFormatter(e).Format()); throw new UnexpectedSystemException(e); } } }
/// <summary> /// This method updates the given account with the correct BillingOption code. /// </summary> /// <param name="accountNumber16"></param> /// <param name="billingOption"></param> public void UpdateBillingOption( [RequiredItem()][CustomerAccountNumber()] string accountNumber16, [RequiredItem()] eBillingOption billingOption) { BillingLogEntry logEntry = new BillingLogEntry( eBillingActivityType.UpdateBillOption, accountNumber16); using (Log log = CreateLog(logEntry)) { try { // validate the parameters. MethodValidator validator = new MethodValidator(MethodBase.GetCurrentMethod(), accountNumber16, billingOption); validator.Validate(); // convert the accountNumber. CustomerAccountNumber accountNumber = (CustomerAccountNumber)TypeDescriptor.GetConverter( typeof(CustomerAccountNumber)).ConvertFrom(accountNumber16); // create the proxy CreateProxy(accountNumber); logEntry.SiteId = SiteId; // invoke it. if an error occurs, one will be thrown. Invoke((Request.STOPPB) new StopPbHelper(_siteId.ToString(), accountNumber.AccountNumber9, new SpbHelper( toInt32(accountNumber.StatementCode), (int)billingOption, eSpbFunctionAction.Add))); } catch (CmErrorException eCm) { logEntry.SetError(eCm.Message, eCm.ErrorCode); throw TranslateCmException(eCm); } catch (Exception e) { logEntry.SetError(e.Message); throw; } } }
/// <summary> /// This method returns the StatementActivity for the given account /// since the last statement. /// </summary> /// <param name="accountNumber16"></param> /// <returns></returns> public StatementActivity InquireStatementActivity( [RequiredItem()][StringLength(16, 16)] [CustomerAccountNumber()] string accountNumber16) { BillingLogEntry logEntry = new BillingLogEntry( eBillingActivityType.StatementActivity, accountNumber16); using (Log log = CreateLog(logEntry)) { try { // validate the parameters. MethodValidator validator = new MethodValidator(MethodBase.GetCurrentMethod(), accountNumber16); validator.Validate(); // convert the accountNumber. CustomerAccountNumber accountNumber = (CustomerAccountNumber)TypeDescriptor.GetConverter( typeof(CustomerAccountNumber)).ConvertFrom(accountNumber16); // setup the return StatementActivity statementActivity = new StatementActivity(); statementActivity.AccountNumber16 = accountNumber.AccountNumber16; statementActivity.StatementCode = accountNumber.StatementCode; // create proxy CreateProxy(accountNumber); // get the sitecode/siteId information // NOTE: CreateProxy above populates enough data for this // purpose as well logEntry.SiteId = SiteId; // get ACSUM from proxy Response.MAC00010 mac10Output = (Response.MAC00010) this.Invoke( (Request.MAC00010) new Mac00010Helper( SiteId.ToString(), accountNumber.AccountNumber9, accountNumber.StatementCode)); if (mac10Output.Items != null) { foreach (object item in mac10Output.Items) { if (item is Response.INL00008) { Response.INL00008 inline8 = (Response.INL00008)item; Transaction transaction = new Transaction(); transaction.Amount = toDouble(inline8.TRNSCTNAMNT); transaction.Description = inline8.DETLDSCRPTN; transaction.FromDate = new IcomsDate(inline8.TRNSCTNFROMDATE8).Date; transaction.ToDate = new IcomsDate(inline8.TRNSCTNTODATE8).Date; transaction.TransactionType = (eTransactionType)TypeDescriptor.GetConverter(typeof( eTransactionType)).ConvertFrom(inline8.TRNSCTNTYPE);; transaction.ServiceCategory = (eServiceCategory)TypeDescriptor.GetConverter(typeof( eServiceCategory)).ConvertFrom(inline8.SRVCCTGRY);; statementActivity.Transactions.Add(transaction); } } } // all done. return(statementActivity); } catch (ValidationException ve) { logEntry.SetError(new ExceptionFormatter(ve).Format()); throw; } catch (BusinessLogicLayerException blle) { logEntry.SetError(new ExceptionFormatter(blle).Format()); throw; } catch (CmErrorException eCm) { logEntry.SetError(eCm.Message, eCm.ErrorCode); throw TranslateCmException(eCm); } catch (Exception e) { logEntry.SetError(new ExceptionFormatter(e).Format()); throw new UnexpectedSystemException(e); } } }
/// <summary> /// This method returns account and statement information for the given account. /// </summary> /// <param name="siteId"></param> /// <param name="setTopBoxId"></param> /// <returns></returns> public Account InquireAccount([RequiredItem()] int siteId, [RequiredItem()][StringLength(1, 16)] string setTopBoxId) { BillingLogEntry logEntry = new BillingLogEntry(eBillingActivityType.AccountInquiry, siteId, setTopBoxId); using (Log log = CreateLog(logEntry)) { try { // validate the parameters. MethodValidator validator = new MethodValidator(MethodBase.GetCurrentMethod(), siteId, setTopBoxId); validator.Validate(); //look up the sitecode string siteCode = DalSiteCode.Instance.GetSiteCode(siteId); //get account number string accountNumber9 = null; DalEquipment dalEquipment = new DalEquipment(); accountNumber9 = dalEquipment.GetAccountFromSetTopBoxId(siteId, siteCode, setTopBoxId).PadLeft(9, '0'); if (accountNumber9 == null || accountNumber9 == string.Empty) { throw new InvalidSetTopBoxIdException(string.Format( __setTopBoxIdToAccountNumberException, setTopBoxId)); } //look up division for this account DalAccount dalAccount = new DalAccount(); CompanyDivisionFranchise companyDivisionFranchise = dalAccount.GetCompanyDivisionFranchise(siteId, siteCode, accountNumber9); //turn accountNumber9 into accountNumber13 string accountNumber13 = companyDivisionFranchise.Company.ToString().PadLeft(2, '0') + companyDivisionFranchise.Division.ToString().PadLeft(2, '0') + accountNumber9; // convert to CustomerAccountNumber CustomerAccountNumber accountNumber = (CustomerAccountNumber)TypeDescriptor.GetConverter( typeof(CustomerAccountNumber)).ConvertFrom(accountNumber13); // get the siteid/sitecode information PopulateSiteInfo(accountNumber); logEntry.CustomerAccountNumber = accountNumber.AccountNumber16; // setup return Account account = new Account(); // setup adapter and fill account object. AccountAdapter adapter = new AccountAdapter(accountNumber, _userName, _siteId, _siteCode); adapter.Fill(account); //set the AllowOnlineOrdering flag SetAllowOnlineOrderingFlag(ref account); // all done. return(account); } catch (ValidationException ve) { logEntry.SetError(ve.Message); throw; } catch (BusinessLogicLayerException blle) { logEntry.SetError(new ExceptionFormatter(blle).Format()); throw; } catch (DataSourceException de) { logEntry.SetError(de.Message); throw new DataSourceUnavailableException(de); } catch (Exception e) { logEntry.SetError(e.Message); throw new UnexpectedSystemException(e); } } }
/// <summary> /// This method returns account and statement information for the given account. /// </summary> /// <param name="accountNumber9"></param> /// <param name="siteId"></param> /// <returns></returns> public Account InquireAccount([RequiredItem()][StringLength(9, 9)] string accountNumber9, [RequiredItem()] int siteId) { BillingLogEntry logEntry = new BillingLogEntry(eBillingActivityType.AccountInquiry, accountNumber9 == null?string.Empty:accountNumber9.PadLeft(16, '0')); using (Log log = CreateLog(logEntry)) { try { // validate the parameters. MethodValidator validator = new MethodValidator(MethodBase.GetCurrentMethod(), accountNumber9, siteId); validator.Validate(); //log the site id logEntry.SiteId = siteId; //look up the company and division for this account string siteCode = DalSiteCode.Instance.GetSiteCode(siteId); DalAccount dalAccount = new DalAccount(); CompanyDivisionFranchise companyDivisionFranchise = dalAccount.GetCompanyDivisionFranchise(siteId, siteCode, accountNumber9); //turn accountNumber9 into accountNumber13 string accountNumber13 = companyDivisionFranchise.Company.ToString().PadLeft(2, '0') + companyDivisionFranchise.Division.ToString().PadLeft(2, '0') + accountNumber9; // convert to CustomerAccountNumber CustomerAccountNumber accountNumber = (CustomerAccountNumber)TypeDescriptor.GetConverter( typeof(CustomerAccountNumber)).ConvertFrom(accountNumber13); PopulateSiteInfo(accountNumber); //log the account number logEntry.CustomerAccountNumber = accountNumber.AccountNumber16; // setup return Account account = new Account(); // setup adapter and fill account object. AccountAdapter adapter = new AccountAdapter(accountNumber, _userName, _siteId, _siteCode); adapter.Fill(account); //set the AllowOnlineOrdering flag SetAllowOnlineOrderingFlag(ref account); // all done. return(account); } catch (ValidationException ve) { logEntry.SetError(ve.Message); throw; } catch (InvalidAccountNumberException ie) { logEntry.SetError(ie.Message); throw; } catch (DataSourceException de) { logEntry.SetError(de.Message); throw new DataSourceUnavailableException(de); } catch (UnexpectedSystemException ue) { logEntry.SetError(ue.Message); throw; } catch (Exception e) { logEntry.SetError(e.Message); throw new UnexpectedSystemException(e); } } }
} // PayUsingCreditCard() /// <summary> /// This method provides functionality to pay a statement using /// a pinless debit card as the method of payment. /// </summary> /// <param name="debitCardNumber"> /// The customer debit card number used to pay the bill. /// </param> /// <param name="nameOnCard"> /// The name on the customer debit card. /// </param> /// <param name="amount"> /// The amount to be paid to the customer service account. /// </param> /// <returns> /// A payment receipt instance is returned with the results from /// the requested payment. /// </returns> public PaymentReceipt PayUsingPinlessDebitCard( [RequiredItem()][RegEx(@"^\d{12,19}$", RegexOptions.None)] string debitCardNumber, [RequiredItem()][StringLength(1, 32)] string nameOnCard, [RequiredItem()][DoubleRange(0.00, 9999999.99)] double amount) { BillingLogEntry logEntry = new BillingLogEntry( eBillingActivityType.PayPinlessDebit, this.m_can.AccountNumber16, amount); using (Log log = CreateLog(logEntry)) { try { MethodValidator validator = new MethodValidator( MethodBase.GetCurrentMethod(), debitCardNumber, nameOnCard, amount); validator.Validate(); // See if debit card number exists in BIN file. // If not, it's invalid...need to throw an // exception. if (!_IsDebitCardNumberValid(debitCardNumber)) { throw new InvalidDebitCardNumberException(__debitCardNotFoundInBinFileMessage); } // Debit card validation logEntry.PaymentType = ePaymentType.PinlessDebit; // set the siteId information logEntry.SiteId = SiteId; // Set to false since it's a pinless debit transaction checkNSFStatus(false); // Create a DAL to transalate Mop codes DalMethodOfPayment dal = new DalMethodOfPayment(); DalPaymentReceipt dalPaymentReceipt = new DalPaymentReceipt(); string paymentReceiptType = dalPaymentReceipt.GetPaymentReceiptType(_userId); paymentReceiptType = paymentReceiptType == string.Empty?CmConstant.kstrDefaultReceiptType:paymentReceiptType; // assure that the length of the customer name does NOT exceed 32 characters! if (nameOnCard.Length >= 32) { nameOnCard = nameOnCard.Substring(0, 31); } // Build input elements Request.INL00072 inl72 = new INL00072Helper( amount, amount, CmConstant.kstrNegative, debitCardNumber, nameOnCard, __icomsSpecialDate, dal.GetMopByUserPaymentType(UserName, (int)ePaymentType.PinlessDebit), CmConstant.kstrNegative, m_can.StatementCode, paymentReceiptType, CmConstant.kstrDefaultWorkstation); Request.MAC00027 mac27 = new Mac00027Helper( SiteId.ToString(), m_can.AccountNumber9, CmConstant.kstrDefaultTaskCode, inl72); // Use inherited functions to get a response Response.MAC00027 mac27Response = (Response.MAC00027) this.Invoke((Request.MAC00027)mac27); Response.INL00072 inl72Response = mac27Response.Items[0] as Response.INL00072; int intErrorCode = toInt32(inl72Response.IGIRTRNCODE); if (intErrorCode > 0) { throw TranslateCmException( intErrorCode, string.Format("Authorization failed with error - ErrorCode: {0} ErrorText: {1}", inl72Response.IGIRTRNCODE, inl72Response.IGIMESGTEXT), null); } PaymentReceipt rcpt = new PaymentReceipt(); rcpt.AccountNumber16 = m_can.AccountNumber16; rcpt.AmountPaid = (inl72Response.AMNTTOAPLY.Length > 0) ? Double.Parse(inl72Response.AMNTTOAPLY): 0.00; rcpt.PaymentType = (ePaymentType) new MopPaymentType(this.UserName, inl72Response.MTHDOFPAYCODE); rcpt.Status = ePaymentStatus.Success; rcpt.TransactionDate = new IcomsDate(inl72Response.ATHRZTNDATE).Date; return(rcpt); } catch (BusinessLogicLayerException blle) { //the dal threw an exception logEntry.SetError(blle.Message); throw; } catch (DataSourceException excDSE) { //the dal threw an exception logEntry.SetError(excDSE.Message); throw new DataSourceUnavailableException(excDSE); } catch (CmErrorException excCm) { logEntry.SetError(excCm.Message, excCm.ErrorCode); throw TranslateCmException(excCm); } catch (Exception exc) { logEntry.SetError(exc.Message); throw; } } }
} // PayUsingElectronicCheck() /// <summary> /// This method provides functionality to pay a statement using /// a credit card as the method of payment. /// </summary> /// <param name="strCreditCardNumber"> /// Thie customer credit card number used to pay the bill. /// </param> /// <param name="strNameOnCard"> /// The name on the customer credit card. /// </param> /// <param name="strExpirationDate"> /// The expiration date of the customer credit card. /// </param> /// <param name="dblAmount"> /// The amount to be paid to the customer service account. /// </param> /// <returns> /// A payment receipt instance is returned with the results from /// the requested payment. /// </returns> public PaymentReceipt PayUsingCreditCard( [RequiredItem()][CreditCardNumberAttribute()] string strCreditCardNumber, [RequiredItem()] string strNameOnCard, [RequiredItem()][ValidCCDate()] string strExpirationDate, [RequiredItem()][DoubleRange(0.00, 9999999.99)] double dblAmount) { BillingLogEntry logEntry = new BillingLogEntry( eBillingActivityType.PayCredit, this.m_can.AccountNumber16, dblAmount); using (Log log = CreateLog(logEntry)) { try { MethodValidator validator = new MethodValidator(MethodBase.GetCurrentMethod(), strCreditCardNumber, strNameOnCard, strExpirationDate, dblAmount); validator.Validate(); // convert the accountNumber. CreditCardNumber creditCardNumber = (CreditCardNumber)TypeDescriptor.GetConverter( typeof(CreditCardNumber)).ConvertFrom(strCreditCardNumber); // Credit card validation logEntry.PaymentType = creditCardNumber.PaymentType; DateTime dttmExpirationDate = ValidCCDateAttribute.ToDate(strExpirationDate); // set the siteId information logEntry.SiteId = SiteId; checkNSFStatus(true); // Create a DAL to transalate Mop codes DalMethodOfPayment dal = new DalMethodOfPayment(); DalPaymentReceipt dalPaymentReceipt = new DalPaymentReceipt(); string paymentReceiptType = dalPaymentReceipt.GetPaymentReceiptType(_userId); paymentReceiptType = paymentReceiptType == string.Empty?CmConstant.kstrDefaultReceiptType:paymentReceiptType; PaymentReceipt rcpt = new PaymentReceipt(); // assure that the length of the customer name does NOT exceed 32 characters! if (strNameOnCard.Length >= 32) { strNameOnCard = strNameOnCard.Substring(0, 31); } // Build input elements Request.INL00072 inl72 = new INL00072Helper( dblAmount, dblAmount, CmConstant.kstrNegative, creditCardNumber.AccountNumber, strNameOnCard, dttmExpirationDate, dal.GetMopByUserPaymentType(UserName, (int)creditCardNumber.PaymentType), CmConstant.kstrNegative, m_can.StatementCode, paymentReceiptType, CmConstant.kstrDefaultWorkstation); Request.MAC00027 mac27 = new Mac00027Helper( SiteId.ToString(), m_can.AccountNumber9, CmConstant.kstrDefaultTaskCode, inl72); // Use inherited functions to get a response Response.MAC00027 mac27Response = (Response.MAC00027) this.Invoke((Request.MAC00027)mac27); Response.INL00072 inl72Response = mac27Response.Items[0] as Response.INL00072; int intErrorCode = toInt32(inl72Response.IGIRTRNCODE); if (intErrorCode > 0) { throw TranslateCmException( intErrorCode, string.Format("Authorization failed with error - ErrorCode: {0} ErrorText: {1}", inl72Response.IGIRTRNCODE, inl72Response.IGIMESGTEXT), null); } rcpt.AccountNumber16 = m_can.AccountNumber16; rcpt.AmountPaid = (inl72Response.AMNTTOAPLY.Length > 0) ? Double.Parse(inl72Response.AMNTTOAPLY): 0.00; rcpt.PaymentType = (ePaymentType) new MopPaymentType(this.UserName, inl72Response.MTHDOFPAYCODE); rcpt.Status = ePaymentStatus.Success; rcpt.TransactionDate = new IcomsDate(inl72Response.ATHRZTNDATE).Date; return(rcpt); } // try catch (BusinessLogicLayerException blle) { //the dal threw an exception logEntry.SetError(blle.Message); throw; } catch (DataSourceException excDSE) { //the dal threw an exception logEntry.SetError(excDSE.Message); throw new DataSourceUnavailableException(excDSE); } catch (CmErrorException excCm) { logEntry.SetError(excCm.Message, excCm.ErrorCode); throw TranslateCmException(excCm); } // catch( CmErrorException excCm ) catch (Exception exc) { logEntry.SetError(exc.Message); throw; } // catch( Exception exc ) } // using( Log log = CreateLog( logEntry ) ) } // PayUsingCreditCard()
/// <summary> /// Sets up the CustomerAccount to pay for services on a recurring basis /// using a credit card. /// </summary> /// <param name="strCreditCardNumber"></param> /// <param name="strNameOnCard"></param> /// <param name="strExpirationDate"></param> public void ActivateRecurringUsingCreditCard( [RequiredItem()][CreditCardNumber()] string strCreditCardNumber, [RequiredItem()] string strNameOnCard, [RequiredItem()][ValidCCDate()] string strExpirationDate) { BillingLogEntry logEntry = new BillingLogEntry( eBillingActivityType.RecurringCredit, this.m_can.AccountNumber16); using (Log log = CreateLog(logEntry)) { try { MethodValidator validator = new MethodValidator(MethodBase.GetCurrentMethod(), strCreditCardNumber, strNameOnCard, strExpirationDate); validator.Validate(); // convert the accountNumber. CreditCardNumber creditCardNumber = (CreditCardNumber)TypeDescriptor.GetConverter( typeof(CreditCardNumber)).ConvertFrom(strCreditCardNumber); // Credit card validation logEntry.PaymentType = creditCardNumber.PaymentType; DateTime dttmExpirationDate = ValidCCDateAttribute.ToDate(strExpirationDate); // set the siteId information logEntry.SiteId = SiteId; // Create a DAL to transalate Mop codes DalMethodOfPayment dal = new DalMethodOfPayment(); int intStatementCode = 0; try{ intStatementCode = int.Parse(m_can.StatementCode); }catch { /*don't care*/ } // check nsf status checkNSFStatus(true); // assure that the length of the customer name does NOT exceed 32 characters! if (strNameOnCard.Length >= 32) { strNameOnCard = strNameOnCard.Substring(0, 31); } // Build input elements Request.INL00073 inl73 = new INL00073Helper(dal.GetMopByUserPaymentType( UserName, (int)creditCardNumber.PaymentType), creditCardNumber.AccountNumber, strNameOnCard, dttmExpirationDate, intStatementCode, false); Request.MAC00027 mac27 = new Mac00027Helper(SiteId.ToString(), m_can.AccountNumber9, CmConstant.kstrDefaultTaskCode, inl73); // invoke and get the response object. this.Invoke((Request.MAC00027)mac27); } catch (BusinessLogicLayerException blle) { //the dal threw an exception logEntry.SetError(blle.Message); throw; } catch (DataSourceException excDSE) { //the dal threw an exception logEntry.SetError(excDSE.Message); throw new DataSourceUnavailableException(excDSE); } catch (CmErrorException excCm) { logEntry.SetError(excCm.Message, excCm.ErrorCode); throw TranslateCmException(excCm); } catch (Exception exc) { logEntry.SetError(exc.Message); throw; } } }
/// <summary> /// Sets up the CustomerAccount to pay for services on a recurring basis /// using a credit card. /// </summary> /// <param name="strCustomerName"></param> /// <param name="strBankRouteNumber"></param> /// <param name="strBankAccountNumber"></param> /// <param name="ebatAccountType"></param> public void ActivateRecurringUsingDirectDebit( string strCustomerName, [RequiredItem()][StringLength(1, 9)][NumericAttribute()] string strBankRouteNumber, [RequiredItem()][StringLength(1, 20)] string strBankAccountNumber, [RequiredItem()] eBankAccountType ebatAccountType) { BillingLogEntry logEntry = new BillingLogEntry( eBillingActivityType.RecurringCheck, this.m_can.AccountNumber16); using (Log log = CreateLog(logEntry)) { try { MethodValidator validator = new MethodValidator(MethodBase.GetCurrentMethod(), strCustomerName, strBankRouteNumber, strBankAccountNumber, ebatAccountType); validator.Validate(); // In this case, we are hard-coding the payment type ePaymentType ept = ePaymentType.RecurringDirectDebit; logEntry.PaymentType = ept; // set the siteId information logEntry.SiteId = SiteId; int intStatementCode = 0; try{ intStatementCode = int.Parse(m_can.StatementCode); } catch { /*don't care*/ } //use stopped check dal to verfiy the account does not have a stop on it DalStoppedCheck dalSC = new DalStoppedCheck(); if (dalSC.IsStoppedCheck(strBankRouteNumber, strBankAccountNumber)) { //the account has a stop placed on it throw new MopAuthorizationFailedException(string.Format(__stoppedCheckErrorMessage + "\nBank Routing Number: {0} \nBank Account Number: {1}", strBankRouteNumber, strBankAccountNumber)); } checkNSFStatus(false); // Create a DAL to transalate Mop codes DalMethodOfPayment dal = new DalMethodOfPayment(); // need to get the customer's name. if (strCustomerName != null) { strCustomerName = strCustomerName.Trim(); } if (strCustomerName == null || strCustomerName.Length == 0) { DalAccount dalAccount = new DalAccount(); CustomerAccountSchema.CustomerName custName = dalAccount.GetCustomerName(_siteId, _siteCode, m_can.AccountNumber9); if (custName == null) { throw new InvalidAccountNumberException(); } strCustomerName = (string)new CustomerName(custName.FirstName, custName.MiddleInitial, custName.LastName); if (strCustomerName == null || strCustomerName.Length == 0) { strCustomerName = CmConstant.kstrDefaultAccountTitle; } } // assure that the length of the customer name does NOT exceed 32 characters! if (strCustomerName.Length >= 32) { strCustomerName = strCustomerName.Substring(0, 31); } // Build input elements Request.INL00074 inl74 = new INL00074Helper(dal.GetMopByUserPaymentType(UserName, (int)ept), strBankAccountNumber, strBankRouteNumber, strCustomerName, (char)TypeDescriptor.GetConverter(typeof(eBankAccountType)).ConvertTo(ebatAccountType, typeof(char)), intStatementCode, false); Request.MAC00027 mac27 = new Mac00027Helper(SiteId.ToString(), m_can.AccountNumber9, CmConstant.kstrDefaultTaskCode, inl74); this.Invoke((Request.MAC00027)mac27); } catch (BusinessLogicLayerException blle) { //the dal threw an exception logEntry.SetError(blle.Message); throw; } catch (DataSourceException excDSE) { //the dal threw an exception logEntry.SetError(excDSE.Message); throw new DataSourceUnavailableException(excDSE); } catch (CmErrorException excCm) { logEntry.SetError(excCm.Message, excCm.ErrorCode); throw TranslateCmException(excCm); } catch (Exception exc) { logEntry.SetError(exc.Message); throw; } } }
/// <summary> /// This method returns the account address information for the given Phone Number. /// </summary> /// <param name="phoneNumber10"></param> /// <param name="streetNumber"></param> /// <returns></returns> public CustomerAccountProfile GetCustomerAccountByPhoneNbrAndStreetNbr([RequiredItem()][StringLength(10, 10)][RegEx(@"\d{10}", RegexOptions.Compiled)] string phoneNumber10 , string streetNumber) { //create log and begin logging CustomerAccountLogEntry logEntry = new CustomerAccountLogEntry(eCustomerAccountActivityType.GetCustomerAccountByPhoneNbrAndStreetNbr, phoneNumber10, streetNumber); using (Log log = CreateLog(logEntry)) { try { logEntry.Note = "phoneNumber10:" + phoneNumber10 + " and street#:" + streetNumber; // validate the parameters. MethodValidator validator = new MethodValidator(MethodBase.GetCurrentMethod(), phoneNumber10); validator.Validate(); try { if (Convert.ToUInt64(phoneNumber10) == 0) { throw new ValidationException(); } } catch { throw new ValidationException("Invalid Phonenumber"); } //create dal to get customer accounts for given phone number ad street address DalCustomerPhone dalCustomerPhone = new DalCustomerPhone(); CustomerAccountProfileSchema.AccountMatchesDataTable accountMatches = dalCustomerPhone.GetCustomerAccountMatches(phoneNumber10, streetNumber); if (String.IsNullOrEmpty(streetNumber)) { if (accountMatches.Rows.Count > 1) { throw new MultipleMatchsFoundException(String.Format(_multipleMatchesWithPhoneOnly, phoneNumber10)); } else if (accountMatches.Rows.Count == 0) { throw new NoMatchFoundException(String.Format(_noMatchWithPhoneOnly, phoneNumber10)); } else { return(GetCustomerAccountProfile(accountMatches[0].Site_ID, accountMatches[0].Account_Number)); } } else { if (accountMatches.Rows.Count > 1) { throw new MultipleMatchsFoundException(String.Format(_multipleMatchesWithStreet, phoneNumber10, streetNumber)); } else if (accountMatches.Rows.Count == 0) { throw new NoMatchFoundException(String.Format(_noMatchWithStreet, phoneNumber10, streetNumber)); } else { return(GetCustomerAccountProfile(accountMatches[0].Site_ID, accountMatches[0].Account_Number)); } } } catch (ValidationException ve) { logEntry.SetError(new ExceptionFormatter(ve).Format()); throw; } catch (InvalidAccountNumberException) { logEntry.SetError(new ExceptionFormatter(new NoMatchFoundException(String.Format(_noMatchWithPhoneOnly, phoneNumber10))).Format()); throw new NoMatchFoundException(String.Format(_noMatchWithPhoneOnly, phoneNumber10)); } catch (BusinessLogicLayerException blle) { logEntry.SetError(new ExceptionFormatter(blle).Format()); throw; } catch (Exception e) { logEntry.SetError(new ExceptionFormatter(e).Format()); throw new UnexpectedSystemException(e); } } }
/// <summary> /// This method provides functionality to pay a statement using /// electronic check as the method of payment. /// </summary> /// <param name="strCustomerName"></param> /// <param name="strBankRouteNumber"></param> /// <param name="strBankAccountNumber"></param> /// <param name="ebatAccountType"></param> /// <param name="dblAmount"></param> /// <returns></returns> public PaymentReceipt PayUsingElectronicCheck( string strCustomerName, [RequiredItem()][StringLength(1, 9)][NumericAttribute()] string strBankRouteNumber, [RequiredItem()][StringLength(1, 20)] string strBankAccountNumber, [RequiredItem()] eBankAccountType ebatAccountType, [RequiredItem()][DoubleRange(0.00, 9999999.99)] double dblAmount) { BillingLogEntry logEntry = new BillingLogEntry( eBillingActivityType.PayCheck, this.m_can.AccountNumber16, dblAmount); using (Log log = CreateLog(logEntry)) { try { // validate the parameters. MethodValidator validator = new MethodValidator(MethodBase.GetCurrentMethod(), strCustomerName, strBankRouteNumber, strBankAccountNumber, ebatAccountType, dblAmount); validator.Validate(); // In this case, we are hard-coding the payment type ePaymentType ept = ePaymentType.ElectronicCheck; logEntry.PaymentType = ept; // set the siteId information logEntry.SiteId = SiteId; //use stopped check dal to verfiy the account does not have a stop on it DalStoppedCheck dalSC = new DalStoppedCheck(); if (dalSC.IsStoppedCheck(strBankRouteNumber, strBankAccountNumber)) { //the account has a stop placed on it throw new MopAuthorizationFailedException(string.Format(__stoppedCheckErrorMessage + "\nBank Routing Number: {0} \nBank Account Number: {1}", strBankRouteNumber, strBankAccountNumber)); } checkNSFStatus(false); // Create a DAL to transalate Mop codes DalMethodOfPayment dal = new DalMethodOfPayment(); DalPaymentReceipt dalPaymentReceipt = new DalPaymentReceipt(); string paymentReceiptType = dalPaymentReceipt.GetPaymentReceiptType(_userId); paymentReceiptType = paymentReceiptType == string.Empty?CmConstant.kstrDefaultReceiptType:paymentReceiptType; PaymentReceipt rcpt = new PaymentReceipt(); // need to get the customer's name. if (strCustomerName != null) { strCustomerName = strCustomerName.Trim(); } if (strCustomerName == null || strCustomerName.Length == 0) { DalAccount dalAccount = new DalAccount(); CustomerAccountSchema.CustomerName custName = dalAccount.GetCustomerName(_siteId, _siteCode, m_can.AccountNumber9); if (custName == null) { throw new InvalidAccountNumberException(); } strCustomerName = (string)new CustomerName(custName.FirstName, custName.MiddleInitial, custName.LastName); if (strCustomerName == null || strCustomerName.Length == 0) { strCustomerName = CmConstant.kstrDefaultAccountTitle; } } // assure that the length of the customer name does NOT exceed 32 characters! if (strCustomerName.Length >= 32) { strCustomerName = strCustomerName.Substring(0, 31); } // Build input elements Request.INL00047 inl47 = new INL00047Helper(dblAmount, dblAmount, (eBankAccountType.Checking == ebatAccountType)? CmConstant.kstrAccountTypeChecking: CmConstant.kstrAccountTypeSavings, CmConstant.kstrNegative, strBankRouteNumber, strBankAccountNumber, strCustomerName, dal.GetMopByUserPaymentType( UserName, (int)ept), CmConstant.kstrNegative, m_can.StatementCode, paymentReceiptType, CmConstant.kstrDefaultWorkstation); Request.MAC00027 mac27 = new Mac00027Helper(SiteId.ToString(), m_can.AccountNumber9, CmConstant.kstrDefaultTaskCode, inl47); // Use inherited functions to get a response Response.MAC00027 mac27Response = (Response.MAC00027) this.Invoke((Request.MAC00027)mac27); Response.INL00047 inl47Response = mac27Response.Items[0] as Response.INL00047; int intErrorCode = toInt32(inl47Response.IGIRTRNCODE); if (intErrorCode > 0) { throw TranslateCmException( intErrorCode, string.Format("Authorization failed with error - ErrorCode: {0} ErrorText: {1}", inl47Response.IGIRTRNCODE, inl47Response.IGIMESGTEXT), null); } rcpt.AccountNumber16 = m_can.AccountNumber16; rcpt.AmountPaid = (inl47Response.AMNTTOAPLYUSR.Length > 0) ? Double.Parse(inl47Response.AMNTTOAPLYUSR): 0.00; rcpt.PaymentType = ePaymentType.ElectronicCheck; rcpt.Status = ePaymentStatus.Success; rcpt.TransactionDate = new IcomsDate(inl47Response.ATHRZTNDATE).Date; return(rcpt); } // try catch (BusinessLogicLayerException blle) { //the dal threw an exception logEntry.SetError(blle.Message); throw; } catch (DataSourceException excDSE) { //the dal threw an exception logEntry.SetError(excDSE.Message); throw new DataSourceUnavailableException(excDSE); } catch (CmErrorException excCm) { logEntry.SetError(excCm.Message, excCm.ErrorCode); throw TranslateCmException(excCm); } // catch( CmErrorException excCm ) catch (Exception exc) { logEntry.SetError(exc.Message); throw; } // catch( Exception exc ) } // using( Log log = ) } // PayUsingElectronicCheck()