The objective of this library is to quickly check available balance for the wallet and act accordingly:
- deny access with 402 status code,
- or withdraw relevant amount of credit and grant access.
The identity behind the API call must be resolved (authenticated) by your code. You can use DamaxApiAuthBundle to authenticate via API keys or JWT.
Your logic decides how much credit to deposit for each payment user makes:
- be it a fixed amount of credit for e.g. $5;
- map $5 to 500 points i.e. 1 cent = 1 credit;
- or something completely different.
See usage examples how to notify other systems about purchases.
Non-negative integer value. Could be represented as amount of cents on user's balance or whatever suits your design.
Identity of authenticated user created by IdentityFactory. Before charging Credit user must be successfully authenticated.
Product describes the amount of Credit you charge for specific API endpoint. There must be at least one product defined. Resolved through product Resolver based on incoming request.
Created by WalletFactory based on provided Identity. You can deposit, withdraw or fetch available Credit from the Wallet.
Store charges Identity for the price of resolved Product returning a purchase Receipt.
Read next how to configure paid APIs.