Skip to content
This repository was archived by the owner on Feb 12, 2023. It is now read-only.

Latest commit

 

History

History
52 lines (30 loc) · 1.91 KB

File metadata and controls

52 lines (30 loc) · 1.91 KB

Concepts

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.

Prerequisites

Authentication

The identity behind the API call must be resolved (authenticated) by your code. You can use DamaxApiAuthBundle to authenticate via API keys or JWT.

Balance history

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.

Library

Credit

Non-negative integer value. Could be represented as amount of cents on user's balance or whatever suits your design.

Identity

Identity of authenticated user created by IdentityFactory. Before charging Credit user must be successfully authenticated.

Product

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.

Wallet

Created by WalletFactory based on provided Identity. You can deposit, withdraw or fetch available Credit from the Wallet.

Store

Store charges Identity for the price of resolved Product returning a purchase Receipt.

Next

Read next how to configure paid APIs.