Ibanity.PontoConnect.PaymentRequest (ibanity v1.0.0)
Payment Request API wrapper
Link to this section Summary
Functions
Same as create/3, but :attributes
, :account_id
, and :token
must be set in request.
Link to this section Functions
create(request)
Same as create/3, but :attributes
, :account_id
, and :token
must be set in request.
examples
Examples
Set id and token to create a PaymentRequest
iex> token
...> |> Ibanity.Request.token()
...> |> Ibanity.Request.id(:account_id, account_id)
...> |> Ibanity.Request.attributes(attributes)
...> |> Ibanity.PontoConnect.PaymentRequest.create()
{:ok, %Ibanity.PontoConnect.PaymentRequest{id: "343e64e5-4882-4559-96d0-221c398288f3"}}
create(request_or_token, account_or_id, attrs)
Returns {:ok, %__MODULE__{}}
if successful, {:error, reason}
otherwise.
example
Example
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 = [
...> remittanceInformation: "payment-request",
...> remittanceInformationType: "unstructured",
...> amount: 0.5,
...> endToEndId: "4874366da78549e0b3014a86cd646dc4",
...> redirectUri: "https://fake-tpp.com/payment-request-confirmation?paymentRequest=123"
...> ]
With token
iex> Ibanity.PontoConnect.PaymentRequest.create(token, account_or_id, attributes)
{:ok, %Ibanity.PontoConnect.PaymentRequest{id: "343e64e5-4882-4559-96d0-221c398288f3"}}
With request
iex> request = Ibanity.Request.token(token)
iex> Ibanity.PontoConnect.PaymentRequest.create(request, account_or_id, attributes)
{:ok, %PontoConnect.PaymentRequest{id: "343e64e5-4882-4559-96d0-221c398288f3"}}
delete(request_or_token, ids)
Delete a Payment Request by id
Takes a map with the following keys as second argument:
:account_id
:Ibanity.PontoConnect.Account
struct or account ID as a string:id
: resource ID as a string
examples
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"
With token
iex> Ibanity.PontoConnect.PaymentRequest.delete(token, ids)
{:ok, %Ibanity.PontoConnect.PaymentRequest{id: "953934eb-229a-4fd2-8675-07794078cc7d"}}
With request
iex> token
...> |> Ibanity.Request.token()
...> |> Ibanity.Request.application(:my_application)
...> |> Ibanity.PontoConnect.PaymentRequest.delete(%{
...> id: "953934eb-229a-4fd2-8675-07794078cc7d", account_id: account_or_id
...> })
{:ok, %Ibanity.PontoConnect.PaymentRequest{id: "953934eb-229a-4fd2-8675-07794078cc7d"}}
Error
iex> Ibanity.PontoConnect.PaymentRequest.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" => "paymentRequest"
}
}
]}
find(request, ids)
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:
:account_id
:Ibanity.PontoConnect.Account
struct or account ID as a string:id
: resource ID as a string
examples
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.PaymentRequest.find(token, ids)
{:ok, %Ibanity.PontoConnect.PaymentRequest{id: "953934eb-229a-4fd2-8675-07794078cc7d"}}
With request
iex> token
...> |> Ibanity.Request.token()
...> |> Ibanity.Request.application(:my_application)
...> |> Ibanity.PontoConnect.PaymentRequest.find(ids)
{:ok, %Ibanity.PontoConnect.PaymentRequest{id: "953934eb-229a-4fd2-8675-07794078cc7d"}}
Error
iex> Ibanity.PontoConnect.PaymentRequest.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" => "paymentRequest"
}
}
]}