An inflight transaction keeps your transaction on hold until you take further action. When enabled using the inflight parameter, transactions follow a specialized workflow that maintains separate balances for pending operations.

It is best used when you want to wait for feedback or authorization before a transaction is applied in your ledger.

Before we start,

Remember that all ledger balances in Blnk have 6 main balance parameters:

  1. balance: This shows the current value held in the ledger balance.
  2. credit_balance: This is the total sum of all amounts received by a ledger balance.
  3. debit_balance: This is the total sum of all amounts sent by a ledger balance.
  4. inflight_balance: This shows the net amount held inflight for a balance.
  5. inflight_credit_balance: This is the total sum of all amount waiting to be received by a ledger balance.
  6. inflight_debit_balance: This is the total sum of all amount waiting to be deducted from a ledger balance.

How Inflight works

Record transaction with Inflight

Record inflight
{
    "amount": 100,
    "precision": 100,
    "reference": "ref_001adcfgf",
    "currency": "USD",
    "source": "bln_28edb3e5-c168-4127-a1c4-16274e7a28d3",
    "destination": "bln_ebcd230f-6265-4d4a-a4ca-45974c47f746",
    "description": "For vacation",
    "inflight": true,
    "inflight_expiry_date": "2024-12-21T01:36:46+01:00"
}

Use the inflight_expiry_date to set when you want the transaction to expire if it hasn’t been committed or voided yet in that time.

Always format the date input as ‘YYYY-MM-DDTHH:MM:SS+00:00’ (e.g., 2024-04-22T15:28:03+00:00), where +00:00 specifies the timezone. It is UTC by default.

When recording a new transaction with Inflight, the system:

  1. Initializes the transaction in the QUEUED state.
  2. Processes and moves the transaction to INFLIGHT.
  3. Maintains the original balances while tracking the pending amounts in inflight balance parameters.

Balance management

Blnk uses three balance parameters for accurate tracking of inflight amounts:

inflight_credit_balance: Pending credits awaiting processing
inflight_debit_balance:  Pending debits awaiting processing
inflight_balance:        Net inflight amount (credit - debit)

Balance tracking example

Consider an inflight transaction where $100 is transferred from balance_A to balance_B:

Initial State:
balance_A: $200 available funds
balance_B: $0 available funds

Transaction Amount: $100
balance_idMain balanceInflight balanceInflight creditInflight debit
balance_A200-1000100
balance_B01001000

In this scenario:

  • balance_A shows a negative inflight balance (-100) because funds are pending outflow.
  • balance_B shows a positive inflight balance (100) because funds are pending inflow.
  • The main balances remain unchanged until the transaction is committed.

Updating Inflight

To act on an inflight transaction, use the Update Inflight endpoint:

PUT /transactions/inflight/{transaction_id}

There are two ways to act on an inflight transaction: commit or void.

1. Commit inflight

Request
{
    "status": "commit"
}
  • Indicates transaction conditions are met.
  • Triggers balance updates, and clears the inflight balances.
  • Creates new transaction record with APPLIED status.

In our example, after commit:

balance_idMain balanceInflight balanceInflight creditInflight debit
balance_A100000
balance_B100000

2. Partial commits

Request
{
    "status": "commit",
    "amount": 40
}
  • Only the specified amount is applied to the main balances.
  • The remaining amount is left inflight.
Partial commit amount must not exceed remaining inflight amount.

Our example after a partial commit:

balance_idMain balanceInflight balanceInflight creditInflight debit
balance_A160-60060
balance_B4060600

3. Void inflight

Request
{
    "status": "void"
}
  • Indicates transaction conditions were not met.
  • Creates new transaction record with VOID status.
  • Resets inflight balances without affecting actual balances.

4. Expired inflight

A transaction will stay inflight indefinitely unless it gets committed, void, or gets expired. To set a time limit on an inflight transaction, include the inflight_expiry_date parameter in the request body.

  • Indicates transaction remained INFLIGHT past specified expiry date.
  • Creates new record with a VOID status.
  • Discards the transaction and resets the inflight balances.

Always format the inflight_expiry_date date input as ‘YYYY-MM-DDTHH:MM:SS+00:00’ (e.g., 2024-04-22T15:28:03+00:00), where +00:00 specifies the timezone. It is UTC by default.

Managing insufficient funds

When working with inflight transactions, your system must always consider both the actual balance and any pending inflight amounts. This ensures that the source always has sufficient funds to complete the inflight transaction when it’s committed.

To do this, compute an available_balance for your customers indicating the amount available for them to spend on new transactions:

available_balance = balance - inflight_debit_balance

To check for insufficient funds before initiating an inflight transaction:

  1. Query the source balance, and compute the available_balance:

    GET /balances/<source-balance-id>
    
  2. Compare the new transaction amount against available_balance:

    • If amount ≤ available_balance: Proceed with transaction.
    • If amount > available_balance: Handle gracefully in your application by notifying the customer of insufficient funds.

With this approach:

  • You ensure that pending inflight transactions will always be committed when they need to.
  • Customers are prevented from spending funds that are waiting to be deducted from their balance.

Inflight for multiple sources/destinations

Multiple sources in Blnk allow you send from multiple sources to a single destination simultaneously, while multiple destinations allow you to send from one source to multiple destinations.

Learn more: Multiple Sources and Multiple Destinations.

1

Initiate inflight

When initiating inflight transactions with multiple sources/destinations, enable the inflight feature in your transaction request. Here’s how to structure your request:

Request
{
    // ... other transaction details
    "inflight": true
}

When using multiple sources/destinations, each transaction is recorded separately in the ledger.

However, these transactions are linked together through a parent_transaction attribute, which you’ll receive in the response to your transaction request. This parent_transaction helps you track and manage related transactions as a single unit.

2

Update Inflight

To commit or void all transactions at once, call the Update Inflight endpoint and pass the transaction_id from your response.

PUT http://YOUR_BLNK_INSTANCE_URL/transactions/inflight/{parent_transaction}

Use cases

Useful applications for inflight include:

  • For managing KYC limits: When an account crosses its KYC limits determined by your application, you can hold all deposits with inflight until the user’s KYC is updated.
  • For escrow: Inflight allows you to easily implement escrow features in your application, allowing your users see the amount being held (but not available to them to spend).
  • For card payouts: Hold amounts in an inflight balance until the card is authorized by the payment processor for successful payment.
  • For external payouts: Hold amount in an inflight balance while your payout is being processed by your provider; only release it when the transaction is successful or failed.

Need help?

We are very happy to help you make the most of Blnk, regardless of whether it is your first time or you are switching from another tool.

To ask questions or discuss issues, please contact us or join our Discord community.

Get access to Blnk Cloud.

Manage your Blnk Ledger and explore advanced features (access control & collaboration, anomaly detection, secure storage & file management, etc.) in one dashboard.