Class Customer

All Implemented Interfaces:
HasId, MetadataStore<Customer>, StripeObjectInterface

public class Customer extends ApiResource implements HasId, MetadataStore<Customer>
This object represents a customer of your business. It lets you create recurring charges and track payments that belong to the same customer.

Related guide: Save a card during payment.

  • Constructor Details

    • Customer

      public Customer()
  • Method Details

    • getDefaultSource

      public String getDefaultSource()
      Get ID of expandable defaultSource object.
    • setDefaultSource

      public void setDefaultSource(String id)
    • getDefaultSourceObject

      public PaymentSource getDefaultSourceObject()
      Get expanded defaultSource.
    • setDefaultSourceObject

      public void setDefaultSourceObject(PaymentSource expandableObject)
    • getTestClock

      public String getTestClock()
      Get ID of expandable testClock object.
    • setTestClock

      public void setTestClock(String id)
    • getTestClockObject

      public TestClock getTestClockObject()
      Get expanded testClock.
    • setTestClockObject

      public void setTestClockObject(TestClock expandableObject)
    • balanceTransactions

      public CustomerBalanceTransactionCollection balanceTransactions() throws StripeException
      Returns a list of transactions that updated the customer’s balances.
      Throws:
      StripeException
    • balanceTransactions

      public CustomerBalanceTransactionCollection balanceTransactions(Map<String,Object> params) throws StripeException
      Returns a list of transactions that updated the customer’s balances.
      Throws:
      StripeException
    • balanceTransactions

      public CustomerBalanceTransactionCollection balanceTransactions(Map<String,Object> params, RequestOptions options) throws StripeException
      Returns a list of transactions that updated the customer’s balances.
      Throws:
      StripeException
    • balanceTransactions

      Returns a list of transactions that updated the customer’s balances.
      Throws:
      StripeException
    • balanceTransactions

      Returns a list of transactions that updated the customer’s balances.
      Throws:
      StripeException
    • create

      public static Customer create(Map<String,Object> params) throws StripeException
      Creates a new customer object.
      Throws:
      StripeException
    • create

      public static Customer create(Map<String,Object> params, RequestOptions options) throws StripeException
      Creates a new customer object.
      Throws:
      StripeException
    • create

      public static Customer create(CustomerCreateParams params) throws StripeException
      Creates a new customer object.
      Throws:
      StripeException
    • create

      public static Customer create(CustomerCreateParams params, RequestOptions options) throws StripeException
      Creates a new customer object.
      Throws:
      StripeException
    • createFundingInstructions

      public FundingInstructions createFundingInstructions(Map<String,Object> params) throws StripeException
      Retrieve funding instructions for a customer cash balance. If funding instructions do not yet exist for the customer, new funding instructions will be created. If funding instructions have already been created for a given customer, the same funding instructions will be retrieved. In other words, we will return the same funding instructions each time.
      Throws:
      StripeException
    • createFundingInstructions

      public FundingInstructions createFundingInstructions(Map<String,Object> params, RequestOptions options) throws StripeException
      Retrieve funding instructions for a customer cash balance. If funding instructions do not yet exist for the customer, new funding instructions will be created. If funding instructions have already been created for a given customer, the same funding instructions will be retrieved. In other words, we will return the same funding instructions each time.
      Throws:
      StripeException
    • createFundingInstructions

      public FundingInstructions createFundingInstructions(CustomerCreateFundingInstructionsParams params) throws StripeException
      Retrieve funding instructions for a customer cash balance. If funding instructions do not yet exist for the customer, new funding instructions will be created. If funding instructions have already been created for a given customer, the same funding instructions will be retrieved. In other words, we will return the same funding instructions each time.
      Throws:
      StripeException
    • createFundingInstructions

      public FundingInstructions createFundingInstructions(CustomerCreateFundingInstructionsParams params, RequestOptions options) throws StripeException
      Retrieve funding instructions for a customer cash balance. If funding instructions do not yet exist for the customer, new funding instructions will be created. If funding instructions have already been created for a given customer, the same funding instructions will be retrieved. In other words, we will return the same funding instructions each time.
      Throws:
      StripeException
    • delete

      public Customer delete() throws StripeException
      Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer.
      Throws:
      StripeException
    • delete

      public Customer delete(RequestOptions options) throws StripeException
      Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer.
      Throws:
      StripeException
    • delete

      public Customer delete(Map<String,Object> params) throws StripeException
      Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer.
      Throws:
      StripeException
    • delete

      public Customer delete(Map<String,Object> params, RequestOptions options) throws StripeException
      Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer.
      Throws:
      StripeException
    • deleteDiscount

      public Discount deleteDiscount() throws StripeException
      Removes the currently applied discount on a customer.
      Throws:
      StripeException
    • deleteDiscount

      public Discount deleteDiscount(Map<String,Object> params) throws StripeException
      Removes the currently applied discount on a customer.
      Throws:
      StripeException
    • deleteDiscount

      public Discount deleteDiscount(Map<String,Object> params, RequestOptions options) throws StripeException
      Removes the currently applied discount on a customer.
      Throws:
      StripeException
    • list

      public static CustomerCollection list(Map<String,Object> params) throws StripeException
      Returns a list of your customers. The customers are returned sorted by creation date, with the most recent customers appearing first.
      Throws:
      StripeException
    • list

      public static CustomerCollection list(Map<String,Object> params, RequestOptions options) throws StripeException
      Returns a list of your customers. The customers are returned sorted by creation date, with the most recent customers appearing first.
      Throws:
      StripeException
    • list

      public static CustomerCollection list(CustomerListParams params) throws StripeException
      Returns a list of your customers. The customers are returned sorted by creation date, with the most recent customers appearing first.
      Throws:
      StripeException
    • list

      public static CustomerCollection list(CustomerListParams params, RequestOptions options) throws StripeException
      Returns a list of your customers. The customers are returned sorted by creation date, with the most recent customers appearing first.
      Throws:
      StripeException
    • listPaymentMethods

      public PaymentMethodCollection listPaymentMethods() throws StripeException
      Returns a list of PaymentMethods for a given Customer.
      Throws:
      StripeException
    • listPaymentMethods

      public PaymentMethodCollection listPaymentMethods(Map<String,Object> params) throws StripeException
      Returns a list of PaymentMethods for a given Customer.
      Throws:
      StripeException
    • listPaymentMethods

      public PaymentMethodCollection listPaymentMethods(Map<String,Object> params, RequestOptions options) throws StripeException
      Returns a list of PaymentMethods for a given Customer.
      Throws:
      StripeException
    • listPaymentMethods

      Returns a list of PaymentMethods for a given Customer.
      Throws:
      StripeException
    • listPaymentMethods

      public PaymentMethodCollection listPaymentMethods(CustomerListPaymentMethodsParams params, RequestOptions options) throws StripeException
      Returns a list of PaymentMethods for a given Customer.
      Throws:
      StripeException
    • retrieve

      public static Customer retrieve(String customer) throws StripeException
      Retrieves a Customer object.
      Throws:
      StripeException
    • retrieve

      public static Customer retrieve(String customer, RequestOptions options) throws StripeException
      Retrieves a Customer object.
      Throws:
      StripeException
    • retrieve

      public static Customer retrieve(String customer, Map<String,Object> params, RequestOptions options) throws StripeException
      Retrieves a Customer object.
      Throws:
      StripeException
    • retrieve

      public static Customer retrieve(String customer, CustomerRetrieveParams params, RequestOptions options) throws StripeException
      Retrieves a Customer object.
      Throws:
      StripeException
    • retrievePaymentMethod

      public PaymentMethod retrievePaymentMethod(String customer, Map<String,Object> params, RequestOptions options) throws StripeException
      Retrieves a PaymentMethod object for a given Customer.
      Throws:
      StripeException
    • retrievePaymentMethod

      public PaymentMethod retrievePaymentMethod(String customer, CustomerRetrievePaymentMethodParams params, RequestOptions options) throws StripeException
      Retrieves a PaymentMethod object for a given Customer.
      Throws:
      StripeException
    • search

      public static CustomerSearchResult search(Map<String,Object> params) throws StripeException
      Search for customers you’ve previously created using Stripe’s Search Query Language. Don’t use search in read-after-write flows where strict consistency is necessary. Under normal operating conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up to an hour behind during outages. Search functionality is not available to merchants in India.
      Throws:
      StripeException
    • search

      public static CustomerSearchResult search(Map<String,Object> params, RequestOptions options) throws StripeException
      Search for customers you’ve previously created using Stripe’s Search Query Language. Don’t use search in read-after-write flows where strict consistency is necessary. Under normal operating conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up to an hour behind during outages. Search functionality is not available to merchants in India.
      Throws:
      StripeException
    • search

      public static CustomerSearchResult search(CustomerSearchParams params) throws StripeException
      Search for customers you’ve previously created using Stripe’s Search Query Language. Don’t use search in read-after-write flows where strict consistency is necessary. Under normal operating conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up to an hour behind during outages. Search functionality is not available to merchants in India.
      Throws:
      StripeException
    • search

      public static CustomerSearchResult search(CustomerSearchParams params, RequestOptions options) throws StripeException
      Search for customers you’ve previously created using Stripe’s Search Query Language. Don’t use search in read-after-write flows where strict consistency is necessary. Under normal operating conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up to an hour behind during outages. Search functionality is not available to merchants in India.
      Throws:
      StripeException
    • update

      public Customer update(Map<String,Object> params) throws StripeException
      Updates the specified customer by setting the values of the parameters passed. Any parameters not provided will be left unchanged. For example, if you pass the source parameter, that becomes the customer’s active source (e.g., a card) to be used for all charges in the future. When you update a customer to a new valid card source by passing the source parameter: for each of the customer’s current subscriptions, if the subscription bills automatically and is in the past_due state, then the latest open invoice for the subscription with automatic collection enabled will be retried. This retry will not count as an automatic retry, and will not affect the next regularly scheduled payment for the invoice. Changing the default_source for a customer will not trigger this behavior.

      This request accepts mostly the same arguments as the customer creation call.

      Specified by:
      update in interface MetadataStore<Customer>
      Throws:
      StripeException
    • update

      public Customer update(Map<String,Object> params, RequestOptions options) throws StripeException
      Updates the specified customer by setting the values of the parameters passed. Any parameters not provided will be left unchanged. For example, if you pass the source parameter, that becomes the customer’s active source (e.g., a card) to be used for all charges in the future. When you update a customer to a new valid card source by passing the source parameter: for each of the customer’s current subscriptions, if the subscription bills automatically and is in the past_due state, then the latest open invoice for the subscription with automatic collection enabled will be retried. This retry will not count as an automatic retry, and will not affect the next regularly scheduled payment for the invoice. Changing the default_source for a customer will not trigger this behavior.

      This request accepts mostly the same arguments as the customer creation call.

      Specified by:
      update in interface MetadataStore<Customer>
      Throws:
      StripeException
    • update

      public Customer update(CustomerUpdateParams params) throws StripeException
      Updates the specified customer by setting the values of the parameters passed. Any parameters not provided will be left unchanged. For example, if you pass the source parameter, that becomes the customer’s active source (e.g., a card) to be used for all charges in the future. When you update a customer to a new valid card source by passing the source parameter: for each of the customer’s current subscriptions, if the subscription bills automatically and is in the past_due state, then the latest open invoice for the subscription with automatic collection enabled will be retried. This retry will not count as an automatic retry, and will not affect the next regularly scheduled payment for the invoice. Changing the default_source for a customer will not trigger this behavior.

      This request accepts mostly the same arguments as the customer creation call.

      Throws:
      StripeException
    • update

      public Customer update(CustomerUpdateParams params, RequestOptions options) throws StripeException
      Updates the specified customer by setting the values of the parameters passed. Any parameters not provided will be left unchanged. For example, if you pass the source parameter, that becomes the customer’s active source (e.g., a card) to be used for all charges in the future. When you update a customer to a new valid card source by passing the source parameter: for each of the customer’s current subscriptions, if the subscription bills automatically and is in the past_due state, then the latest open invoice for the subscription with automatic collection enabled will be retried. This retry will not count as an automatic retry, and will not affect the next regularly scheduled payment for the invoice. Changing the default_source for a customer will not trigger this behavior.

      This request accepts mostly the same arguments as the customer creation call.

      Throws:
      StripeException
    • getTestHelpers

      public Customer.TestHelpers getTestHelpers()
      The customer's state, county, province, or region as identified by Stripe Tax.
    • getAddress

      public Address getAddress()
      The customer's address.
    • getBalance

      public Long getBalance()
      Current balance, if any, being stored on the customer. If negative, the customer has credit to apply to their next invoice. If positive, the customer has an amount owed that will be added to their next invoice. The balance does not refer to any unpaid invoices; it solely takes into account amounts that have yet to be successfully applied to any invoice. This balance is only taken into account as invoices are finalized.
    • getCashBalance

      public CashBalance getCashBalance()
      The current funds being held by Stripe on behalf of the customer. These funds can be applied towards payment intents with source "cash_balance". The settings[reconciliation_mode] field describes whether these funds are applied to such payment intents manually or automatically.
    • getCreated

      public Long getCreated()
      Time at which the object was created. Measured in seconds since the Unix epoch.
    • getCurrency

      public String getCurrency()
      Three-letter ISO code for the currency the customer can be charged in for recurring billing purposes.
    • getDeleted

      public Boolean getDeleted()
      Always true for a deleted object.
    • getDelinquent

      public Boolean getDelinquent()
      When the customer's latest invoice is billed by charging automatically, delinquent is true if the invoice's latest charge failed. When the customer's latest invoice is billed by sending an invoice, delinquent is true if the invoice isn't paid by its due date.

      If an invoice is marked uncollectible by dunning, delinquent doesn't get reset to false.

    • getDescription

      public String getDescription()
      An arbitrary string attached to the object. Often useful for displaying to users.
    • getDiscount

      public Discount getDiscount()
      Describes the current discount active on the customer, if there is one.
    • getEmail

      public String getEmail()
      The customer's email address.
    • getInvoiceCreditBalance

      public Map<String,Long> getInvoiceCreditBalance()
      The current multi-currency balances, if any, being stored on the customer. If positive in a currency, the customer has a credit to apply to their next invoice denominated in that currency. If negative, the customer has an amount owed that will be added to their next invoice denominated in that currency. These balances do not refer to any unpaid invoices. They solely track amounts that have yet to be successfully applied to any invoice. A balance in a particular currency is only applied to any invoice as an invoice in that currency is finalized.
    • getInvoicePrefix

      public String getInvoicePrefix()
      The prefix for the customer used to generate unique invoice numbers.
    • getInvoiceSettings

      public Customer.InvoiceSettings getInvoiceSettings()
    • getLivemode

      public Boolean getLivemode()
      Has the value true if the object exists in live mode or the value false if the object exists in test mode.
    • getName

      public String getName()
      The customer's full name or business name.
    • getNextInvoiceSequence

      public Long getNextInvoiceSequence()
      The suffix of the customer's next invoice number, e.g., 0001.
    • getObject

      public String getObject()
      String representing the object's type. Objects of the same type share the same value.

      Equal to customer.

    • getPhone

      public String getPhone()
      The customer's phone number.
    • getPreferredLocales

      public List<String> getPreferredLocales()
      The customer's preferred locales (languages), ordered by preference.
    • getShipping

      public ShippingDetails getShipping()
      Mailing and shipping address for the customer. Appears on invoices emailed to this customer.
    • getSources

      public PaymentSourceCollection getSources()
      The customer's payment sources, if any.
    • getSubscriptions

      public SubscriptionCollection getSubscriptions()
      The customer's current subscriptions, if any.
    • getTax

      public Customer.Tax getTax()
    • getTaxExempt

      public String getTaxExempt()
      Describes the customer's tax exemption status. One of none, exempt, or reverse. When set to reverse, invoice and receipt PDFs include the text "Reverse charge".
    • getTaxIds

      public TaxIdCollection getTaxIds()
      The customer's tax IDs.
    • setAddress

      public void setAddress(Address address)
      The customer's address.
    • setBalance

      public void setBalance(Long balance)
      Current balance, if any, being stored on the customer. If negative, the customer has credit to apply to their next invoice. If positive, the customer has an amount owed that will be added to their next invoice. The balance does not refer to any unpaid invoices; it solely takes into account amounts that have yet to be successfully applied to any invoice. This balance is only taken into account as invoices are finalized.
    • setCashBalance

      public void setCashBalance(CashBalance cashBalance)
      The current funds being held by Stripe on behalf of the customer. These funds can be applied towards payment intents with source "cash_balance". The settings[reconciliation_mode] field describes whether these funds are applied to such payment intents manually or automatically.
    • setCreated

      public void setCreated(Long created)
      Time at which the object was created. Measured in seconds since the Unix epoch.
    • setCurrency

      public void setCurrency(String currency)
      Three-letter ISO code for the currency the customer can be charged in for recurring billing purposes.
    • setDeleted

      public void setDeleted(Boolean deleted)
      Always true for a deleted object.
    • setDelinquent

      public void setDelinquent(Boolean delinquent)
      When the customer's latest invoice is billed by charging automatically, delinquent is true if the invoice's latest charge failed. When the customer's latest invoice is billed by sending an invoice, delinquent is true if the invoice isn't paid by its due date.

      If an invoice is marked uncollectible by dunning, delinquent doesn't get reset to false.

    • setDescription

      public void setDescription(String description)
      An arbitrary string attached to the object. Often useful for displaying to users.
    • setDiscount

      public void setDiscount(Discount discount)
      Describes the current discount active on the customer, if there is one.
    • setEmail

      public void setEmail(String email)
      The customer's email address.
    • setId

      public void setId(String id)
      Unique identifier for the object.
    • setInvoiceCreditBalance

      public void setInvoiceCreditBalance(Map<String,Long> invoiceCreditBalance)
      The current multi-currency balances, if any, being stored on the customer. If positive in a currency, the customer has a credit to apply to their next invoice denominated in that currency. If negative, the customer has an amount owed that will be added to their next invoice denominated in that currency. These balances do not refer to any unpaid invoices. They solely track amounts that have yet to be successfully applied to any invoice. A balance in a particular currency is only applied to any invoice as an invoice in that currency is finalized.
    • setInvoicePrefix

      public void setInvoicePrefix(String invoicePrefix)
      The prefix for the customer used to generate unique invoice numbers.
    • setInvoiceSettings

      public void setInvoiceSettings(Customer.InvoiceSettings invoiceSettings)
    • setLivemode

      public void setLivemode(Boolean livemode)
      Has the value true if the object exists in live mode or the value false if the object exists in test mode.
    • setMetadata

      public void setMetadata(Map<String,String> metadata)
      Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
    • setName

      public void setName(String name)
      The customer's full name or business name.
    • setNextInvoiceSequence

      public void setNextInvoiceSequence(Long nextInvoiceSequence)
      The suffix of the customer's next invoice number, e.g., 0001.
    • setObject

      public void setObject(String object)
      String representing the object's type. Objects of the same type share the same value.

      Equal to customer.

    • setPhone

      public void setPhone(String phone)
      The customer's phone number.
    • setPreferredLocales

      public void setPreferredLocales(List<String> preferredLocales)
      The customer's preferred locales (languages), ordered by preference.
    • setShipping

      public void setShipping(ShippingDetails shipping)
      Mailing and shipping address for the customer. Appears on invoices emailed to this customer.
    • setSources

      public void setSources(PaymentSourceCollection sources)
      The customer's payment sources, if any.
    • setSubscriptions

      public void setSubscriptions(SubscriptionCollection subscriptions)
      The customer's current subscriptions, if any.
    • setTax

      public void setTax(Customer.Tax tax)
    • setTaxExempt

      public void setTaxExempt(String taxExempt)
      Describes the customer's tax exemption status. One of none, exempt, or reverse. When set to reverse, invoice and receipt PDFs include the text "Reverse charge".
    • setTaxIds

      public void setTaxIds(TaxIdCollection taxIds)
      The customer's tax IDs.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getId

      public String getId()
      Unique identifier for the object.
      Specified by:
      getId in interface HasId
    • getMetadata

      public Map<String,String> getMetadata()
      Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
      Specified by:
      getMetadata in interface MetadataStore<Customer>