Single Immediate Payments (SIP): initiate a payment authorisation and check payment status.
Creating a payment is a two-step process:
- Build the payment request payload and drive the user through
MoneyHub.Authwith amh:paymentclaim (seeMoneyHub.Claims.put_payment/2) and thepaymentscope - the user authorises the payment at their bank. - After the redirect back to your
redirect_uri, exchange thecodeviaMoneyHub.Auth.exchange_code/3and read the resulting payment id from the verifiedid_token'smh:paymentclaim (MoneyHub.Auth.IdToken.fetch/2).
Use status/3 to poll the resulting payment afterwards - Moneyhub
payments move through PENDING -> COMPLETED (or ERROR/REJECTED)
asynchronously, and are also reported via the paymentCompleted /
paymentPending / paymentError webhooks (see MoneyHub.Webhooks).
See Payments Overview, Single Immediate Payments, and Payments Status.
Summary
Functions
Builds the mh:payment claim value for a payment authorisation request.
Lists payments for the user identified by token.
Initiates a refund of a completed payment, where supported by the originating bank. See Reverse Payments.
Fetches a payment's current status by id.
Types
@type payment() :: map()
Functions
Builds the mh:payment claim value for a payment authorisation request.
attrs is merged onto required defaults - typically you'll provide at
least:
%{
"amount" => %{"amount" => 10.50, "currency" => "GBP"},
"creditorAccount" => %{
"identification" => %{"sortCode" => "010203", "accountNumber" => "12345678"}
},
"reference" => "Invoice 123"
}Pass a "payeeId" instead of "creditorAccount" to pay an existing
payee created via MoneyHub.Payees.create/3.
@spec list(MoneyHub.Config.t(), String.t(), keyword()) :: {:ok, [payment()]} | {:error, MoneyHub.Error.t()}
Lists payments for the user identified by token.
@spec refund(MoneyHub.Config.t(), String.t(), String.t(), map()) :: {:ok, map()} | {:error, MoneyHub.Error.t()}
Initiates a refund of a completed payment, where supported by the originating bank. See Reverse Payments.
@spec status(MoneyHub.Config.t(), String.t(), String.t()) :: {:ok, payment()} | {:error, MoneyHub.Error.t()}
Fetches a payment's current status by id.