Information about a bank payment to be processed by a financial gateway
Inheritance: PaymentInfo
Exemplo n.º 1
0
        /// <summary>
        /// Gets the payment information.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="person">The person.</param>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="totalAmount">The total amount.</param>
        /// <param name="paymentDetail">The payment detail.</param>
        /// <returns></returns>
        private PaymentInfo GetPaymentInfo( PaymentParameters parameters, Person person, RockContext rockContext, decimal totalAmount, FinancialPaymentDetail paymentDetail )
        {
            PaymentInfo paymentInfo = null;

            if ( parameters.AccountType.ToLower() == "credit" )
            {
                if ( parameters.ExpirationMonth < 1 || parameters.ExpirationMonth > 12 )
                {
                    GenerateResponse( HttpStatusCode.BadRequest, "ExpirationMonth is required and must be between 1 and 12 for credit transactions" );
                }

                var currentDate = DateTime.Now;
                var maxYear = currentDate.Year + 30;

                if ( parameters.ExpirationYear < currentDate.Year || parameters.ExpirationYear > maxYear )
                {
                    GenerateResponse( HttpStatusCode.BadRequest, string.Format( "ExpirationYear is required and must be between {0} and {1} for credit transactions", currentDate.Year, maxYear ) );
                }

                if ( parameters.ExpirationYear <= currentDate.Year && parameters.ExpirationMonth < currentDate.Month )
                {
                    GenerateResponse( HttpStatusCode.BadRequest, "The ExpirationMonth and ExpirationYear combination must not have already elapsed for credit transactions" );
                }

                if ( string.IsNullOrWhiteSpace( parameters.Street1 ) ||
                    string.IsNullOrWhiteSpace( parameters.City ) ||
                    string.IsNullOrWhiteSpace( parameters.State ) ||
                    string.IsNullOrWhiteSpace( parameters.PostalCode ) )
                {
                    GenerateResponse( HttpStatusCode.BadRequest, "Street1, City, State, and PostalCode are required for credit transactions" );
                }

                paymentInfo = new CreditCardPaymentInfo()
                {
                    Number = parameters.AccountNumber,
                    Code = parameters.CCV ?? string.Empty,
                    ExpirationDate = new DateTime( parameters.ExpirationYear, parameters.ExpirationMonth, 1 ),
                    BillingStreet1 = parameters.Street1 ?? string.Empty,
                    BillingStreet2 = parameters.Street2 ?? string.Empty,
                    BillingCity = parameters.City ?? string.Empty,
                    BillingState = parameters.State ?? string.Empty,
                    BillingPostalCode = parameters.PostalCode ?? string.Empty,
                    BillingCountry = parameters.Country ?? "USA"
                };
            }
            else
            {
                if ( string.IsNullOrWhiteSpace( parameters.RoutingNumber ) )
                {
                    GenerateResponse( HttpStatusCode.BadRequest, "RoutingNumber is required for ACH transactions" );
                    return null;
                }

                paymentInfo = new ACHPaymentInfo()
                {
                    BankRoutingNumber = parameters.RoutingNumber,
                    BankAccountNumber = parameters.AccountNumber,
                    AccountType = parameters.AccountType.ToLower() == "checking" ? BankAccountType.Checking : BankAccountType.Savings
                };
            }

            paymentInfo.Amount = totalAmount;
            paymentInfo.FirstName = parameters.FirstName ?? person.FirstName;
            paymentInfo.LastName = parameters.LastName ?? person.LastName;
            paymentInfo.Email = parameters.Email ?? person.Email;
            paymentInfo.Phone = parameters.PhoneNumber ?? string.Empty;
            paymentInfo.Street1 = parameters.Street1 ?? string.Empty;
            paymentInfo.Street2 = parameters.Street2 ?? string.Empty;
            paymentInfo.City = parameters.City ?? string.Empty;
            paymentInfo.State = parameters.State ?? string.Empty;
            paymentInfo.PostalCode = parameters.PostalCode ?? string.Empty;
            paymentInfo.Country = parameters.Country ?? "USA";

            if ( paymentInfo.CreditCardTypeValue != null )
            {
                paymentDetail.CreditCardTypeValueId = paymentInfo.CreditCardTypeValue.Id;
            }

            if ( paymentInfo.CurrencyTypeValue != null )
            {
                paymentDetail.CurrencyTypeValueId = paymentInfo.CurrencyTypeValue.Id;
            }

            return paymentInfo;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Gets the ACH information.
 /// </summary>
 /// <returns></returns>
 private ACHPaymentInfo GetACHInfo()
 {
     var ach = new ACHPaymentInfo( txtAccountNumber.Text, txtRoutingNumber.Text, rblAccountType.SelectedValue == "Savings" ? BankAccountType.Savings : BankAccountType.Checking );
     ach.BankName = txtBankName.Text;
     return ach;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the check information.
        /// </summary>
        /// <param name="paymentInfo">The payment information.</param>
        /// <returns></returns>
        private Check GetCheck( ACHPaymentInfo ach )
        {
            var check = new Check();
            check.accountNumber = ach.BankAccountNumber.AsNumeric();
            check.accountType = ach.AccountType == BankAccountType.Checking ? "C" : "S";
            check.bankTransitNumber = ach.BankRoutingNumber.AsNumeric();
            check.secCode = "WEB";

            return check;
        }