tourze / prepaid-card-bundle
Symfony bundle for prepaid card management system
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/tourze/prepaid-card-bundle
Requires
- doctrine/collections: ^2.3
- doctrine/dbal: ^4.0
- doctrine/doctrine-bundle: ^2.13
- doctrine/orm: ^3.0
- doctrine/persistence: ^4.1
- easycorp/easyadmin-bundle: ^4
- knplabs/knp-menu: ^3.7
- monolog/monolog: ^3.1
- nesbot/carbon: ^2.72 || ^3
- psr/log: ^3|^2|^1
- symfony/config: ^7.3
- symfony/console: ^7.3
- symfony/dependency-injection: ^7.3
- symfony/doctrine-bridge: ^7.3
- symfony/http-foundation: ^7.3
- symfony/http-kernel: ^7.3
- symfony/property-access: ^7.3
- symfony/security-core: ^7.3
- symfony/serializer: ^7.3
- tourze/arrayable: 1.*
- tourze/bundle-dependency: 1.*
- tourze/doctrine-indexed-bundle: 1.0.*
- tourze/doctrine-ip-bundle: 1.1.*
- tourze/doctrine-random-bundle: 1.0.*
- tourze/doctrine-snowflake-bundle: 1.1.*
- tourze/doctrine-timestamp-bundle: 1.1.*
- tourze/doctrine-track-bundle: 1.1.*
- tourze/doctrine-user-bundle: 1.0.*
- tourze/easy-admin-enum-field-bundle: 1.0.*
- tourze/easy-admin-menu-bundle: 1.0.*
- tourze/enum-extra: 1.0.*
- tourze/symfony-aop-bundle: 1.0.*
- tourze/symfony-aop-doctrine-bundle: 1.0.*
- tourze/symfony-aop-lock-bundle: 1.0.*
- tourze/symfony-cron-job-bundle: 1.1.*
- tourze/symfony-dependency-service-loader: 1.0.*
Requires (Dev)
- doctrine/data-fixtures: ^2.0
- doctrine/doctrine-fixtures-bundle: ^4.0
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
- tourze/phpunit-base: 1.*
- tourze/phpunit-doctrine-entity: 1.*
- tourze/phpunit-enum: 1.*
- tourze/phpunit-symfony-kernel-test: 1.0.*
- tourze/phpunit-symfony-unit-test: 1.*
- tourze/phpunit-symfony-web-test: 1.*
This package is auto-updated.
Last update: 2025-11-18 05:21:14 UTC
README
Prepaid card management module - Provides functionality for creating, consuming, balance management and expiration handling of prepaid cards
Features
- Prepaid Card Management - Create, activate, recharge, and consume prepaid cards
- Balance Management - Real-time balance queries and consumption tracking
- Expiration Handling - Automatic checking and processing of expired cards
- Consumption Records - Detailed consumption history tracking
- Contract Management - Prepaid order and contract association
- Multiple Card Types - Support for one-time payment and deposit settlement
- Automated Tasks - Scheduled expiration checks and status updates
Installation
composer require tourze/prepaid-card-bundle
Main Entities
Card (Prepaid Card)
- Card number and password management
- Face value and balance tracking
- Status management (valid/expired/insufficient balance)
- Activation time and expiration time
Consumption (Consumption Record)
- Consumption title and amount
- Associated order ID
- Refundable amount management
- Creation time and IP logging
Contract (Prepaid Contract)
- Prepaid order management
- Cost tracking
- Refund processing
- Consumption record association
Console Commands
prepaid-card:expire-check
Automatically check and handle expired prepaid cards
php bin/console prepaid-card:expire-check
Features:
- Check cards with expired time and update status to
EXPIRED - Check cards with zero balance and update status to
EMPTY - Process up to 500 cards per batch
- Automatically executed on schedule (runs every minute)
Processing Logic:
- Find cards with status
VALIDand expired time passed - Update these cards' status to
EXPIRED - Find cards with status
VALIDand balance ≤ 0 - Update these cards' status to
EMPTY
Usage
Basic Usage
use PrepaidCardBundle\Service\PrepaidCardService; // Inject service private PrepaidCardService $prepaidCardService; // Check if balance is sufficient if ($this->prepaidCardService->hasEnoughBalance($card, $amount)) { // Execute consumption $this->prepaidCardService->consume($card, $amount, $title); }
Card Status Management
use PrepaidCardBundle\Enum\PrepaidCardStatus; // Check card status if ($card->getStatus() === PrepaidCardStatus::VALID) { // Card is valid and can be used }
Card Types
use PrepaidCardBundle\Enum\PrepaidCardType; // One-time full payment $card->setType(PrepaidCardType::ONE_TIME); // Deposit with later settlement $card->setType(PrepaidCardType::AFTER);
Configuration
Configure in config/packages/prepaid_card.yaml:
# Prepaid card module configuration prepaid_card: # Expiration check frequency (cron expression) expire_check_cron: '* * * * *' # Maximum number of cards processed per batch batch_size: 500
Database Schema
ims_prepaid_card- Main prepaid card tableims_prepaid_consumption- Consumption record tableims_prepaid_contract- Prepaid contract tableims_prepaid_company- Card issuing company tableims_prepaid_package- Card package tableims_prepaid_campaign- Marketing campaign table
Enum Types
PrepaidCardStatus (Card Status)
VALID- ValidEXPIRED- ExpiredEMPTY- Insufficient balanceINACTIVE- Not activated
PrepaidCardType (Card Type)
ONE_TIME- One-time full paymentAFTER- Deposit with later settlement
PrepaidCardExpireType (Expiration Type)
SAME_WITH_CARD- Same as card validity periodAFTER_ACTIVATION- After activation
Events and Listeners
The module provides the following events:
- Card creation event
- Consumption record creation event
- Balance change event
- Status change event
Extensibility
You can extend functionality through:
- Implementing custom card types
- Adding additional consumption validation rules
- Customizing expiration handling logic
- Integrating third-party payment systems
Reference Documentation
License
This project is licensed under the MIT License - see the LICENSE file for details.