PHPackages                             wasimrasheed/e-wallet - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. wasimrasheed/e-wallet

ActiveLibrary[Payment Processing](/categories/payments)

wasimrasheed/e-wallet
=====================

v1.1.11(1y ago)033MITPHP

Since Oct 24Pushed 1y ago2 watchersCompare

[ Source](https://github.com/wasimrasheed64/Laravel-E-Wallet)[ Packagist](https://packagist.org/packages/wasimrasheed/e-wallet)[ RSS](/packages/wasimrasheed-e-wallet/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (14)Used By (0)

EWallet Package
===============

[](#ewallet-package)

Overview
--------

[](#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
--------

[](#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
------------

[](#installation)

1. Install the package via composer:

    ```
    composer require wasimrasheed/e-wallet
    ```
2. Register the service provider in config/app.php if not using auto-discovery:

    ```
    'providers' => [
        ...
        Wasimrasheed\Ewallet\EwalletServiceProvider::class,
    ]

     'aliases' => [
          ...
          'EWallet' => Wasimrasheed\Ewallet\Facades\EWallet::class,
     ]
    ```
3. Publish and run the migrations:

    ```
    php artisan migrate
    ```

Usage
-----

[](#usage)

Once the package is installed and configured, you can interact with the package's controllers and models. The key classes included are:

WalletController
----------------

[](#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:

```
createWallet(array $data): mixed:  Creates a new wallet with the provided data.
getWallet(int $id): array:  Retrieves the details of a specific wallet by its ID.
getWallets(): Collection:  Retrieves a collection of all wallets.
updateWallet(int $id, array $data): string:  Updates the wallet details for the specified wallet ID.
deleteWallet(int $id): string:  Deletes a wallet identified by its ID.
getWalletByColumn($item, $column): array:  Retrieves a wallet based on a specific column value.
```

### Wallet Validation Rules

[](#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.

```
$newWallet = EWallet::createWallet([
    'user_id' => $uuid,
    'balance' => 100.00,
]);

// Retrieve wallet details
$walletDetails = EWallet::getWallet($uuid);

// Retrieve all wallets
$allWallets = EWallet::getWallets();

// Update wallet
$updateMessage = EWallet::updateWallet($uuid, ['balance' => 150.00]);

// Delete wallet
$deleteMessage = EWallet::deleteWallet(1);
```

### TransactionController

[](#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:

```
createTransaction(array $data): mixed: Creates a new transaction linked to a wallet.
getTransaction(int $id): array: Retrieves the details of a specific transaction by its ID.
getTransactionsByWallet(int $walletId): Collection: Retrieves the transaction history for a specific wallet.
updateTransaction(int $id, array $data): string: Updates the transaction details for the specified transaction ID.
deleteTransaction(int $id): string: Deletes a transaction identified by its ID.
```

### Transaction Validation Rules

[](#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**

```
use Wasimrasheed\EWallet\Http\Controllers\TransactionController;

// Create a new transaction
$newTransaction = EWallet::createTransaction([
'wallet_id' => 1,
'amount' => 50.00,
'type' => 'credit',
]);

// Retrieve transaction details
$transactionDetails = EWallet::getTransaction(1);

// Retrieve all transactions for a wallet
$walletTransactions = EWallet::getTransactionsByWallet(1);

// Update transaction
$transactionUpdateMessage = EWallet::updateTransaction(1, ['amount' => 75.00]);

// Delete transaction
$transactionDeleteMessage = EWallet::deleteTransaction(1);
```

PaymentMethodController
-----------------------

[](#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:

```
createPaymentMethod(array $data): mixed: Creates a new payment method.
getPaymentMethod(int $id): array: Retrieves the details of a specific payment method by its ID.
getPaymentMethods(): Collection: Retrieves a collection of all payment methods.
updatePaymentMethod(int $id, array $data): string: Updates the payment method details for the specified ID.
deletePaymentMethod(int $id): string: Deletes a payment method identified by its ID.
```

### Payment Method Validation Rules

[](#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**

```
use Wasimrasheed\EWallet\Http\Controllers\PaymentMethodController;

// Create a new payment method
$newPaymentMethod = EWallet::createPaymentMethod([
'name' => 'Credit Card',
'details' => 'Visa ending in 1234',
]);

// Retrieve payment method details
$paymentMethodDetails = EWallet::getPaymentMethod(1);

// Retrieve all payment methods
$allPaymentMethods = EWallet::getPaymentMethods();

// Update payment method
$paymentMethodUpdateMessage = EWallet::updatePaymentMethod(1, ['details' => 'Updated details']);

// Delete payment method
$paymentMethodDeleteMessage = EWallet::deletePaymentMethod(1);
```

ActivityController
------------------

[](#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:

```
createActivity(array $data): mixed: Logs a new activity related to wallets.
getActivity(int $id): array: Retrieves the details of a specific activity by its ID.
getActivities(): Collection: Retrieves a collection of all recorded activities.
updateActivity(int $id, array $data): string: Updates the details of a specific activity.
deleteActivity(int $id): string: Deletes an activity identified by its ID.
```

### Activity Validation Rules

[](#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**

```
use Wasimrasheed\EWallet\Http\Controllers\ActivityController;

// Create a new activity
$activityController = new ActivityController();
$newActivity = EWallet::createActivity([
'wallet_id' => 1,
'description' => 'Deposit of $50',
]);

// Retrieve activity details
$activityDetails = EWallet::etActivity(1);

// Retrieve all activities
$allActivities = EWallet::getActivities();

// Update activity
$activityUpdateMessage = EWallet::updateActivity(1, ['description' => 'Updated description']);

// Delete activity
$activityDeleteMessage = EWallet::deleteActivity(1);
```

Customization
-------------

[](#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
----------

[](#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
------------

[](#contributing)

Feel free to contribute to this package by submitting a pull request or opening an issue on GitHub. Contributions are highly appreciated!

License
-------

[](#license)

This package is open-source and is distributed under the MIT License.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

13

Last Release

565d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b0a2c7ca213d986e2f4d8c7105c075c8fbf8d2b60b775ce7024633f2214271fb?d=identicon)[wasimrasheed64](/maintainers/wasimrasheed64)

### Embed Badge

![Health badge](/badges/wasimrasheed-e-wallet/health.svg)

```
[![Health](https://phpackages.com/badges/wasimrasheed-e-wallet/health.svg)](https://phpackages.com/packages/wasimrasheed-e-wallet)
```

###  Alternatives

[omnipay/paypal

PayPal gateway for Omnipay payment processing library

3156.8M53](/packages/omnipay-paypal)[eduardokum/laravel-boleto

Biblioteca com boletos para o laravel

626351.9k2](/packages/eduardokum-laravel-boleto)[tbbc/money-bundle

This is a Symfony bundle that integrates moneyphp/money library (Fowler pattern): https://github.com/moneyphp/money.

1961.9M](/packages/tbbc-money-bundle)[2checkout/2checkout-php

2Checkout PHP Library

83740.3k2](/packages/2checkout-2checkout-php)[smhg/sepa-qr-data

Generate QR code data for SEPA payments

61717.2k5](/packages/smhg-sepa-qr-data)[omnipay/dummy

Dummy driver for the Omnipay payment processing library

271.2M33](/packages/omnipay-dummy)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
