Stripe.Customers

Main API for working with Customers at Stripe. Through this API you can alter subscriptions, create invoices, create and delete customers, etc.

Summary

Functions

Cancels a subscription

Changes a customer’s subscription (plan, description, etc - see Stripe API for acceptable options). Customer ID and Subscription ID are required for this

Creates a Customer with the given parameters - all of which are optional

Invoices a customer according to Stripe’s invoice rules. This is not the same as a charge

Starts a subscription for the specified customer. Note that if you pass in the customer and subscription information, both will be created at the same time

Creates a subscription for the specified customer

Deletes a Customer with the specified ID

Retrieves a given Customer with the specified ID. Returns 404 if not found.

Example

Returns a list of invoices for a given customer

Returns a subscription; customer_id and subscription_id are required

Returns all subscriptions for a Customer

Returns a list of Customers with a default limit of 10 which you can override with list/1

Functions

cancel_subscription(id, sub_id)

Cancels a subscription

Example

Stripe.Customers.cancel_subscription "customer_id", "subscription_id"
change_subscription(id, sub_id, opts)

Changes a customer’s subscription (plan, description, etc - see Stripe API for acceptable options). Customer ID and Subscription ID are required for this.

Example

Stripe.Customers.change_subscription "customer_id", "subscription_id", plan: "premium"
create(params)

Creates a Customer with the given parameters - all of which are optional.

Example

new_customer = [
    email: "test@test.com",
    description: "An Test Account",
    card: [
      number: "4111111111111111",
      exp_month: 01,
      exp_year: 2018,
      cvc: 123,
      name: "Joe Test User"
    ]
  ]
  {:ok, res} = Stripe.Customers.create new_customer
create_invoice(id, params)

Invoices a customer according to Stripe’s invoice rules. This is not the same as a charge.

Example

Stripe.Customers.create_invoice "customer_id", "subscription_id"
create_subscription(opts)

Starts a subscription for the specified customer. Note that if you pass in the customer and subscription information, both will be created at the same time.

Example

new_sub = [
    email: "jill@test.com",
    description: "Poop on the Potty",
    plan: "standard",
    source: [
      object: "card",
      number: "4111111111111111",
      exp_month: 01,
      exp_year: 2018,
      cvc: 123,
      name: "Jill Subscriber"
    ]
  ]
  {:ok, sub} = Stripe.Customers.create_subscription new_sub

You can also just pass along the customer id and the plan name:

new_sub = [
    plan: "standard",
    customer: "customer_id"
  ]
  {:ok, sub} = Stripe.Customers.create_subscription new_sub
create_subscription(id, opts)

Creates a subscription for the specified customer.

Example

Stripe.Customers.create_subscription "customer_id", "plan"
delete(id)

Deletes a Customer with the specified ID

Example

Stripe.Customers.delete "customer_id"
get(id)

Retrieves a given Customer with the specified ID. Returns 404 if not found.

Example

Stripe.Customers.get "customer_id"
get_invoices(id, params \\ [])

Returns a list of invoices for a given customer

Example

Stripe.Customers.get_invoices "customer_id"
get_subcription(id, sub_id)

Returns a subscription; customer_id and subscription_id are required.

Example

Stripe.Customers.get_subscription "customer_id", "subscription_id"
get_subscriptions(id)

Returns all subscriptions for a Customer.

Example

Stripe.Customers.get_subscriptions "customer_id"
list(limit \\ 10)

Returns a list of Customers with a default limit of 10 which you can override with list/1

Example

{:ok, customers} = Stripe.Customers.list(20)