public void Should_Fail_To_Use_An_Invalid_Token_In_Credit_Card_Transaction() { var postTransactionRequestModel = new PostTransactionRequestModel { Payer = "John Smith", EmailAddress = "*****@*****.**", Amount = System.Math.Round(new System.Random().NextDouble() * 1000, 2), TokenId = "INVALID_TOKEN", Comments = "Sample comments" }; var response = _transactionsApi.TransactionsPost(postTransactionRequestModel, null); Assert.AreEqual(PaymentResponseCode.InvalidToken, response.PaymentResponseCode); Assert.IsNotNull(response.Message); }
public void Should_Not_Successfully_Process_A_Transaction() { var amount = System.Math.Round(new System.Random().NextDouble() * 100, 2); var postTransactionRequestModel = new PostTransactionRequestModel { Payer = "John Smith", EmailAddress = "*****@*****.**", Amount = amount, CreditCardInformation = new CreditCardInformationModel { AccountHolder = "John Smith", CardNumber = "4242424242424242", Cvc = "123", Month = 12, Year = System.DateTime.Now.Year + 2, PostalCode = "54321" }, AttributeValues = new System.Collections.Generic.Dictionary <string, string> { { "phoneNumber", "512-234-1233" }, { "agentCode", "213498" } }, Comments = "Sample comments", PayerFee = amount * .10 }; try { var response = _transactionsApi.TransactionsPost(postTransactionRequestModel, null); // Should not be able to delete a token. Assert.Fail(); } catch (ApiException) { } }
public void Should_Successfully_Process_And_Void_Credit_Card() { var amount = System.Math.Round(new System.Random().NextDouble() * 100, 2); var postTransactionRequestModel = new PostTransactionRequestModel { Payer = "John Smith", EmailAddress = "*****@*****.**", Amount = amount, CreditCardInformation = new CreditCardInformationModel { AccountHolder = "John Smith", CardNumber = "4242424242424242", Cvc = "123", Month = 12, Year = System.DateTime.Now.Year + 2, PostalCode = "54321" }, AttributeValues = new System.Collections.Generic.Dictionary <string, string> { { "phoneNumber", "512-234-1233" }, { "agentCode", "213498" } }, Comments = "Sample comments", PayerFee = amount * .10 }; var response = _transactionsApi.TransactionsPost(postTransactionRequestModel, null); // Should return a valid Id. Assert.IsTrue(response.Id > 0); // Should successfully void a transaction. Assert.AreEqual(ReversalResponseCode.Success, _transactionsApi.TransactionsVoid(response.Id.Value, new PostVoidTransactionRequestModel { SendReceipt = false }).ReversalResponseCode); var getTransactionResponseModel = _transactionsApi.TransactionsGet(response.Id.Value); Assert.IsNotNull(getTransactionResponseModel); Assert.AreEqual("512-234-1233", getTransactionResponseModel.AttributeValues.Single(x => x.ParameterName == "phoneNumber").Value); Assert.IsNotNull(getTransactionResponseModel.Events.SingleOrDefault(x => x.EventType == EventType.Sale)); Assert.IsNotNull(getTransactionResponseModel.Events.SingleOrDefault(x => x.EventType == EventType.Void)); // Should not be able to void the transaction more than once. Assert.AreEqual(ReversalResponseCode.PreviouslyVoided, _transactionsApi.TransactionsVoid(response.Id.Value, new PostVoidTransactionRequestModel { SendReceipt = false }).ReversalResponseCode); }
public void Should_Create_Transaction_Then_Update_Existing_Transaction_Successfully_With_Impersonation_Key() { var amount = new System.Random().Next(10, 1000); var postTransactionRequestModel = new PostTransactionRequestModel { Payer = "John Smith", EmailAddress = "*****@*****.**", Amount = amount, BankAccountInformation = new BankAccountInformationModel { AccountHolder = "John Smith", FirstName = "John", LastName = "Smith", AccountNumber = "4545454", RoutingNumber = "111000025", AccountType = AccountType.Personalsavings }, Comments = "Sample comments" }; var response = _transactionsApi.TransactionsPost(postTransactionRequestModel, TestApiSettings.InvoicesImpersonationAccountKey); // Should return a valid Id. Assert.IsTrue(response.Id > 0); var updateInvoicesRequestModel = new UpdateInvoicesRequestModel() { Id = response.Id.Value, AttributeValues = new Dictionary <string, string>() { ["accountCode"] = "123", ["postalCode"] = "78701" }, PaidInvoices = new List <PaidInvoiceModel>() { new PaidInvoiceModel() { Id = "112121", PaidAmount = postTransactionRequestModel.Amount.Value / 2 }, new PaidInvoiceModel() { Id = "112122", PaidAmount = postTransactionRequestModel.Amount - (postTransactionRequestModel.Amount.Value / 2) } } }; bool success = GetApi(true).InvoicesUpdate(updateInvoicesRequestModel, TestApiSettings.InvoicesImpersonationAccountKey); // Should post successfully. Assert.IsTrue(success); }