/// <summary>
        /// Successful response returned from a Credit Card Present Authorization Only request.
        /// https://apidocs.securenet.com/docs/creditcardpresent.html?lang=JSON#authonly
        /// </summary>
        public int Credit_Card_Present_AuthorizationOnly_Request_Returns_Successfully()
        {
            // Arrange
            var request = new AuthorizeRequest
            {
                Amount = 11.00m,
                Card = new Card
                {
                    TrackData = "%B4444333322221111^SECURENET^16041015432112345678?;4444333322221111=16041015432112345678?",
                },
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new PaymentsController();

            // Act
            var response = controller.ProcessRequest<AuthorizeResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
            Assert.IsNotNull(response.Transaction);
            Assert.IsTrue(response.Transaction.TransactionId > 0);

            return response.Transaction.TransactionId;
        }
        public void Tokenization_Create_Token_Using_Credit_Card_Request_Returns_Successfully()
        {
            // Arrange
            var request = new TokenCardRequest
            {
                PublicKey = "278DCC4B-85FE-485D-AFDD-9927AC4CA229",
                Card = new Card
                {
                    Number = "4111 1111 1111 1111",
                    ExpirationDate = "01/2017",
                    Address = new Address
                    {
                        Line1 = "123 Main St.",
                        City = "Austin",
                        State = "TX",
                        Zip = "78759"
                    }
                },
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new PreVaultController();

            // Act
            var response = controller.ProcessRequest<TokenCardResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        public void Transaction_Reporting_And_Management_Search_Transaction_Request_Returns_Successfully()
        {
            // Arramge
            var request = new TransactionSearchRequest
            {
                TransactionId = 111995104,
                CustomerId = "5000587",
                StartDate = Convert.ToDateTime("02/01/2014"),
                EndDate = Convert.ToDateTime("05/31/2014"),
                Amount = 11.00m,
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new TransactionsController();

            // Act
            var response = controller.ProcessRequest<TransactionSearchResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        public void Settlement_Close_Batch_Request_Returns_Successfully()
        {
            var paymentsControllerTests = new PaymentsControllerTests();
            paymentsControllerTests.Credit_Card_Present_AuthorizationOnly_And_PriorAuthCapture_Requests_Returns_Successfully();
            paymentsControllerTests.Credit_Card_Not_Present_Charge_Authorization_And_Capture_Request_Returns_Successfully();
            paymentsControllerTests.Credit_Card_Not_Present_Include_Addres_Request_Returns_Successfully();

            // Arrange
            var request = new BatchCloseRequest()
            {
                DeveloperApplication = new DeveloperApplication()
                {
                    DeveloperId = 12345678, 
                    Version = "1.2"
                }
            };
            var apiContext = new APIContext();
            var controller = new BatchesController();

            // Act
            var response = controller.ProcessRequest<BatchCloseResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        public void Tokenization_Create_Token_Using_Checking_Information_Request_Returns_Successfully()
        {
            // Arrange
            var request = new TokenCheckRequest
            {
                PublicKey = "278DCC4B-85FE-485D-AFDD-9927AC4CA229",
                Check = new Check
                {
                    FirstName = "John",
                    LastName = "Smith",
                    RoutingNumber = "222371863",
                    AccountNumber = "123456",
                },
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new PreVaultController();

            // Act
            var response = controller.ProcessRequest<TokenCheckResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        public void Transaction_Reporting_And_Management_Search_Transaction_Request_Returns_Successfully()
        {

            var paymentsController = new PaymentsControllerTests();
            int transactionId = paymentsController.Credit_Card_Present_AuthorizationOnly_Request_Returns_Successfully();
            // Arramge
            var request = new TransactionSearchRequest
            {
                TransactionId = transactionId,
                StartDate = DateTime.UtcNow.AddDays(-1),
                EndDate = DateTime.UtcNow.AddDays(1),
                Amount = 11.00m,
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new TransactionsController();

            // Act
            var response = controller.ProcessRequest<TransactionSearchResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        public void Settlement_Retrieving_Current_Batch_Request_Returns_Successfully()
        {
            // Arrange
            var request = new BatchCurrentRequest();
            var apiContext = new APIContext();
            var controller = new BatchesController();

            // Act
            var response = controller.ProcessRequest<BatchCurrentResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        public void Transaction_Reporting_And_Management_Retrieve_Transaction_Request_Returns_Successfully()
        {
            // Arrange
            var request = new TransactionRetrieveRequest
            {
                TransactionId = 111995104
            };

            var apiContext = new APIContext();
            var controller = new TransactionsController();

            // Act
            var response = controller.ProcessRequest<TransactionRetrieveResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        public void Transaction_Reporting_And_Management_Retrieve_Transaction_Request_Returns_Successfully()
        {
            var paymentsController = new PaymentsControllerTests();
            int transactionId = paymentsController.Credit_Card_Present_AuthorizationOnly_Request_Returns_Successfully();
            // Arrange
            var request = new TransactionRetrieveRequest
            {
                TransactionId = transactionId 
            };

            var apiContext = new APIContext();
            var controller = new TransactionsController();

            // Act
            var response = controller.ProcessRequest<TransactionRetrieveResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        public void ACH_Add_Billing_Address_Charge_Request_Returns_Successfully()
        {
            // Arrange
            var request = new ChargeRequest
            {
                Amount = 10.00m,
                Check = new Check
                {
                    FirstName = "Jack",
                    LastName = "Test",
                    RoutingNumber = "222371863",
                    AccountNumber = "123456",
                    Address = new Address
                    {
                        Line1 = "123 Main St.",
                        City = "Austin",
                        State = "TX",
                        Zip = "78759"
                    },
                },
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new PaymentsController();

            // Act
            var response = controller.ProcessRequest<ChargeResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        /// <summary>
        /// Successful response returned from a Credit Card Present PriorAuthCapture request.
        /// https://apidocs.securenet.com/docs/creditcardpresent.html?lang=JSON#priorauth
        /// </summary>
        public void Credit_Card_Present_PriorAuthCapture_Request_Returns_Successfully(int transactionId)
        {
            // Arrange
            var request = new PriorAuthCaptureRequest
            {
                Amount = 11.00m,
                TransactionId = transactionId, 
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                },
            };

            var apiContext = new APIContext();
            var controller = new PaymentsController();

            // Act
            var response = controller.ProcessRequest<PriorAuthCaptureResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        public void SecureNet_Vault_Store_Account_After_Charge_Request_Returns_Successfully()
        {
            // Arrange
            var request = new ChargeRequest
            {
                Amount = 11.00m,
                AddToVault = true,
                Card = new Card
                {
                    Number = "4444 3333 2222 1111",
                    ExpirationDate = "04/2016",
                    Address = new Address
                    {
                        Line1 = "123 Main St.",
                        City = "Austin",
                        State = "TX",
                        Zip = "78759"
                    }
                },
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new CustomersController();

            // Act
            var response = controller.ProcessRequest<ChargeResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        /// <summary>
        /// Successful response returned from a Void Transaction request.
        /// https://apidocs.securenet.com/docs/voids.html?lang=csharp
        /// </summary>
        public void Voids_Void_Transaction_Request_Returns_Successfully(int transactionId)
        {
            // Arrange
            var request = new VoidRequest
            {
                TransactionId = transactionId,
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new PaymentsController();

            // Act
            var response = controller.ProcessRequest<VoidResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        public void ACH_Charge_Account_Using_POS_Request_Returns_Successfully()
        {
            // Arrange
            var request = new ChargeRequest
            {
                Amount = 11.00m,
                Check = new Check
                {
                    FirstName = "Jack",
                    LastName = "Test",
                    RoutingNumber = "222371863",
                    AccountNumber = "147852",
                    CheckNumber = "107",
                    AccountType = "SAVINGS",
                    CheckType = "POINT_OF_SALE",
                    Verification = "NONE",
                },
                ExtendedInformation = new ExtendedInformation
                {
                    AdditionalTerminalInfo = new AdditionalTerminalInfo
                    {
                        TerminalId = "1234",
                        TerminalCity = "Austin",
                        TerminalState = "TX",
                        TerminalLocation = "Office",
                        StoreNumber = "452"
                    }
                },
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new PaymentsController();

            // Act
            var response = controller.ProcessRequest<ChargeResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        /// <summary>
        /// Successful response returned from a Credit Card Present IncludTip PriorAuthCapture request.
        /// https://apidocs.securenet.com/docs/creditcardpresent.html?lang=JSON#includetip
        /// </summary>
        public void Credit_Card_Present_IncludeTip_PriorAuthCapture_Request_Returns_Successfully(int transactionId)
        {
            // Arrange
            var request = new PriorAuthCaptureRequest
            {
                Amount = 13.25m,
                TransactionId = transactionId,
                ExtendedInformation = new ExtendedInformation
                {
                    ServiceData = new ServiceData
                    {
                        GratuityAmount = 1.75m,
                    },
                },
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                },
            };

            var apiContext = new APIContext();
            var controller = new PaymentsController();

            // Act
            var response = controller.ProcessRequest<PriorAuthCaptureResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        public void Credit_Card_Present_Charge_Request_Including_Address_Returns_Successfully()
        {
            // Arrange
            var request = new ChargeRequest
            {
                Amount = 11.00m,
                Card = new Card
                {
                    Number = "4444 3333 2222 1111",
                    Cvv = "999",
                    ExpirationDate = "04/2016",
                    Address = new Address
                    {
                        Line1 = "123 Main St.",
                        City = "Austin",
                        State = "TX",
                        Zip = "78759"
                    }
                },
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new PaymentsController();

            // Act
            var response = controller.ProcessRequest<ChargeResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        /// <summary>
        /// Successful response returned from an Charge using Tokenization request.
        /// https://apidocs.securenet.com/docs/creditcardnotpresent.html?lang=csharp#tokenization
        /// </summary>
        public void Credit_Card_Not_Present_Charge_Using_Tokenization_Request_Returns_Successfully(string token)
        {
            // Arrange
            var request = new ChargeRequest
            {
                Amount = 10.00m,
                PaymentVaultToken = new PaymentVaultToken
                {
                    PaymentMethodId = token,
                    PublicKey = "278DCC4B-85FE-485D-AFDD-9927AC4CA229"
                },
                AddToVault = true,
                ExtendedInformation = new ExtendedInformation
                {
                    TypeOfGoods = "PHYSICAL"
                },
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new PaymentsController();

            // Act
            var response = controller.ProcessRequest<ChargeResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        public void Recurring_Billing_Update_Variable_Payment_Plan_Request_Returns_Successfully(string customerId, string planId)
        {
            // Arrange
            var request = new UpdateVariablePaymentPlanRequest
            {
                CustomerId = customerId,
                PlanId = planId,
                Plan = new StoredVariablePaymentPlan
                {
                    PlanStartDate = Convert.ToDateTime("07/12/2014"),
                    ScheduledPayments = new List<StoredScheduledVariablePaymentPlan>
                    {
                        new StoredScheduledVariablePaymentPlan
                        {
                            ScheduleId = 1093749,
                            PaymentDate = Convert.ToDateTime("12/05/2014"),
                            Amount = 200
                        }

                    },
                    MaxRetries = 4,
                    Notes = "This is an updated variable Payment Plan"
                },
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new CustomersController();

            // Act
            var response = controller.ProcessRequest<UpdateVariablePaymentPlanResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        /// <summary>
        /// Successful response returned from an Delete Payment Account request.
        /// https://apidocs.securenet.com/docs/vault.html?lang=csharp#removeaccount
        /// </summary>
        public void SecureNet_Vault_Delete_Payment_Account_Request_Returns_Successfully(string customerId, string paymentMethodId)
        {
            // Arrange
            var request = new RemovePaymentMethodRequest
            {
                CustomerId = customerId,
                PaymentMethodId = paymentMethodId,
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new CustomersController();

            // Act
            var response = controller.ProcessRequest<RemovePaymentMethodResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        /// <summary>
        /// Successful response returned from a Pay with Stored Vault Account request.
        /// https://apidocs.securenet.com/docs/vault.html?lang=csharp#payaccount
        /// </summary>
        public void SecureNet_Vault_Pay_With_Stored_Vault_Account_Request_Returns_Successfully(string customerId, string paymentMethodId)
        {
            // Arrange
            var request = new ChargeRequest
            {
                Amount = 11.00m,
                PaymentVaultToken = new PaymentVaultToken
                {
                    CustomerId = customerId,
                    PaymentMethodId = paymentMethodId,
                    PaymentType = "CREDIT_CARD"
                },
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new CustomersController();

            // Act
            var response = controller.ProcessRequest<ChargeResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        /// <summary>
        /// Successful response returned from an Update Recurring Payment Plan request.
        /// https://apidocs.securenet.com/docs/recurringbilling.html?lang=csharp#updaterecurring
        /// </summary>
        public void Recurring_Billing_Update_Recurring_Payment_Plan_Request_Returns_Successfully(string customerId, string planId)
        {
            // Arrange
            var request = new UpdateRecurringPaymentPlanRequest
            {
                CustomerId = customerId,
                PlanId = planId,
                Plan = new RecurringPaymentPlan
                {
                    CycleType = "monthly",
                    DayOfTheMonth = 1,
                    DayOfTheWeek = 1,
                    Month = 6,
                    Frequency = 10,
                    Amount = 52.95m,
                    StartDate = Convert.ToDateTime("09/01/2014"),
                    EndDate = Convert.ToDateTime("12/01/2018"),
                    MaxRetries = 4,
                    Notes = "This is an updated recurring plan",
                    Active = true
                },
                IncludeRawObjects = true,
                IncludeRequest = true,
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new CustomersController();

            // Act
            var response = controller.ProcessRequest<UpdateRecurringPaymentPlanResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        /// <summary>
        /// Successful response returned from an Create Installment Plan request.
        /// https://apidocs.securenet.com/docs/recurringbilling.html?lang=csharp#installment
        /// </summary>
        public string Recurring_Billing_Create_Installment_Plan_Request_Returns_Successfully(string customerId, string paymentMethodId)
        {
            // Arrange
            var request = new AddInstallmentPaymentPlanRequest
            {
                CustomerId = customerId,
                Plan = new InstallmentPaymentPlan
                {
                    CycleType = "monthly",
                    DayOfTheMonth = 1,
                    DayOfTheWeek = 1,
                    Frequency = 1,
                    NumberOfPayments = 12,
                    InstallmentAmount = 276.95m,
                    RemainderAmount = 12.90m,
                    BalloonPaymentAddedTo = "FIRST",
                    RemainderAmountAddedTo = "LAST",
                    StartDate = Convert.ToDateTime("10/1/2017"),
                    EndDate = Convert.ToDateTime("10/1/2020"),
                    MaxRetries = 4,
                    PrimaryPaymentMethodId = paymentMethodId,
                    Notes = "This is an installment plan",
                    Active = true,
                    UserDefinedFields = new List<UserDefinedField>
                    {
                        new UserDefinedField
                        {
                            UdfName = "Udf1",
                            UdfValue = "Udf1_Value"
                        },
                        new UserDefinedField
                        {
                            UdfName = "Udf2",
                            UdfValue = "Udf2_Value"
                        },
                        new UserDefinedField
                        {
                            UdfName = "Udf3",
                            UdfValue = "Udf3_Value"
                        },
                        new UserDefinedField
                        {
                            UdfName = "Udf4",
                            UdfValue = "Udf4_Value"
                        },
                        new UserDefinedField
                        {
                            UdfName = "Udf5",
                            UdfValue = "Udf5_Value"
                        }
                    },
                },
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new CustomersController();

            // Act
            var response = controller.ProcessRequest<AddInstallmentPaymentPlanResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
            Assert.IsNotNull(response.PlanId);

            return response.PlanId;
        }
        /// <summary>
        /// Successful response returned from an Update Installment Plan request.
        /// https://apidocs.securenet.com/docs/recurringbilling.html?lang=csharp#updateinstallment
        /// </summary>
        public void Recurring_Billing_Update_Installment_Plan_Request_Returns_Successfully(string customerId, string planId)
        {
            // Arrange
            var request = new UpdateInstallmentPaymentPlanRequest
            {
                CustomerId = customerId,
                PlanId = planId,
                Plan = new InstallmentPaymentPlan
                {
                    CycleType = "monthly",
                    DayOfTheMonth = 1,
                    DayOfTheWeek = 1,
                    Frequency = 1,
                    NumberOfPayments = 15,
                    InstallmentAmount = 300.95m,
                    RemainderAmount = 17.90m,
                    BalloonPaymentAddedTo = "FIRST",
                    RemainderAmountAddedTo = "LAST",
                    StartDate = Convert.ToDateTime("11/01/2014"),
                    EndDate = Convert.ToDateTime("10/01/2020"),
                    MaxRetries = 4,
                    Notes = "This is an updated installment plan",
                    Active = true
                },
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new CustomersController();

            // Act
            var response = controller.ProcessRequest<UpdateInstallmentPaymentPlanResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        public void SecureNet_Vault_Create_Customer_And_Payment_Account_Request_Returns_Successfully()
        {
            // Arrange
            var request = new VaultCustomerAndPaymentMethodRequest
            {
                FirstName = "Jack",
                LastName = "Test",
                PhoneNumber = "512-250-7865",
                Address = new Address
                {
                    Line1 = "123 Main St.",
                    City = "Austin",
                    State = "TX",
                    Zip = "78759",
                    Country = "US"
                },
                EmailAddress = "*****@*****.**",
                SendEmailReceipts = true,
                Company = "Test company",
                Notes = "This is test notes",
                UserDefinedFields = new List<UserDefinedField>
                {
                    new UserDefinedField
                    {
                        UdfName = "Udf1",
                        UdfValue = "Udf1_Value"
                    },
                    new UserDefinedField
                    {
                        UdfName = "Udf2",
                        UdfValue = "Udf2_Value"
                    },
                    new UserDefinedField
                    {
                        UdfName = "Udf3",
                        UdfValue = "Udf3_Value"
                    },
                    new UserDefinedField
                    {
                        UdfName = "Udf4",
                        UdfValue = "Udf4_Value"
                    },
                    new UserDefinedField
                    {
                        UdfName = "Udf5",
                        UdfValue = "Udf5_Value"
                    }
                },
                CustomerDuplicateCheckIndicator = 1,
                Card = new Card
                {
                    Number = "4444 3333 2222 1111",
                    ExpirationDate = "04/2016",
                    FirstName = "Jack",
                    LastName = "Test",
                    Address = new Address
                    {
                        Line1 = "123 Main St.",
                        City = "Austin",
                        State = "TX",
                        Zip = "78749",
                        Country = "US"
                    }
                },
                Phone = "512-250-7865",
                Primary = true,
                AccountDuplicateCheckIndicator = 1,
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new CustomersController();

            // Act
            var response = controller.ProcessRequest<VaultCustomerAndPaymentMethodResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        /// <summary>
        /// Successful response returned from a Credit Card Not Present Authorization Only request.
        /// https://apidocs.securenet.com/docs/creditcardnotpresent.html?lang=JSON#authonly
        /// </summary>
        public int Credit_Card_Not_Present_AuthorizationOnly_Request_Returns_Successfully()
        {
            // Arrange
            var request = new AuthorizeRequest
            {
                Amount = 11.00m,
                Card = new Card
                {
                    Number = "4444 3333 2222 1111",
                    Cvv = "999",
                    ExpirationDate = "04/2016",
                    Address = new Address
                    {
                        Line1 = "123 Main St.",
                        City = "Austin",
                        State = "TX",
                        Zip = "78759"
                    },
                    FirstName = "Jack",
                    LastName = "Test"
                },
                ExtendedInformation = new ExtendedInformation
                {
                    TypeOfGoods = "PHYSICAL"
                },
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new PaymentsController();

            // Act
            var response = controller.ProcessRequest<AuthorizeResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
            Assert.IsNotNull(response.Transaction);
            Assert.IsTrue(response.Transaction.TransactionId > 0);

            return response.Transaction.TransactionId;
        }
        public string Recurring_Billing_Create_Variable_Payment_Plan_Request_Returns_Successfully(string customerId, string paymentMethodId)
        {
            // Arrange
            var request = new AddVariablePaymentPlanRequest
            {
                CustomerId = customerId,
                Plan = new VariablePaymentPlan
                {
                    PlanStartDate = Convert.ToDateTime("10/01/2014"),
                    PlanEndDate = Convert.ToDateTime("01/01/2020"),
                    PrimaryPaymentMethodId = paymentMethodId,
                    ScheduledPayments = new List<StoredScheduledVariablePaymentPlan>
                    {
                        new StoredScheduledVariablePaymentPlan
                        {
                            Amount = 132.89m,
                            PaymentDate = Convert.ToDateTime("10/1/2014"),
                        }

                    },
                    MaxRetries = 4,
                    Notes = "This is a variable payment plan",
                    UserDefinedFields = new List<UserDefinedField>
                    {
                        new UserDefinedField
                        {
                            UdfName = "Udf1",
                            UdfValue = "Udf1_Value"
                        },
                        new UserDefinedField
                        {
                            UdfName = "Udf2",
                            UdfValue = "Udf2_Value"
                        },
                        new UserDefinedField
                        {
                            UdfName = "Udf3",
                            UdfValue = "Udf3_Value"
                        },
                        new UserDefinedField
                        {
                            UdfName = "Udf4",
                            UdfValue = "Udf4_Value"
                        },
                        new UserDefinedField
                        {
                            UdfName = "Udf5",
                            UdfValue = "Udf5_Value"
                        }
                    },

                },
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new CustomersController();

            // Act
            var response = controller.ProcessRequest<AddVariablePaymentPlanResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
            Assert.IsNotNull(response.PlanId);

            return response.PlanId;
        }
        public void ACH_Pay_By_Check_Charge_Request_Returns_Successfully()
        {
            // Arrange
            var request = new ChargeRequest
            {
                Amount = 10.00m,
                Check = new Check
                {
                    FirstName = "Jack",
                    LastName = "Test",
                    RoutingNumber = "222371863",
                    AccountNumber = "123456"
                },
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new PaymentsController();

            // Act
            var response = controller.ProcessRequest<ChargeResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        public void Credits_Credit_An_Account_Request_Returns_Successfully()
        {
            // Arrange
            var request = new CreditRequest
            {
                Amount = 1.05m,
                Card = new Card
                {
                    Number = "4111 1111 1111 1111",
                    ExpirationDate = "01/2017"
                },
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new PaymentsController();

            // Act
            var response = controller.ProcessRequest<CreditResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        public void Transaction_Reporting_And_Management_Update_Transaction_Request_Returns_Successfully()
        {
            // Arrange
            var request = new TransactionUpdateRequest
            {
                ReferenceTransactionId = 111995104,
                DutyAmount = "2.07",
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new TransactionsController();

            // Act
            var response = controller.ProcessRequest<TransactionUpdateResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
        /// <summary>
        /// Successful response returned from a Create Customer request.
        /// https://apidocs.securenet.com/docs/vault.html?lang=csharp#createcustomer
        /// </summary>
        public string SecureNet_Vault_Create_Customer_Request_Returns_Successfully()
        {
            // Arrange
            var request = new CreateCustomerRequest
            {
                FirstName = "Jack",
                LastName = "Test",
                PhoneNumber = "512-122-1211",
                EmailAddress = "*****@*****.**",
                SendEmailReceipts = true,
                Notes = "test notes",
                Address = new Address
                {
                    Line1 = "123 Main St.",
                    City = "Austin",
                    State = "TX",
                    Zip = "78759"
                },
                Company = "Test Company",
                UserDefinedFields = new List<UserDefinedField>
                {
                    new UserDefinedField
                    {
                        UdfName = "Udf1",
                        UdfValue = "Udf1_Value"
                    },
                    new UserDefinedField
                    {
                        UdfName = "Udf2",
                        UdfValue = "Udf2_Value"
                    },
                    new UserDefinedField
                    {
                        UdfName = "Udf3",
                        UdfValue = "Udf3_Value"
                    },
                    new UserDefinedField
                    {
                        UdfName = "Udf4",
                        UdfValue = "Udf4_Value"
                    },
                    new UserDefinedField
                    {
                        UdfName = "Udf5",
                        UdfValue = "Udf5_Value"
                    },
                },
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new CustomersController();

            // Act
            var response = controller.ProcessRequest<CreateCustomerResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
            Assert.IsNotNull(response.CustomerId);
            Assert.IsTrue(response.CustomerId.Length > 0);

            return response.CustomerId;
        }