gocardless v1.0.3 Gocardless.Behaviour.Payment behaviour

Link to this section Summary

Callbacks

Cancels the payment if it has not already been submitted to the banks

Creates a new Payment

Gets an individual payment by ID

Lists all payments

Retries a failed payment if the underlying mandate is active

Updates a Payment metadata based by ID. Only the metadata parameter is allowed

Link to this section Callbacks

Link to this callback cancel_payment(arg0, map)
cancel_payment(String.t, map) :: tuple

Cancels the payment if it has not already been submitted to the banks.

Examples

iex> Gocardless.Client.cancel_payment("PM000099999999")
{:ok,
%{"payments" => %{"amount" => 100, "amount_refunded" => 0,
    "charge_date" => "2017-06-30", "created_at" => "2017-06-23T15:27:18.656Z",
    "currency" => "GBP", "description" => nil, "id" => "PM000099999999",
    "links" => %{"creditor" => "CR000099999999",
      "mandate" => "MD000099999999"}, "metadata" => %{"db_id" => "1234"},
    "reference" => nil, "status" => "cancelled"}}}
Link to this callback create_payment(map)
create_payment(map) :: tuple

Creates a new Payment

Examples

iex> params = %{
  payments: %{
    amount: 100,
    currency: "GBP",
    charge_date: "2017-06-30",
    links: %{
      mandate: "MD000099999999"
    }
  }
}
iex> Gocardless.Client.create_payment(params)
{:ok,
%{"payments" => %{"amount" => 100, "amount_refunded" => 0,
    "charge_date" => "2017-06-30", "created_at" => "2017-06-23T15:27:18.656Z",
    "currency" => "GBP", "description" => nil, "id" => "PM000099999999",
    "links" => %{"creditor" => "CR000099999999",
      "mandate" => "MD000099999999"}, "metadata" => %{}, "reference" => nil,
    "status" => "pending_submission"}}}
Link to this callback get_payment(arg0)
get_payment(String.t) :: tuple

Gets an individual payment by ID

Examples

iex> Gocardless.Client.get_payment("PM000099999999")
{:ok,
%{"payments" => %{"amount" => 100, "amount_refunded" => 0,
    "charge_date" => "2017-06-30", "created_at" => "2017-06-23T15:27:18.656Z",
    "currency" => "GBP", "description" => nil, "id" => "PM000099999999",
    "links" => %{"creditor" => "CR000099999999",
      "mandate" => "MD000099999999"}, "metadata" => %{}, "reference" => nil,
    "status" => "pending_submission"}}}
Link to this callback list_payments(map)
list_payments(map) :: tuple

Lists all payments

Examples

iex> Gocardless.Client.list_payments
{:ok,
%{"meta" => %{"cursors" => %{"after" => nil, "before" => nil}, "limit" => 50},
  "payments" => [%{"amount" => 100, "amount_refunded" => 0,
      "charge_date" => "2017-06-30", "created_at" => "2017-06-23T15:27:18.656Z",
      "currency" => "GBP", "description" => nil, "id" => "PM000099999999",
      "links" => %{"creditor" => "CR000099999999",
        "mandate" => "MD000099999999"}, "metadata" => %{}, "reference" => nil,
      "status" => "pending_submission"}]}}

iex> Gocardless.Client.list_payments(%{"created_at[gt]" => "2017-06-22T17:18:06.000Z"})
{:ok,
%{"meta" => %{"cursors" => %{"after" => nil, "before" => nil}, "limit" => 50},
  "payments" => [%{"amount" => 100, "amount_refunded" => 0,
      "charge_date" => "2017-06-30", "created_at" => "2017-06-23T15:27:18.656Z",
      "currency" => "GBP", "description" => nil, "id" => "PM000099999999",
      "links" => %{"creditor" => "CR000099999999",
        "mandate" => "MD000099999999"}, "metadata" => %{}, "reference" => nil,
      "status" => "pending_submission"}]}}
Link to this callback retry_payment(arg0, map)
retry_payment(String.t, map) :: tuple

Retries a failed payment if the underlying mandate is active.

Examples

iex> Gocardless.Client.retry_payment("PM000099999999")
Link to this callback update_payment(arg0, map)
update_payment(String.t, map) :: tuple

Updates a Payment metadata based by ID. Only the metadata parameter is allowed.

Examples

iex> params = %{
  payments: %{
    metadata: %{
      db_id: "1234"
    }
  }
}
iex> Gocardless.Client.update_payment("PM000099999999", mtd)
{:ok,
%{"payments" => %{"amount" => 100, "amount_refunded" => 0,
    "charge_date" => "2017-06-30", "created_at" => "2017-06-23T15:27:18.656Z",
    "currency" => "GBP", "description" => nil, "id" => "PM000099999999",
    "links" => %{"creditor" => "CR000099999999",
      "mandate" => "MD000099999999"}, "metadata" => %{"db_id" => "1234"},
    "reference" => nil, "status" => "pending_submission"}}}