- Create and manage multi-asset wallets in your ledger.
- Manage a pool of issued loyalty points.
- Award points to customers when they make purchases.
- Allow customers to redeem their points for discounts on future purchases.
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 loyalty points system, we have two workflows - awarding points and redeeming points.-
Awarding points:
Points are awarded to customers who qualify for the loyalty program. A customer purchase triggers the process: funds from the
Customer Main Walletare used for the purchase, contributing to@RevenueUSD. Once the purchase is completed, points are awarded from the@PointsPoolto theCustomer Points Wallet.@RevenueUSD: An internal balance representing the business’ revenue.@PointsPool: An internal balance tracking the total points issued to customers.
Explore the map yourself here
-
Redeeming points:
Customers can redeem points to receive discounts on purchases. When a customer applies points to a transaction, the discount is deducted from the original price.
Once the purchase is completed, the redeemed points are transferred from the
Customer Points Walletto@PointsPool.
Set up your implementation
Based on our map, we’ll implement the following:- Create the main and points balances for the customer.
- Initiate a purchase transaction and award points to the customer.
- Redeem the points in a second purchase transaction.
Prerequisites
Before starting, ensure you have:- A running Blnk Core instance (e.g. at
http://localhost:5001). - An API key for Blnk (replace
YOUR_API_KEYin the code examples). Required for authenticated requests. - Optionally, you can connect your Blnk Core to your Blnk Cloud workspace to view your ledger data.
Create your ledgers
First, we need to create ledgers to organize our wallets:Create balances for customer funds and loyalty points
Blnk Finance supports tracking of different assets (e.g., USD and POINTS) in your ledger. Now, let’s create the main wallet and points wallet for the customer:Awarding points after a purchase
When a customer makes a purchase, we need to:- Process the payment from the customer’s main wallet to the revenue account.
- Award loyalty points based on the purchase amount.
Redeeming points during a purchase
When you make a purchase, you can use your loyalty points to get a discount. In our example, 10 points = 1 USD. For example, a customer has 500 points and wants to buy something that costs $100:- They choose to use 200 points from their
Points Wallet. - Those 200 points convert to $20 (at the 10 points = $1 rate)
- Their final cost to pay from their
Main Walletwould be $80 instead of $100.
- Take points from the
Customer Points Walletto@PointsPool. - Convert the points to its equivalent dollar value, apply it as discount, and calculate the final cost for the customer.
- Charge the
Customer Main Walletwith the final discounted cost.
Conclusion
You now have a basic loyalty points system built with the Blnk Ledger. This system enables you to award points to customers based on their purchases and allows them to redeem those points for discounts. The system is flexible and can be extended with additional features like:- Points expiry management
- Tiered rewards based on customer spending levels
- Special promotions with bonus points
- Point transfers between customers