Gocardlex.Behaviour.Payment behaviour (gocardlex v1.0.4)
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.
Callbacks
Cancels the payment if it has not already been submitted to the banks.
Examples
iex> Gocardlex.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"}}}
Creates a new Payment
Examples
iex> params = %{
payments: %{
amount: 100,
currency: "GBP",
charge_date: "2017-06-30",
links: %{
mandate: "MD000099999999"
}
}
}
iex> Gocardlex.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"}}}
Gets an individual payment by ID
Examples
iex> Gocardlex.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"}}}
Lists all payments
Examples
iex> Gocardlex.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> Gocardlex.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"}]}}
Retries a failed payment if the underlying mandate is active.
Examples
iex> Gocardlex.Client.retry_payment("PM000099999999")
Updates a Payment metadata based by ID. Only the metadata parameter is allowed.
Examples
iex> params = %{
payments: %{
metadata: %{
db_id: "1234"
}
}
}
iex> Gocardlex.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"}}}