recurly v0.0.1 Recurly.Subscription

Module for handling subscriptions in Recurly. See the developer docs on subscriptions for more details

Summary

Functions

Creates a subscription from a changeset. Supports nesting the account

Finds a subscription given a subscription uuid. Returns the subscription or an error

Lists all the subscriptions. See the subscriptions dev docs for more details

Generates the path to a subscription given the uuid

Functions

cancel(subscription)
create(changeset)

Creates a subscription from a changeset. Supports nesting the account.

Parameters

  • changeset Keyword list changeset

Examples

alias Recurly.ValidationError

changeset = [
  plan_code: "gold",
  currency: "USD",
  account: [
    account_code: "b6f5783",
    email: "verena@example.com",
    first_name: "Verena",
    last_name: "Example",
    billing_info: [
      number: "4111-1111-1111-1111",
      month: 12,
      year: 2019,
      verification_value: "123",
      address1: "400 Alabama St",
      city: "San Francisco",
      state: "CA",
      country: "US",
      zip: "94110"
    ]
  ]
]

case Recurly.Subscription.create(changeset) do
  {:ok, subscription} ->
    # created the subscription
  {:error, %ValidationError{errors: errors}} ->
    # will give you a list of validation errors
end
find(uuid)

Finds a subscription given a subscription uuid. Returns the subscription or an error.

Parameters

  • uuid String subscription uuid

Examples

alias Recurly.NotFoundError

case Recurly.Subscription.find("36ce107b00244abd107f4e4397a19e95") do
  {:ok, subscription} ->
    # Found the subscription
  {:error, %NotFoundError{}} ->
    # 404 subscription was not found
end
list(options \\ [])

Lists all the subscriptions. See the subscriptions dev docs for more details.

Parameters

  • options Keyword list of GET params

Examples

case Recurly.Subscription.list(state: "active") do
  {:ok, subscriptions} ->
    # list of active subscriptions
  {:error, error} ->
    # error happened
end
path(uuid)

Generates the path to a subscription given the uuid

Parameters

  • uuid String subscription uuid
terminate(subscription)