示例#1
0
        /// <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;
                }
            }
        }
示例#2
0
        /// <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;
                }
            }
        }
示例#3
0
        }         // 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()
示例#4
0
        }         // 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;
                }
            }
        }
示例#5
0
        /// <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()