Download the PHP package wasimrasheed/e-wallet without Composer
On this page you can find all versions of the php package wasimrasheed/e-wallet. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package e-wallet
EWallet Package
Overview
The EWallet package is a flexible and modular Laravel package that provides essential functionality for managing wallets, transactions, payment methods, and activities. The package includes various controllers, models, and validation layers to ensure robust data handling and secure operations.
Features
- Wallet Management: Create, update, delete, and retrieve wallet information.
- Transaction Handling: Manage all operations related to transactions.
- Payment Method Management: Support for various payment methods with CRUD operations.
- Activity Tracking: Record and manage wallet-related activities.
- Validation: Custom validation logic for each resource to ensure data integrity.
Installation
-
Install the package via composer:
-
Register the service provider in config/app.php if not using auto-discovery:
- Publish and run the migrations:
Usage
Once the package is installed and configured, you can interact with the package's controllers and models. The key classes included are:
WalletController
The WalletController is responsible for managing wallet records. It handles operations such as creating a new wallet, updating existing wallets, retrieving wallet details, and deleting wallets. The key functions include:
Wallet Validation Rules
createValidationRules
:
-
user_id
:required|integer|exists:users,id
Must be a valid user ID that exists in the users table. -
phone_number
:required|string|size:11
You may adjust the size if your phone numbers differ in length. -
is_verified
:required|boolean
Ensures it is either true or false. -
balance
:required|numeric|min:0
Must be a non-negative numeric value. -
balance_calculator
:required|numeric|min:0
Must be a non-negative numeric value. -
balance_hash
:required|string
Must be a string value. status
:required|boolean
Ensures it is either true or false.
updateValidationRules
:
-
phone_number
:sometimes|string|size:11
You may adjust the size if your phone numbers differ in length. -
balance
:sometimes|numeric|min:0
Must be a non-negative numeric value. -
balance_calculator
:sometimes|numeric|min:0
Must be a non-negative numeric value. balance_hash
:required|string
Must be a string value.
TransactionController
The TransactionController handles operations related to the Transaction model. This includes creating, updating, and deleting transactions, as well as retrieving transaction histories for specific wallets. The key functions include:
Transaction Validation Rules
createTransactionValidationRules
:
-
wallet_id
:required|uuid|exists:wallets,id
Must be a valid UUID of a wallet that exists in the wallets table. -
user_id
:required|uuid
Must be a valid UUID for the user associated with the transaction. -
amount
:required|numeric|min:0
The transaction amount must be a non-negative numeric value. -
cashflowIn
:required|boolean
Indicates whether the cash flow is incoming (true) or outgoing (false). -
cashType
:required|in:topUp,loyalty,purchase,purchaseReward,refunded
Specifies the type of cash flow, with the allowed values being topUp, loyalty, purchase, purchaseReward, and refunded. -
transaction_type
:required|in:easy_paisa,jazzcash,card
Specifies the type of transaction, with valid options being easy_paisa, jazzcash, and card. -
payment_method
:required|string|max:255
The payment method used for the transaction, must be a string with a maximum length of 255 characters. -
external_transaction_id
:nullable|string|max:255
Optional field for an external transaction ID, if applicable. -
activity
:nullable|uuid
Optional UUID linking to an activity related to the transaction. -
status
:required|boolean
Indicates the transaction status (e.g., completed or pending). notes
:nullable|string
Optional field for any additional notes related to the transaction.
updateTransactionValidationRules
:
-
amount
:sometimes|numeric|min:0
The transaction amount, if provided, must be a non-negative numeric value. -
cashflowIn
:sometimes|boolean
Indicates whether the cash flow is incoming (true) or outgoing (false), if provided. -
cashType
:sometimes
The type of cash flow, if provided. -
transaction_type
:sometimes
The type of transaction, if provided. -
payment_method
:sometimes|string|max:255
The payment method used for the transaction, if provided. -
external_transaction_id
:sometimes|string|max:255
Optional field for an external transaction ID, if provided. -
activity
:sometimes|uuid
Optional UUID linking to an activity related to the transaction, if provided. -
status
:sometimes|boolean
Indicates the transaction status, if provided. notes
:sometimes|string
Optional field for any additional notes related to the transaction, if provided.
Example Usage of TransactionController
PaymentMethodController
This controller manages CRUD operations for different payment methods that are linked to wallets. Payment methods can be created, updated, deleted, and listed. The key functions include:
Payment Method Validation Rules
createPaymentMethodValidationRules
:
-
user_id
:required|integer|exists:users,id
Must be a valid user ID that exists in the users table. -
wallet_id
:required|uuid|exists:wallets,uuid
Ensures the wallet_id exists in the wallets table. -
last_four_digit
:required|string|size:4
Exactly 4 digits for the last four of the card. -
expiry
:required|string|regex:/^(0[1-9]|1[0-2])\/?([0-9]{2})$/
Validates the expiration date in MM/YY format. -
json
:nullable|json
Optional field; must be valid JSON if provided. -
status
:boolean
Indicates the status of the payment method. encrypted_card
:required|string
Encrypted card information is required.
updatePaymentMethodValidationRules
:
-
last_four_digit
:sometimes|string|size:4
Exactly 4 digits for the last four of the card; optional for update. -
expiry
:sometimes|string|regex:/^(0[1-9]|1[0-2])\/?([0-9]{2})$/
Validates the expiration date in MM/YY format; optional for update. -
json
:nullable|json
Optional field; must be valid JSON if provided. -
status
:boolean
Indicates the status of the payment method. encrypted_card
:required|string
Encrypted card information is required.
Example Usage of PaymentMethodController
ActivityController
The ActivityController tracks all significant activities related to wallets. This could include logging transactions, wallet updates, and other key events. The key functions include:
Activity Validation Rules
createActivityValidationRules
:
-
action
:required|string|max:500
The action field is required, must be a string, and can have a maximum length of 500 characters. points
:required|numeric|min:0
The points field is required, must be numeric, and should be a non-negative value (minimum: 0).
updateActivityValidationRules
:
-
action
:sometimes|string|max:500
The action field is optional; if provided, it must be a string and can have a maximum length of 500 characters. -
points
:sometimes|numeric|min:0
The points field is optional; if provided, it must be numeric and should be a non-negative value (minimum: 0).Example Usage of ActivityController
Customization
You can extend or modify the default behavior by extending the base classes provided in the package or by overriding specific methods as per your application's requirements.
Migrations
This package provides its own set of migrations, located in database/migrations, which are automatically loaded when you run php artisan migrate. Ensure that migrations are properly configured to avoid any issues.
Contributing
Feel free to contribute to this package by submitting a pull request or opening an issue on GitHub. Contributions are highly appreciated!
License
This package is open-source and is distributed under the MIT License.