stripity-stripe v1.4.0 Stripe.Subscriptions

Main API for working with Subscriptions at Stripe. Through this API you can:

  • create
  • change
  • retrieve
  • cancel
  • cancel_all
  • list all
  • count all

Supports Connect workflow by allowing to pass in any API key explicitely (vs using the one from env/config).

(API ref https://stripe.com/docs/api#subscriptions)

Summary

Functions

List all subscriptions using given api key

Cancels a subscription with given api key

Cancel all subscriptions for account

Cancel all subscriptions for account using given api key

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

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

Changes the payment source for a subscription

Count total number of subscriptions

Count total number of subscriptions using given api key

Starts a subscription for the specified customer

Starts a subscription for the specified customer using given api key

Returns a subscription; customer_id and subscription_id are required

Returns a subscription using given api key; customer_id and subscription_id are required

Functions

all(customer_id, accum \\ [], starting_after \\ "")

List all subscriptions.

##Example

{:ok, subscriptions} = Stripe.Subscriptions.all customer_id
all(customer_id, accum, starting_after, key)

List all subscriptions using given api key.

##Example

{:ok, subscriptions} = Stripe.Subscriptions.all customer_id, [], "", key
cancel(customer_id, sub_id, opts \\ [])

Cancels a subscription

Example

  Stripe.Subscriptions.cancel "customer_id", "subscription_id"
  Stripe.Subscriptions.cancel "customer_id", "subscription_id", [at_period_end: true]
cancel(customer_id, sub_id, opts, key)

Cancels a subscription with given api key.

Example

Stripe.Subscriptions.cancel "customer_id", "subscription_id", key
cancel_all(customer_id, opts)

Cancel all subscriptions for account.

#Example

Stripe.Subscriptions.cancel_all customer_id
cancel_all(customer_id, opts, key)

Cancel all subscriptions for account using given api key.

#Example

Stripe.Subscriptions.cancel_all customer_id, key
change(customer_id, sub_id, plan_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.Subscriptions.change "customer_id", "subscription_id", "plan_id"
change(customer_id, sub_id, plan_id, key)

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

Example

Stripe.Subscriptions.change "customer_id", "subscription_id", "plan_id", key
change_payment_source(customer_id, sub_id, source)

Changes the payment source for a subscription.

#Example

source = [object: "card", number: "4111111111111111", exp_month: 01, exp_year: 2018, cvc: 123]
Stripe.Subscriptions.change_payment_source("customer_id", "subscription_id", source)
count(customer_id)

Count total number of subscriptions.

Example

{:ok, count} = Stripe.Subscriptions.count customer_id
count(customer_id, key)

Count total number of subscriptions using given api key.

Example

{:ok, count} = Stripe.Subscriptions.count customer_id, key
create(customer_id, opts)

Starts a subscription for the specified customer.

Example

  new_sub = [
    plan: plan_id,
    metadata: [
    ...
    ]
  ]
  {:ok, sub} = Stripe.Subscriptions.create customer_id, new_sub
create(customer_id, opts, key)

Starts a subscription for the specified customer using given api key.

Example

new_sub = [
  plan: plan_id,
  metadata: [
  ...
  ]
]
{:ok, sub} = Stripe.Subscriptions.create customer_id, opts, key
get(customer_id, sub_id)

Returns a subscription; customer_id and subscription_id are required.

Example

  {:ok, customer} = Stripe.Customers.get_subscription "customer_id", "subscription_id"
get(customer_id, sub_id, key)

Returns a subscription using given api key; customer_id and subscription_id are required.

Example

{:ok, sub} = Stripe.Subscriptions.get "customer_id", "subscription_id", key