Gocardlex.Behaviour.Refund behaviour (gocardlex v1.0.4)

Summary

Callbacks

Creates a new Refund

Gets a Refund based on their ID in GoCardless

Lists Refunds from GoCardless

Updates a Refund metadata based on their ID in GoCardless. Only the metadata parameter is allowed.

Callbacks

create_refund(map)

@callback create_refund(map()) :: tuple()

Creates a new Refund

Examples

iex> params = %{
  refunds: %{
    amount: 100,
    total_amount_confirmation: 100,
    reference: "partial refund",
    links: %{
      payment: "PM000999999998"
    }
  }
}
iex> Gocardlex.Client.create_refund(params)
{:ok,
 %{"refunds" => %{"amount" => 100, "created_at" => "2017-06-27T10:00:26.248Z",
     "currency" => "GBP", "id" => "RF000999999998",
     "links" => %{"payment" => "PM000999999998"}, "metadata" => %{},
     "reference" => "partial refund"}}}

get_refund(t)

@callback get_refund(String.t()) :: tuple()

Gets a Refund based on their ID in GoCardless

Examples

iex> Gocardlex.Client.get_refund("RF000999999998")
{:ok,
 %{"refunds" => %{"amount" => 100, "created_at" => "2017-06-27T10:00:26.248Z",
     "currency" => "GBP", "id" => "RF000999999998",
     "links" => %{"payment" => "PM000999999998"}, "metadata" => %{},
     "reference" => "partial refund"}}}

list_refunds(map)

@callback list_refunds(map()) :: tuple()

Lists Refunds from GoCardless

Examples

iex> Gocardlex.Client.list_refunds
{:ok,
 %{"meta" => %{"cursors" => %{"after" => nil, "before" => nil}, "limit" => 50},
   "refunds" => [%{"amount" => 100, "created_at" => "2017-06-27T10:00:26.248Z",
      "currency" => "GBP", "id" => "RF000999999998",
      "links" => %{"payment" => "PM000999999998"}, "metadata" => %{},
      "reference" => "partial refund"}]}}

update_refund(t, map)

@callback update_refund(String.t(), map()) :: tuple()

Updates a Refund metadata based on their ID in GoCardless. Only the metadata parameter is allowed.

Examples

iex> params = %{
  refunds: %{
    metadata: %{
      db_id: "1234"
    }
  }
}
iex> Gocardlex.Client.update_refund("RF000999999998", params)
{:ok,
 %{"refunds" => %{"amount" => 100, "created_at" => "2017-06-27T10:00:26.248Z",
     "currency" => "GBP", "id" => "RF000999999998",
     "links" => %{"payment" => "PM000999999998"},
     "metadata" => %{"db_id" => "1234"}, "reference" => "partial refund"}}}