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
Cancels a subscription
Example
Stripe.Customers.cancel_subscription "customer_id", "subscription_id"
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"
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
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"
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
Creates a subscription for the specified customer.
Example
Stripe.Customers.create_subscription "customer_id", "plan"
Retrieves a given Customer with the specified ID. Returns 404 if not found.
Example
Stripe.Customers.get "customer_id"
Returns a list of invoices for a given customer
Example
Stripe.Customers.get_invoices "customer_id"
Returns a subscription; customer_id and subscription_id are required.
Example
Stripe.Customers.get_subscription "customer_id", "subscription_id"
Returns all subscriptions for a Customer.
Example
Stripe.Customers.get_subscriptions "customer_id"
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)