Learn how to implement a loyalty points system with Blnk.
In this tutorial, we will build a simple loyalty points system using the Blnk Ledger. Here’s what we’ll do:
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.
For this tutorial, we’ll use the Blnk TypeScript SDK and Blnk Go SDK for the implementation. If you prefer, you can also refer to the API reference for details on the available endpoints.
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 Wallet are used for the purchase, contributing to @RevenueUSD.Once the purchase is completed, points are awarded from the @PointsPool to the Customer Points Wallet.
@RevenueUSD: An internal balance representing the business’ revenue.
@PointsPool: An internal balance tracking the total points issued to customers.
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 Wallet to @PointsPool.
@PointsPool records all issued points using the debit_balance parameter and tracks all redeemed points using the credit_balance parameter.
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:
As shown above, you can set custom precision for each currency, like 100 for USD or 1 for POINTS in our example.For ledger accuracy, ensure the source and destination currencies match when posting transactions.
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 Wallet would be $80 instead of $100.
Behind the scenes, here’s what we’ll do:
Take points from the Customer Points Wallet to @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 Wallet with the final discounted cost.
Redeem points and charge the discounted purchase amount:
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
By leveraging Blnk’s transaction system, you can ensure all point movements are accurately tracked and reconciled, providing a reliable foundation for your loyalty program.