Returns a collection of Customer response objects.

For operators available on search fields, see the search fields page.

C♯
var request = new CustomerSearchRequest().
    Id.Is("the_customer_id");

ResourceCollection<Customer> collection = gateway.Customer.Search(request);

foreach (Customer customer in collection)
{
    Console.WriteLine(customer.FirstName);
}
Parameters
AddressCountryName text

The country on an address associated with the customer.

AddressExtendedAddress text

The extended address on an address associated with the customer.

AddressFirstName text

The first name on an address associated with the customer.

AddressLastName text

The last name on an address associated with the customer.

AddressLocality text

The locality (e.g. city) on an address associated with the customer.

AddressPostalCode text

The postal code on an address associated with the customer.

AddressRegion text

The region (e.g. state) on an address associated with the customer.

AddressStreetAddress text

The street address on an address associated with the customer.

CardholderName text

The name on a credit card associated with the customer.

Company text

The customer's company.

CreatedAt range

The date/time the customer was created.

CreditCardExpirationDate text

The expiration date of a credit card associated with the customer.

CreditCardNumber text

The number of a credit card associated with the customer.

Card number search is restricted: starts with searches up to the first 6 digits, ends with searches last 4 digits, and contains is not allowed.

Email text

The customer's email.

Fax text

The customer's fax number.

FirstName text

The customer's first name.

Id text

A string value representing an existing customer in your Vault.

Ids multiple

A list of customer IDs to search for.

LastName text

The customer's last name.

PaymentMethodToken text

The payment method token of a payment method associated with the customer.

PaymentMethodTokenWithDuplicates text

Same as payment method token, except this will return all customers that have a credit card with the same number as the payment method being searched.

PaypalAccountEmail text

The email of a PayPal account associated with the customer.

Phone text

The customer's phone number.

Website text

The customer's website.

Examples

Customer fields

C♯
var request = new CustomerSearchRequest().
    Company.Is("Acme Inc.").
    Email.Is("john.doe@example.com").
    Fax.Is("555-123-1234").
    FirstName.Is("John").
    Id.Is("the_customer_id").
    LastName.Is("Doe").
    Phone.Is("555-321-4321").
    Website.Is("http://www.example.com");

ResourceCollection<Customer> collection = gateway.Customer.Search(request);

Address fields

C♯
var request = new CustomerSearchRequest().
    AddressFirstName.Is("John").
    AddressLastName.Is("Doe").
    AddressStreetAddress.Is("111 First St.").
    AddressExtendedAddress.Is("Suite #3").
    AddressLocality.Is("Chicago").
    AddressRegion.Is("IL").
    AddressPostalCode.Is("12345").
    AddressCountryName.Is("USA");

ResourceCollection<Customer> collection = gateway.Customer.Search(request);

Credit card fields

C♯
var request = new CustomerSearchRequest().
    CardholderName.Is("John Doe").
    PaymentMethodToken.Is("the_payment_method_token");

ResourceCollection<Customer> collection = gateway.Customer.Search(request);

Credit card number

Searching on credit card number has a few restrictions. If you search using "starts with" you can only enter up to the first 6 digits. If you search using "ends with" you can only enter the last 4 digits. And you can't search on "contains."

C♯
var request = new CustomerSearchRequest().
    CreditCardNumber.StartsWith("510510");
ResourceCollection<Customer> collection = gateway.Customer.Search(request);

request = new CustomerSearchRequest().
    CreditCardNumber.EndsWith("5100");
collection = gateway.Customer.Search(request);

Expiration date

Expiration date also has restrictions. "is" and "is not" work, while "starts with," "ends with," and "contains" do not.

C♯
var request = new CustomerSearchRequest().
    CreditCardExpirationDate.Is("12/13");
ResourceCollection<Customer> collection = gateway.Customer.Search(request);

request = new CustomerSearchRequest().
    CreditCardExpirationDate.IsNot("12/13");
collection = gateway.Customer.Search(request);

Created at

You can search for customers that were created at a certain time. For instance, you can find all customers which were created in the past 3 days.

An example:

C♯
var searchRequest = new CustomerSearchRequest().
    CreatedAt.GreaterThanOrEqualTo(DateTime.Now.AddDays(-1));

ResourceCollection<Customer> results = gateway.Customer.Search(searchRequest);

Payment method token with duplicates

You can search for customers that have duplicated credit card numbers using payment method token as a reference.

An example:

C♯
var searchRequest = new CustomerSearchRequest().
    PaymentMethodTokenWithDuplicates().Is("paymentMethodToken");

ResourceCollection<Customer> results = gateway.Customer.Search(searchRequest);

All customers

You can get a list of all customers stored in the Vault. This will return a resource collection of customer objects. Search results are currently capped so this may not work for everybody.

C♯
ResourceCollection<Customer> collection = gateway.Customer.All();

See also