Customer

Customer: Search

Returns a collection of Customer response objects.

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

  1. Java
CustomerSearchRequest request = new CustomerSearchRequest()
  .id().is("the_customer_id");

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

for (Customer customer : collection) {
    System.out.println(customer.getFirstName());
}
Parameters
The country on an address associated with the customer.
The extended address on an address associated with the customer.
The first name on an address associated with the customer.
The last name on an address associated with the customer.
The locality (e.g. city) on an address associated with the customer.
The postal code on an address associated with the customer.
The region (e.g. state) on an address associated with the customer.
The street address on an address associated with the customer.
The name on a credit card associated with the customer.
The customer's company.
The date/time the customer was created.
The expiration date of a credit card associated with the customer.

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.

The customer's email.
The customer's fax number.
The customer's first name.
A string value representing an existing customer in your Vault.
.ids(…)multiple
A list of customer IDs to search for.
The customer's last name.
The payment method token of a payment method associated with the customer.

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.

The email of a PayPal account associated with the customer.
The customer's phone number.
The customer's website.

Examplesanchor

Customer fieldsanchor

  1. Java
CustomerSearchRequest 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 fieldsanchor

  1. Java
CustomerSearchRequest 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 fieldsanchor

  1. Java
CustomerSearchRequest request = new CustomerSearchRequest()
  .cardholderName().is("John Doe")
  .paymentMethodToken().is("the_payment_method_token");

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

Credit card numberanchor

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."

  1. Java
CustomerSearchRequest request = new CustomerSearchRequest()
  .creditCardNumber().startsWith("510510");

CustomerSearchRequest request = new CustomerSearchRequest()
  .creditCardNumber().endsWith("5100");

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

Expiration dateanchor

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

  1. Java
CustomerSearchRequest request = new CustomerSearchRequest()
  .creditCardExpirationDate().is("12/13");

CustomerSearchRequest request = new CustomerSearchRequest()
  .creditCardExpirationDate().isNot("12/13");

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

Created atanchor

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:

  1. Java
CustomerSearchRequest searchRequest = new CustomerSearchRequest()
  .createdAt().lessThanOrEqual(Calendar.getInstance());

ResourceCollection<Customer> collection = gateway.customer().search(searchRequest);

Payment method token with duplicatesanchor

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

An example:

  1. Java
CustomerSearchRequest searchRequest = new CustomerSearchRequest()
  .paymentMethodTokenWithDuplicates().is("paymentMethodToken");

ResourceCollection<Customer> collection = gateway.customer().search(searchRequest);

All customersanchor

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.

  1. Java
ResourceCollection<Customer> collection = gateway.customer().all();

See also