Skip to main content
In this tutorial, you’ll learn how to model online card payments using Blnk. We’ll cover the money movement flow a card issuer needs to handle: creating an authorization hold, tracking the pending transaction, settling it when the processor clears it, and voiding it if it’s cancelled. By the end, you’ll know the exact ledger steps needed to support basic card payments.

How online card payments work

When your customer makes a purchase with a card, the process unfolds in two stages: authorization and settlement.
1

Authorization

The card network requests confirmation that the customer has sufficient funds.
2

Settlement

Hours or days later, the payment processor sends the final confirmation.

Prerequisites

Before starting, ensure you have:
  1. A running Blnk Core instance (e.g. at http://localhost:5001).
  2. An API key for Blnk (replace YOUR_API_KEY in the code examples). Required for authenticated requests.
  3. Optionally, you can connect your Blnk Core to your Blnk Cloud workspace to view your ledger data.
Okay, let’s dive in!

1: Create card account

Each card account will be represented with a ledger. The card balance will be created under this ledger.
1

Create a ledger

Create a ledger for the card account. This groups all of the balances for that customer in one place:
Save the ledger_id from the response. You’ll need it to create balances for the card account.
Create a ledger
2

Create customer identity

Create a customer identity to link all balances to the same customer identity:
Save the identity_id from the response. You’ll use this ID to link all balances to this customer.
Create a customer identity
3

Create card balance

Create a balance for the card account. This balance will track all card transactions:
Create card balance
Save the balance_id from the response. You’ll need it for creating transactions throughout this tutorial.

2: Authorization

Authorizing a card transaction means telling the processor that the customer has enough funds to cover the transaction, and they can proceed with the transaction. You can model this in Blnk with inflight transactions.
1

Money movement map

When a card transaction is authorized, money moves from the customer’s card balance to @World-USD (representing the external merchant):Card authorization mapExplore the map yourself hereThe transaction is created with inflight: true, so it remains pending until the payment processor clears it (or the transaction is voided).
2

Create an inflight transaction

Create an inflight transaction to authorize the payment. Setting inflight = true puts the transaction in a pending state until it’s settled or voided.
@World-USD is an internal balance that represents money leaving and coming into your system (like payments to merchants or payments from customers). Internal balances use the @ prefix and don’t require a balance ID.
Card authorization
3

Confirm authorization

If you use the queue, Blnk returns a QUEUED status in the API response, processes the transaction asynchronously, and emits a webhook event when complete.To confirm authorization, listen for these events:
For high traffic scenarios, Blnk supports various strategies to improve performance and reliability in your ledger. Learn more.
4

Handling fund reservation

When a transaction is INFLIGHT, the amount is reserved and unavailable until the transaction settles or is voided.Blnk handles this automatically. Each inflight transaction reduces the customer’s available balance. If the available balance is insufficient to cover a new transaction, that transaction is rejected.Any new transaction over $3,000 will be rejected. This prevents spending funds already reserved for pending card payments.Handling insufficient funds

3: Settlement

Once a transaction is settled by the payment processor, it means the money has finally been transferred to the recipient. Now, you can commit the inflight transaction. This moves the transaction from INFLIGHT (pending) to APPLIED (completed). If it was rejected or cancelled, you can void the transaction instead.
1

Money movement map

When you commit the inflight transaction, it finalizes the money movement that was authorized:Card settlement mapThe transaction status changes from INFLIGHT to APPLIED, completing the transfer.
2

Update the inflight transaction

Once clearing is received, update the inflight transaction from the authorization step depending on the outcome.
This approach allows your ledger to cleanly track when the transaction was initiated, and when it was completed based on your business requirements.
Commit the inflight transaction. This turns the transaction from INFLIGHT (pending) to APPLIED (completed).

Conclusion

You now have a fully functional card payment system built with Blnk Finance. This system can:
  • Create and manage card accounts with a ledger and card balance
  • Authorize card transactions using inflight transactions to reserve funds
  • Commit or void inflight transactions when they’re settled or rejected