public void Search_OnAllTextFields()
{
string creditCardToken = string.Format("cc{0}", new Random().Next(1000000).ToString());
string firstName = string.Format("Tim{0}", new Random().Next(1000000).ToString());
TransactionRequest request = new TransactionRequest
{
Amount = 1000M,
CreditCard = new TransactionCreditCardRequest
{
Number = "4111111111111111",
ExpirationDate = "05/2012",
CardholderName = "Tom Smith",
Token = creditCardToken
},
BillingAddress = new AddressRequest
{
Company = "Braintree",
CountryName = "United States of America",
ExtendedAddress = "Suite 123",
FirstName = firstName,
LastName = "Smith",
Locality = "Chicago",
PostalCode = "12345",
Region = "IL",
StreetAddress = "123 Main St"
},
Customer = new CustomerRequest
{
Company = "Braintree",
Email = "[email protected]",
Fax = "5551231234",
FirstName = "Tom",
LastName = "Smith",
Phone = "5551231234",
Website = "http://example.com"
},
Options = new TransactionOptionsRequest
{
StoreInVault = true,
SubmitForSettlement = true
},
OrderId = "myorder",
ShippingAddress = new AddressRequest
{
Company = "Braintree P.S.",
CountryName = "Mexico",
ExtendedAddress = "Apt 456",
FirstName = "Thomas",
LastName = "Smithy",
Locality = "Braintree",
PostalCode = "54321",
Region = "MA",
StreetAddress = "456 Road"
}
};
Transaction transaction = gateway.Transaction.Sale(request).Target;
gateway.TestTransaction.Settle(transaction.Id);
transaction = gateway.Transaction.Find(transaction.Id);
TransactionSearchRequest searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
BillingCompany.Is("Braintree").
BillingCountryName.Is("United States of America").
BillingExtendedAddress.Is("Suite 123").
BillingFirstName.Is(firstName).
BillingLastName.Is("Smith").
BillingLocality.Is("Chicago").
BillingPostalCode.Is("12345").
BillingRegion.Is("IL").
BillingStreetAddress.Is("123 Main St").
CreditCardCardholderName.Is("Tom Smith").
CreditCardExpirationDate.Is("05/2012").
CreditCardNumber.Is(SandboxValues.CreditCardNumber.VISA).
Currency.Is("USD").
CustomerCompany.Is("Braintree").
CustomerEmail.Is("[email protected]").
CustomerFax.Is("5551231234").
CustomerFirstName.Is("Tom").
CustomerId.Is(transaction.Customer.Id).
CustomerLastName.Is("Smith").
CustomerPhone.Is("5551231234").
CustomerWebsite.Is("http://example.com").
OrderId.Is("myorder").
PaymentMethodToken.Is(creditCardToken).
ProcessorAuthorizationCode.Is(transaction.ProcessorAuthorizationCode).
SettlementBatchId.Is(transaction.SettlementBatchId).
ShippingCompany.Is("Braintree P.S.").
ShippingCountryName.Is("Mexico").
ShippingExtendedAddress.Is("Apt 456").
ShippingFirstName.Is("Thomas").
ShippingLastName.Is("Smithy").
ShippingLocality.Is("Braintree").
ShippingPostalCode.Is("54321").
ShippingRegion.Is("MA").
ShippingStreetAddress.Is("456 Road").
User.Is("integration_user_public_id").
CreditCardUniqueIdentifier.Is(transaction.CreditCard.UniqueNumberIdentifier);
ResourceCollection<Transaction> collection = gateway.Transaction.Search(searchRequest);
Assert.AreEqual(1, collection.MaximumCount);
Assert.AreEqual(transaction.Id, collection.FirstItem.Id);
}