As stated in installation document the first thing you need to configure is payment listener:
damax_chargeable_api:
listener:
matcher: ^/api/services/Charge payment for requests covered by above regex. You can omit this setting if all routes require payment.
It is possible to be more specific and process only certain HTTP verbs or IP addresses:
damax_chargeable_api:
listener:
matcher:
path: ^/api/services/
methods: [GET, POST]
ips: [192.168.2.100, 192.168.2.105]By default a product named API is registered with price of 1 (one) credit.
A price of default product is configurable:
damax_chargeable_api:
product: 5Or you can change the name of default product:
damax_chargeable_api:
product: ScoringRegister multiple products with different price points:
damax_chargeable_api:
product:
- { name: Scoring Fast, price: 3, matcher: ^/api/scoring/fast }
- { name: Scoring Full, price: 8, matcher: ^/api/scoring/full }
- { name: API services, price: 1 } # remaining paid requestA matcher key can be configured in same way as in listener configuration.
In most simplest form you can resolve to same identity for all requests:
damax_chargeable_api:
identity: john.doe@domain.abcAbove configuration is useful for testing purposes or when you have a single client.
Use authenticated user from security component:
damax_chargeable_api:
identity:
type: securityThis is also the default configuration.
You can register custom service by implementing IdentityFactory:
damax_chargeable_api:
identity:
type: service
factory_service_id: app.chargeable_api.identity_factoryFor testing purposes fixed wallet is the best choice. This is in memory representation of users' balances:
damax_chargeable_api:
wallet:
'john.doe@domain.abc': 10
'jane.doe@domain.abc': 50In other words, there is fixed amount of credit on user's balance for each payment request.
For Redis:
damax_chargeable_api:
wallet:
type: redis
wallet_key: wallet
redis_client_id: snc_redis.default # service implementing Predis\ClientInterfaceFor Mongo:
damax_chargeable_api:
wallet:
type: mongo
mongo_client_id: MongoDB\Client
db_name: project
collection_name: userRegister custom service by implementing WalletFactory:
damax_chargeable_api:
wallet:
type: service
factory_service_id: app.chargeable_api.wallet_factoryRun config:dump-reference to see all available options:
$ ./bin/console config:dump-reference damax_chargeable_apiRead next on usage examples.