Gocardlex.Behaviour.Subscription behaviour (gocardlex v1.0.4)
Defines the behaviour for Subscriptions
Summary
Callbacks
Examples
iex> Gocardlex.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" => []}}}
Creates a new Subscription
Gets a Subscription based on their ID in GoCardless
Lists Subscriptions from GoCardless
Updates a Subscription in GoCardless.
Callbacks
Examples
iex> Gocardlex.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" => []}}}
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> Gocardlex.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"}]}}}
Gets a Subscription based on their ID in GoCardless
Examples
iex> Gocardlex.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"}]}}}
Lists Subscriptions from GoCardless
Examples
iex> Gocardlex.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"}]}]}}
Updates a Subscription in GoCardless.
Examples
iex> params = %{
subscriptions: %{
name: "Updated Name"
}
}
iex> Gocardlex.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"}]}}}