Search by

guiziweb / sylius-token-plugin

Prepaid token wallet for Sylius: customers buy tokens and spend them on services.

Maintainers

Package info

github.com/Guiziweb/GuiziwebSyliusTokenPlugin

Type:sylius-plugin

pkg:composer/guiziweb/sylius-token-plugin

Transparency log

Statistics

Installs: 4

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

This package is auto-updated.

Last update: 2026-09-05 12:28:16 UTC


README

Sylius Logo.

Sylius Token Plugin

Build status Latest version PHP version PHPUnit Behat PHPStan max ECS License

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.