guiziweb / sylius-token-plugin
Prepaid token wallet for Sylius: customers buy tokens and spend them on services.
Package info
github.com/Guiziweb/GuiziwebSyliusTokenPlugin
Type:sylius-plugin
pkg:composer/guiziweb/sylius-token-plugin
Requires
- php: ^8.2
- doctrine/orm: ^3.0
- sylius/sylius: ^2.1
Requires (Dev)
- behat/behat: ^3.16
- dbrekelmans/bdi: ^1.4
- dmore/behat-chrome-extension: ^1.4
- dmore/chrome-mink-driver: ^2.9
- friends-of-behat/mink: ^1.11
- friends-of-behat/mink-browserkit-driver: ^1.6
- friends-of-behat/mink-debug-extension: ^2.1
- friends-of-behat/mink-extension: ^2.7
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.1
- friends-of-behat/symfony-extension: ^2.6
- friends-of-behat/variadic-extension: ^1.6
- nyholm/psr7: ^1.8
- phpstan/phpstan: ^1.12
- phpstan/phpstan-doctrine: ^1.3
- phpstan/phpstan-phpunit: ^1.4
- phpstan/phpstan-webmozart-assert: ^1.2
- phpunit/phpunit: ^10.5
- sylius-labs/coding-standard: ^4.4
- sylius-labs/suite-tags-extension: ~0.2
- sylius/sylius-rector: ^2.0
- sylius/test-application: ^2.0.0@alpha
- symfony/browser-kit: ^6.4 || ^7.4
- symfony/debug-bundle: ^6.4 || ^7.4
- symfony/dotenv: ^6.4 || ^7.4
- symfony/http-client: ^6.4 || ^7.4
- symfony/intl: ^6.4 || ^7.4
- symfony/runtime: ^6.4 || ^7.4
- symfony/web-profiler-bundle: ^6.4 || ^7.4
- symfony/webpack-encore-bundle: ^2.2
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-05 12:28:16 UTC
README
Sylius Token Plugin
Buy tokens, spend them on anything. Prepaid wallet for Sylius, the way AI SaaS products bill their users.
How it works
Customers buy token packs: ordinary Sylius products that grant tokens instead of being shipped. Tokens land in a wallet when the payment completes, and your own code spends them against a price list that says what each action costs.
$this->tokenConsumer->consume($customer, $price, 'image-generation-4521');
Every movement is written to an append-only ledger. Tokens are held in batches, each with its own acquisition date, purchase price and optional expiry, and spent oldest-expiring-first. A balance is always derived from those batches, so an expired batch stops counting the moment it expires.
Requirements
- PHP ^8.2
- Sylius ^2.1
- MySQL, MariaDB or PostgreSQL
Quick install
This plugin ships a Symfony Flex recipe. With the Guiziweb recipe endpoint configured in your project (see linked repo), the install boils down to:
composer require guiziweb/sylius-token-plugin
The recipe registers the bundle and imports the configuration and the routes. One
step cannot be automated: apply TokenPackTrait to your own ProductVariant
entity, since a pack grants tokens through a field carried by your entity. Do it
before running the migrations:
bin/console doctrine:migrations:migrate
Full step-by-step guide (with and without Flex): installation.
Documentation
- Installation - full setup steps
- Usage - selling packs, spending tokens, adjusting balances
- Extending - expiration policy, overriding models
License
MIT - see LICENSE.