View Source Ibanity.PontoConnect.Payment (ibanity v1.1.0)

Payment API wrapper

Summary

Functions

Same as create/3, but :attributes, :account_id, and :token must be set in request.

Examples

Set id and token to request a Payment

iex> %PontoConnect.Token{}
...> |> Request.token()
...> |> Request.id(:account_id, account_id)
...> |> Request.attributes(attributes)
...> |> PontoConnect.Payment.create()
{:ok, %PontoConnect.Payment{id: "343e64e5-4882-4559-96d0-221c398288f3"}}
Link to this function

create(request_or_token, account_or_id, attrs)

View Source

Creates a payment.

Returns {:ok, %__MODULE__{}} if successful, {:error, reason} otherwise.

Examples

Fetch an account before each example, or use a valid account id

iex> {:ok, account_or_id} = token |> Ibanity.PontoConnect.Account.find("03ebe0ae-f630-4414-b37b-afde7de67229")

Or

iex> account_or_id = "03ebe0ae-f630-4414-b37b-afde7de67229"
"03ebe0ae-f630-4414-b37b-afde7de67229"

Attributes

iex> attributes = [
...>   remittance_information: "payment",
...>   remittance_information_type: "unstructured",
...>   requested_execution_date: "2025-05-05",
...>   currency: "EUR",
...>   amount: 59,
...>   creditor_name: "Alex Creditor",
...>   creditor_account_reference: "BE55732022998044",
...>   creditor_account_reference_type: "IBAN",
...>   creditor_agent: "NBBEBEBB203",
...>   creditor_agent_type: "BIC",
...>   redirect_uri: "https://fake-tpp.com/payment-confirmation?payment=123",
...>   end_to_end_id: "1234567890"
...> ]

Use attributes and account_or_id:

iex> Ibanity.PontoConnect.Payment.create(token, account_or_id, attributes)
{:ok, %Ibanity.PontoConnect.Payment{id: "343e64e5-4882-4559-96d0-221c398288f3"}}

With request

iex> request = Ibanity.Request.token(token)
iex> Ibanity.PontoConnect.Payment.create(request, account_or_id, attributes)
{:ok, %Ibanity.PontoConnect.Payment{id: "343e64e5-4882-4559-96d0-221c398288f3"}}
Link to this function

delete(request_or_token, ids)

View Source

Delete a Payment by id

Takes a map with the following keys as second argument:

Examples

Fetch an account before each example, or use a valid account id

iex> {:ok, account_or_id} = token |> Ibanity.PontoConnect.Account.find("03ebe0ae-f630-4414-b37b-afde7de67229")

Or

iex> account_or_id = "03ebe0ae-f630-4414-b37b-afde7de67229"
"03ebe0ae-f630-4414-b37b-afde7de67229"

IDs

iex> ids = %{
...>   account_id: account_or_id,
...>   id: "953934eb-229a-4fd2-8675-07794078cc7d"
...> }

With token

iex> Ibanity.PontoConnect.Payment.delete(token, ids)
{:ok, %Ibanity.PontoConnect.Payment{id: "953934eb-229a-4fd2-8675-07794078cc7d"}}

With request

iex> token
...> |> Ibanity.Request.token()
...> |> Ibanity.Request.application(:my_application)
...> |> Ibanity.PontoConnect.Payment.delete(ids)
{:ok, %Ibanity.PontoConnect.Payment{id: "953934eb-229a-4fd2-8675-07794078cc7d"}}

Error

iex> Ibanity.PontoConnect.Payment.delete(token, %{
...>   id: "does-not-exist",
...>   account_id: account_or_id
...> })
{:error,
  [
    %{
      "code" => "resourceNotFound",
      "detail" => "The requested resource was not found.",
      "meta" => %{
        "requestId" => "00077F00000184847F0000011F4066E44223327005A",
        "resource" => "payment"
      }
    }
  ]}
Link to this function

find(request_or_token, ids)

View Source

Find Payment by id

Takes a Ibanity.PontoConnect.Token, or a Ibanity.Request with set :token as first argument.

Takes a map with the following keys as second argument:

Examples

Fetch an account before each example, or use a valid account id

iex> {:ok, account_or_id} = token |> Ibanity.PontoConnect.Account.find("03ebe0ae-f630-4414-b37b-afde7de67229")

Or

iex> account_or_id = "03ebe0ae-f630-4414-b37b-afde7de67229"
"03ebe0ae-f630-4414-b37b-afde7de67229"

IDs

iex> ids = %{
...>   account_id: account_or_id,
...>   id: "953934eb-229a-4fd2-8675-07794078cc7d"
...> }

With token

iex> Ibanity.PontoConnect.Payment.find(token, ids)
{:ok, %Ibanity.PontoConnect.Payment{id: "953934eb-229a-4fd2-8675-07794078cc7d"}}

With request

iex> token
...> |> Ibanity.Request.token()
...> |> Ibanity.Request.application(:my_application)
...> |> Ibanity.PontoConnect.Payment.find(ids)
{:ok, %Ibanity.PontoConnect.Payment{id: "953934eb-229a-4fd2-8675-07794078cc7d"}}

iex> Ibanity.PontoConnect.Payment.find(token, %{account_id: account_or_id, id: "does-not-exist"})
{:error,
  [
    %{
      "code" => "resourceNotFound",
      "detail" => "The requested resource was not found.",
      "meta" => %{
        "requestId" => "00077F00000184847F0000011F4066E44223327005A",
        "resource" => "payment"
      }
    }
  ]}