Building a customer loyalty points system can significantly increase user engagement and retention in your eCommerce or fintech app.

In this example, you’ll learn how to implement a loyalty point management system, process transactions, and ensure smooth and secure workflows, all with the Blnk Ledger.

We’ll learn about:

  1. Defining and creating your ledger structure
  2. Balance (wallet) creation
  3. Awarding points
  4. Redeeming points
  5. Best Practices (with Inflight)

1. Ledger structure

The entry point of the Blnk ledger system is ledger folders. These folders serve as a way to group and manage assets, accounts, and balances that fit your product or organization’s structure.

In this guide, we’ll use a simple structure:

  • Loyalty Points Ledger: Contains all loyalty point accounts for customers

The ledger structure is flexible and can be customized based on your specific needs. For instance, you could group by users instead of currencies, or use a combination of both.

See also:

Creating a loyalty points ledger

View your ledgers in your terminal:

bash
blnk ledgers list 

Always store the ledger_id in your database. You’ll need it for future operations related to this ledger.

2. Balance (wallet) creation

Blnk uses the concept of ledger balances to manage accounts/balances in a ledger. In this example, we’ll create loyalty point accounts for customers. Each loyalty point account will be represented as a balance in the ledger.

See also:

Creating a loyalty points account for a customer

View your balances in your terminal:

bash
blnk balances list

The balance_id is crucial. Always store this in your database and associate it with the customer. You’ll use this ID for all future transactions involving this loyalty point account.

3. Awarding points

Whenever a customer makes a purchase, you can award them loyalty points. We’ll use the Inflight feature to manage loyalty point transactions.

See also:

Awarding points for a purchase

View your transactions in your terminal:

bash
blnk transactions list

When you use inflight on your transaction, you need to commit or void the transaction to complete the transaction workflow. To learn more, see Applying inflight.

4. Redeeming points

Customers can redeem their loyalty points for rewards or discounts. We’ll use the Inflight feature to manage point redemptions.

Redeeming points

When you use inflight on your transaction, you need to commit or void the transaction to complete the transaction workflow. To learn more, see Applying inflight.

See also

Managing side effects with Inflight

A deep-dive guide into how to implement Inflight in your application.

Best practices (with Inflight)

  1. Available Balance Calculation: In your application, calculate the available balance to prevent users from accessing funds that are held in Inflight transactions. This can be done as follows:
    const availableBalance = balance - inflight_debit_balance;
    
  2. Error Handling: Implement robust error handling in your Inflight process. If a commit or void operation fails, you may need to retry or escalate to manual intervention.
  3. Customer Communication: Implement a system to notify customers about the status of their transactions, especially when they are held in Inflight. Clear communication can enhance customer trust and satisfaction.
  4. Reconciliation: Regularly reconcile your internal records with Blnk’s transaction logs to ensure accuracy. Pay special attention to Inflight transactions. Blnk v1 will support reconciliation features built into the ledger, which can aid in this process.
  5. Webhook Authentication: In a production environment, implement a mechanism to verify that webhooks are genuinely from your payment provider. This helps in maintaining the integrity and security of your transaction processing.
  6. Idempotency: Ensure your webhook handler is idempotent. Providers may send the same webhook multiple times, so your system should handle duplicate notifications gracefully. This prevents double-processing of transactions.
  7. Monitoring: Set up monitoring and alerting for your webhook endpoint and Inflight transactions. This can help you quickly identify and respond to any issues in the payment verification process.
  8. Data Security: Always ensure that sensitive card details are securely managed and stored. Mask or encrypt card numbers, CVVs, and other sensitive information when storing or displaying them.
  9. Transaction State Management: Use metadata to manage the state of virtual cards and transactions effectively. For example, track the transaction verification status (e.g., VERIFIED, DECLINED) in the metadata.
  10. Compliance: Ensure that your virtual card issuance and transaction processing comply with relevant regulations and standards, such as PCI-DSS for handling card data securely.
  11. Testing: Thoroughly test your virtual card issuance and transaction processing flows, including Inflight handling, to identify and resolve any issues before going live.

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.