Record a transaction
Overview
This guide shows you how to record a transaction into your Blnk Ledger.
There are 3 main ways a transaction can be categorized:
- Money is received from an external balance (accounts, cards, crypto, etc.)
- Money is sent out to an external balance (accounts, wallets, etc.)
- Money is sent between balances in your application.
An external balance refers to a source or destination that isn’t owned by your application. This includes other bank accounts, card payment providers, payout providers, etc.
To successfully post or record a transaction, the following fields are required:
Field | Description | Required | Type |
---|---|---|---|
amount | The transaction amount. | Yes | float |
reference | Transaction reference | Yes | string |
currency | Short code for your asset class. See also → Defining asset classes. | Yes | string |
precision | Converts the transaction amount to the lowest unit possible. See also → Understanding precision. | No | int64 |
source | Sender’s balance ID | Yes | string |
destination | Recipient’s balance ID. | Yes | string |
description | Description or narration of the transaction. | No | string |
meta_data | Custom data associated with the transaction | No | object |
There are multiple ways to manage
Source
andDestination
for transactions that involve an external balance.However, it is best to create a dedicated balance,
@World
, to represent external balance, i.e., when receiving money from an external balance, it is"source": "@World"
and when sending money to an external balance, it is “destination: "@World"
.Go to Internal balances for more information on how to use and manage
@World
.
How Blnk records transactions
Blnk cares about the accuracy, security and integrity of your transaction data. As a result, all transaction records have 2 main properties — immutability and idempotency.
Immutability
All transactions in Blnk are immutable.
Once they have been recorded, they cannot be altered or tampered with. This ensures the accuracy and unchangeability of the transaction record. See also → Transaction Hashing.
Idempotency
All transactions in Blnk are idempotent.
This ensures that performing the same operation multiple times results in the same outcome as doing it once. This property is crucial for maintaining consistent outcomes regardless of how many times a transaction is repeated, especially in scenarios where network errors or other issues might cause transaction failures.
Blnk ensures idempotency through the use of a unique reference
for every transaction. This is why it is required for you to provide one when recording a transaction.
Record a transaction
Send a request to the Record Transaction endpoint and input the required fields.
Passing detailed data with the meta_data
object is encouraged; it provides you with 360-degree insights about each transaction record. Examples of data you can pass include sender_name
, account_number
, bank_name
, receiver_name
, payment_id
, ip_address
, location
, payment_method
, etc.
It’s strongly encouraged to always pass a
precision
value that converts your amount to its lowest unit possible to ensure correctness when computing your balances. To learn more, read: Understanding precision.
Field | Description | Type |
---|---|---|
id | Unique id for the transaction. This is generated by Blnk. | string |
precise_amount | The transaction amount after the precision value has been applied. | integer |
status | Current state of your transaction record. See below. | string |
created_at | Date and time of the transaction record. | string |
Transaction statuses
There are three primary statuses for any transaction in the Blnk Ledger.
-
QUEUED
: This is the default status of any new transaction record. It means your transaction record has been accepted by Blnk, added to a queue and is waiting to be applied.See also → Why Blnk queues transactions.
-
APPLIED
: The status is updated to applied when the participating balances in the transaction get updated with the transaction amount. Only transaction records with theAPPLIED
status are deemed complete and permanently stored in the Blnk Ledger.E.g., if ₦1,000 was sent from
bal_01
tobal_02
;- the default transaction status is
QUEUED
; - the status changes to
APPLIED
when ₦1,000 has been deducted frombal_01
and added tobal_02
.
- the default transaction status is
-
REJECTED
: The status of a transaction is updated to rejected if any of the conditions required for a successful transaction isn’t met.
Blnk focuses on helping you efficiently keep the records of how money moves in your application. Whether a transaction is successfully processed or not is managed by you and your payment partners.
Conditions required for a transaction
- The participating balances (
source
anddestination
) must have the same asset class (currency
) as specified in the transaction request. - The
source
must have enough funds to process the transaction. - Overdraft must be enabled if the transaction has to happen but the
source
has insufficient funds.
Track a transaction
To track a transaction, call the Get Transaction endpoint and pass the id
of the transaction in the URL.
We also send notifications via webhook events to let you know the updated status of a transaction:
transaction.applied
: Sent when the transaction status is updated toAPPLIED
.transaction.rejected
: Sent when the transaction status is updated toREJECTED
.
See also
Setting up internal balances
Learn how to set up internal balances
Understanding precision
Improve the correctness of your ledger
Handling concurrency
How Blnk queues transactions
Managing notifications
Set up how you receive notifications
Need help?
Are you stuck? Do you have a question that isn’t answered in this doc? Have you run into a problem you can’t solve? Want to file a bug report?
Join our Discord server and share your questions/thoughts with other developers building financial applications like you.
Was this page helpful?