Overview
In this tutorial, we’ll build a simple escrow payment workflow using Blnk’s inflight transaction feature. Here’s what we’ll do:- Initiate an escrow transaction.
- Verify that all conditions have been met.
- Update the transaction based on the conditions.
- Handle alternative use cases cases like partial fulfilment.
Designing your map
Before writing code, it’s crucial to design a money movement map that outlines how money moves in your system. This serves as the blueprint for your implementation. For our escrow payments workflow, here’s our map: Read more: Inflight transactions → This map shows three key aspects of the escrow fund flow:Buyer
initiates transaction toSeller
.- Transaction is held inflight until the escrow conditions are met or not.
- Transaction is completed or discarded depending on the inflight status, and the balances get updated.
Set up your implementation
Based on our map, we’ll implement the following steps:- Initiate a transaction with inflight between the
Buyer Wallet
and theSeller Wallet
. - Update the status of our inflight transaction.
- Commit if the escrow payment is successful.
- Void if the escrow payment failed.
Prerequisites
Before starting, ensure you have:- A running Blnk server instance (e.g. at
http://localhost:5001
). - An API key for Blnk (replace
YOUR_API_KEY
in the code examples). Required for authenticated requests. - The Blnk CLI installed or a connected Blnk Cloud workspace to view your ledger data.
- Balances created for the buyer and seller wallets in your Blnk Ledger. Learn how: Building a Wallet Management System with Blnk →.
- Funded the buyer wallet balance in ledger.
Initiate escrow transaction
Create a transaction withinflight
enabled.
When
inflight
is enabled, the transaction remains pending, ensuring that neither the source nor the destination balance is affected until the specified conditions are met.Path 1: Successful escrow payment
For a successful escrow payment, commit the inflight transaction to apply it to the buyer and seller balances:Path 2: Failed escrow payment
If the escrow failed, void the inflight transaction instead:Path 3: Partial escrow payment
Escrow payments can also be fulfilled in bits, meaning you can complete part of the total amount over time, e.g., for a $100 transaction, you can commit $30, then $40, then the remaining $30 later.You can also make multiple partial commits and void the remaining inflight amount if needed.
Conclusion
This tutorial demonstrated how to build a secure escrow payment system using Blnk’s inflight feature, enabling safe transactions for buyers and sellers. The system includes initiating escrows, tracking confirmations, releasing funds upon mutual agreement, and handling cancellations. With Blnk’s flexible architecture, you can easily adapt this escrow system to various business models, including from marketplace transactions and freelancer payments to real estate deals and complex business contracts.Inflight transactions
Learn everything about inflight (plus best practices)