gocardless v1.0.3 Gocardless.Behaviour.Subscription behaviour

Defines the behaviour for Subscriptions

Link to this section Summary

Callbacks

Creates a new Subscription

Gets a Subscription based on their ID in GoCardless

Lists Subscriptions from GoCardless

Updates a Subscription in GoCardless

Link to this section Callbacks

Link to this callback cancel_subscription(arg0)
cancel_subscription(String.t) :: tuple

Examples

iex> Gocardless.Client.cancel_subscription("SB000999999998")
{:ok,
 %{"subscriptions" => %{"amount" => 2500,
     "created_at" => "2017-06-26T11:03:27.037Z", "currency" => "GBP",
     "day_of_month" => 1, "end_date" => nil, "id" => "SB000999999998",
     "interval" => 1, "interval_unit" => "monthly",
     "links" => %{"mandate" => "MD000999999998"},
     "metadata" => %{"order_no" => "ABCD1234"}, "month" => nil,
     "name" => "Updated Name", "payment_reference" => nil,
     "start_date" => "2017-07-03", "status" => "cancelled",
     "upcoming_payments" => []}}}
Link to this callback create_subscription(map)
create_subscription(map) :: tuple

Creates a new Subscription

Examples

iex> params = %{
  subscriptions: %{
    amount: "2500",
    currency: "GBP",
    name: "Monthly Magazine",
    interval_unit: "monthly",
    day_of_month:  "1",
    metadata: %{
      "order_no": "ABCD1234"
    },
    links: %{
      mandate: "MD000999999998"
    }
  }
}
iex> Gocardless.Client.create_subscription(params)
{:ok,
 %{"subscriptions" => %{"amount" => 2500,
     "created_at" => "2017-06-26T11:03:27.037Z", "currency" => "GBP",
     "day_of_month" => 1, "end_date" => nil, "id" => "SB000999999998",
     "interval" => 1, "interval_unit" => "monthly",
     "links" => %{"mandate" => "MD000999999998"},
     "metadata" => %{"order_no" => "ABCD1234"}, "month" => nil,
     "name" => "Monthly Magazine", "payment_reference" => nil,
     "start_date" => "2017-07-03", "status" => "active",
     "upcoming_payments" => [%{"amount" => 2500, "charge_date" => "2017-07-03"},
      %{"amount" => 2500, "charge_date" => "2017-08-01"},
      %{"amount" => 2500, "charge_date" => "2017-09-01"},
      %{"amount" => 2500, "charge_date" => "2017-10-02"},
      %{"amount" => 2500, "charge_date" => "2017-11-01"},
      %{"amount" => 2500, "charge_date" => "2017-12-01"},
      %{"amount" => 2500, "charge_date" => "2018-01-02"},
      %{"amount" => 2500, "charge_date" => "2018-02-01"},
      %{"amount" => 2500, "charge_date" => "2018-03-01"},
      %{"amount" => 2500, "charge_date" => "2018-04-03"}]}}}
Link to this callback get_subscription(arg0)
get_subscription(String.t) :: tuple

Gets a Subscription based on their ID in GoCardless

Examples

iex> Gocardless.Client.get_subscription("SB000999999998")
{:ok,
 %{"subscriptions" => %{"amount" => 2500,
     "created_at" => "2017-06-26T11:03:27.037Z", "currency" => "GBP",
     "day_of_month" => 1, "end_date" => nil, "id" => "SB000999999998",
     "interval" => 1, "interval_unit" => "monthly",
     "links" => %{"mandate" => "MD000999999998"},
     "metadata" => %{"order_no" => "ABCD1234"}, "month" => nil,
     "name" => "Monthly Magazine", "payment_reference" => nil,
     "start_date" => "2017-07-03", "status" => "active",
     "upcoming_payments" => [%{"amount" => 2500, "charge_date" => "2017-07-03"},
      %{"amount" => 2500, "charge_date" => "2017-08-01"},
      %{"amount" => 2500, "charge_date" => "2017-09-01"},
      %{"amount" => 2500, "charge_date" => "2017-10-02"},
      %{"amount" => 2500, "charge_date" => "2017-11-01"},
      %{"amount" => 2500, "charge_date" => "2017-12-01"},
      %{"amount" => 2500, "charge_date" => "2018-01-02"},
      %{"amount" => 2500, "charge_date" => "2018-02-01"},
      %{"amount" => 2500, "charge_date" => "2018-03-01"},
      %{"amount" => 2500, "charge_date" => "2018-04-03"}]}}}
