Token Deduction Logic

This page explains the process of using tokens for viewing crop prices in the Bolbhav app.

In the Bolbhav app, users who have purchased tokens can utilize them for viewing crop prices. However, users who have not purchased a yearly plan will need to pay tokens for accessing crop data in any mandi. Endpoint Triggered:

Purpose of this API:

  • This API is utilized for accessing crop price data in the Bolbhav app.

  • It first verifies if the user is a Bolbhav Plus member. If not, it proceeds to deduct tokens for crop price viewing, unless already deducted.

Token Deduction Logic:

  • The API triggers the reduce_token_for_crop_price_view function, which verifies whether the user has already viewed crop prices today.

  • If the user hasn't viewed crop prices today, it checks if the user has sufficient tokens in their wallet (at least 4 tokens) and if crop prices are available for either today or yesterday.

  • If the conditions are met, tokens are deducted from the user's wallet for crop price viewing.

Usage:

  • This API is used in versions 6.0.0 and higher for facilitating crop price viewing.

  • In versions prior to v6.0.0, a similar API (mandi-crop-data) was used, but without the Bolbhav Plus membership verification. Additionally, it had limited crop metrics data and was specific to certain crops and mandis.

Database transactions

Token Deduction from User Membership Wallet (Silver Token):

  • Source Wallet ID: The user's membership wallet ID serves as the source of the transaction.

  • Target Wallet ID: The bank's membership wallet ID is designated as the target for receiving the deducted tokens.

  • Amount: 4000 tokens are debited from the user's membership wallet, equivalent to 4 tokens. (In the database, tokens are stored as multiples of 1000.)

  • Reason: The reason field provides context for the transaction, indicating the purpose as the usage for viewing crop receipts. In Hindi, this is represented as "फसल की रसीदें देखीं".

  • Ref ID: The reference ID stored in the Wallet Ledger table is "crop_price_viewed", which helps track the transaction back to its origin.

Last updated