public void Sale_WithAllAttributes()
{
TransactionRequest request = new TransactionRequest
{
Amount = SandboxValues.TransactionAmount.AUTHORIZE,
Channel = "MyShoppingCartProvider",
OrderId = "123",
Recurring = true,
CreditCard = new TransactionCreditCardRequest
{
Number = SandboxValues.CreditCardNumber.VISA,
CVV = "321",
ExpirationDate = "05/2009",
CardholderName = "John Doe"
},
Customer = new CustomerRequest
{
FirstName = "Dan",
LastName = "Smith",
Company = "Braintree",
Email = "[email protected]",
Phone = "419-555-1234",
Fax = "419-555-1235",
Website = "http://braintreepayments.com"
},
BillingAddress = new AddressRequest
{
FirstName = "Carl",
LastName = "Jones",
Company = "Braintree",
StreetAddress = "123 E Main St",
ExtendedAddress = "Suite 403",
Locality = "Chicago",
Region = "IL",
PostalCode = "60622",
CountryName = "United States of America",
CountryCodeAlpha2 = "US",
CountryCodeAlpha3 = "USA",
CountryCodeNumeric = "840"
},
ShippingAddress = new AddressRequest
{
FirstName = "Andrew",
LastName = "Mason",
Company = "Braintree Shipping",
StreetAddress = "456 W Main St",
ExtendedAddress = "Apt 2F",
Locality = "Bartlett",
Region = "MA",
PostalCode = "60103",
CountryName = "Mexico",
CountryCodeAlpha2 = "MX",
CountryCodeAlpha3 = "MEX",
CountryCodeNumeric = "484"
}
};
Result<Transaction> result = gateway.Transaction.Sale(request);
Assert.IsTrue(result.IsSuccess());
Transaction transaction = result.Target;
Assert.AreEqual(1000.00, transaction.Amount);
Assert.AreEqual(TransactionStatus.AUTHORIZED, transaction.Status);
Assert.AreEqual("MyShoppingCartProvider", transaction.Channel);
Assert.AreEqual("123", transaction.OrderId);
Assert.IsTrue(transaction.Recurring.Value);
Assert.IsNull(transaction.GetVaultCreditCard());
Assert.IsNull(transaction.GetVaultCustomer());
Assert.IsNull(transaction.AvsErrorResponseCode);
Assert.AreEqual("M", transaction.AvsPostalCodeResponseCode);
Assert.AreEqual("M", transaction.AvsStreetAddressResponseCode);
Assert.IsFalse(transaction.TaxExempt.Value);
Assert.AreEqual("M", transaction.CvvResponseCode);
Assert.AreEqual("USD", transaction.CurrencyIsoCode);
Assert.IsNull(transaction.GetVaultCreditCard());
CreditCard creditCard = transaction.CreditCard;
Assert.AreEqual("411111", creditCard.Bin);
Assert.AreEqual("1111", creditCard.LastFour);
Assert.AreEqual("05", creditCard.ExpirationMonth);
Assert.AreEqual("2009", creditCard.ExpirationYear);
Assert.AreEqual("05/2009", creditCard.ExpirationDate);
Assert.AreEqual("John Doe", creditCard.CardholderName);
Assert.IsNull(transaction.GetVaultCustomer());
Customer customer = transaction.Customer;
Assert.AreEqual("Dan", customer.FirstName);
Assert.AreEqual("Smith", customer.LastName);
Assert.AreEqual("Braintree", customer.Company);
Assert.AreEqual("[email protected]", customer.Email);
Assert.AreEqual("419-555-1234", customer.Phone);
Assert.AreEqual("419-555-1235", customer.Fax);
Assert.AreEqual("http://braintreepayments.com", customer.Website);
Assert.IsNull(transaction.GetVaultBillingAddress());
Address billingAddress = transaction.BillingAddress;
Assert.AreEqual("Carl", billingAddress.FirstName);
Assert.AreEqual("Jones", billingAddress.LastName);
Assert.AreEqual("Braintree", billingAddress.Company);
Assert.AreEqual("123 E Main St", billingAddress.StreetAddress);
Assert.AreEqual("Suite 403", billingAddress.ExtendedAddress);
Assert.AreEqual("Chicago", billingAddress.Locality);
Assert.AreEqual("IL", billingAddress.Region);
Assert.AreEqual("60622", billingAddress.PostalCode);
Assert.AreEqual("United States of America", billingAddress.CountryName);
Assert.AreEqual("US", billingAddress.CountryCodeAlpha2);
Assert.AreEqual("USA", billingAddress.CountryCodeAlpha3);
Assert.AreEqual("840", billingAddress.CountryCodeNumeric);
Assert.IsNull(transaction.GetVaultShippingAddress());
Address shippingAddress = transaction.ShippingAddress;
Assert.AreEqual("Andrew", shippingAddress.FirstName);
Assert.AreEqual("Mason", shippingAddress.LastName);
Assert.AreEqual("Braintree Shipping", shippingAddress.Company);
Assert.AreEqual("456 W Main St", shippingAddress.StreetAddress);
Assert.AreEqual("Apt 2F", shippingAddress.ExtendedAddress);
Assert.AreEqual("Bartlett", shippingAddress.Locality);
Assert.AreEqual("MA", shippingAddress.Region);
Assert.AreEqual("60103", shippingAddress.PostalCode);
Assert.AreEqual("Mexico", shippingAddress.CountryName);
Assert.AreEqual("MX", shippingAddress.CountryCodeAlpha2);
Assert.AreEqual("MEX", shippingAddress.CountryCodeAlpha3);
Assert.AreEqual("484", shippingAddress.CountryCodeNumeric);
}