Link to this callback list_subscriptions(map)
list_subscriptions(map) :: tuple

Lists Subscriptions from GoCardless

Examples

iex> Gocardless.Client.list_subscriptions
{:ok,
 %{"meta" => %{"cursors" => %{"after" => nil, "before" => nil}, "limit" => 50},
   "subscriptions" => [%{"amount" => 2500,
      "created_at" => "2017-06-26T11:03:27.037Z", "currency" => "GBP",
      "day_of_month" => 1, "end_date" => nil, "id" => "SB000999999998",
      "interval" => 1, "interval_unit" => "monthly",
      "links" => %{"mandate" => "MD000999999998"},
      "metadata" => %{"order_no" => "ABCD1234"}, "month" => nil,
      "name" => "Monthly Magazine", "payment_reference" => nil,
      "start_date" => "2017-07-03", "status" => "active",
      "upcoming_payments" => [%{"amount" => 2500,
         "charge_date" => "2017-07-03"},
       %{"amount" => 2500, "charge_date" => "2017-08-01"},
       %{"amount" => 2500, "charge_date" => "2017-09-01"},
       %{"amount" => 2500, "charge_date" => "2017-10-02"},
       %{"amount" => 2500, "charge_date" => "2017-11-01"},
       %{"amount" => 2500, "charge_date" => "2017-12-01"},
       %{"amount" => 2500, "charge_date" => "2018-01-02"},
       %{"amount" => 2500, "charge_date" => "2018-02-01"},
       %{"amount" => 2500, "charge_date" => "2018-03-01"},
       %{"amount" => 2500, "charge_date" => "2018-04-03"}]}]}}
Link to this callback update_subscription(arg0, map)
update_subscription(String.t, map) :: tuple

Updates a Subscription in GoCardless.

Examples

iex> params = %{
  subscriptions: %{
    name: "Updated Name"
  }
}
iex> Gocardless.Client.update_subscription("SB000999999998", params)
{:ok,
 %{"subscriptions" => %{"amount" => 2500,
     "created_at" => "2017-06-26T11:03:27.037Z", "currency" => "GBP",
     "day_of_month" => 1, "end_date" => nil, "id" => "SB000999999998",
     "interval" => 1, "interval_unit" => "monthly",
     "links" => %{"mandate" => "MD000999999998"},
     "metadata" => %{"order_no" => "ABCD1234"}, "month" => nil,
     "name" => "Updated Name", "payment_reference" => nil,
     "start_date" => "2017-07-03", "status" => "active",
     "upcoming_payments" => [%{"amount" => 2500, "charge_date" => "2017-07-03"},
      %{"amount" => 2500, "charge_date" => "2017-08-01"},
      %{"amount" => 2500, "charge_date" => "2017-09-01"},
      %{"amount" => 2500, "charge_date" => "2017-10-02"},
      %{"amount" => 2500, "charge_date" => "2017-11-01"},
      %{"amount" => 2500, "charge_date" => "2017-12-01"},
      %{"amount" => 2500, "charge_date" => "2018-01-02"},
      %{"amount" => 2500, "charge_date" => "2018-02-01"},
      %{"amount" => 2500, "charge_date" => "2018-03-01"},
      %{"amount" => 2500, "charge_date" => "2018-04-03"}]}}}