PHPackages                             coderity/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. coderity/wallet

ActiveLibrary[Payment Processing](/categories/payments)

coderity/wallet
===============

Coderity Wallet extends Laravel Cashier allowing users to have multiple credit cards with multiple subscriptions, along with the ability to charge different cards as needed.

v1.0.0(8y ago)8147MITPHP &gt;=5.5.9

Since Oct 23Compare

[ Source](https://github.com/coderity/wallet)[ Packagist](https://packagist.org/packages/coderity/wallet)[ RSS](/packages/coderity-wallet/feed)WikiDiscussions Synced 2w ago

READMEChangelog (1)Dependencies (8)Versions (2)Used By (0)

Coderity Wallet
===============

[](#coderity-wallet)

Introduction
------------

[](#introduction)

Coderity Wallet extends [Laravel Cashier](http://github.com/laravel/cashier) allowing users to have multiple credit cards with multiple subscriptions, along with the ability to charge different cards as needed.

Coderity Wallet still contains all the features of [Laravel Cashier](http://github.com/laravel/cashier), with extra methods available!

Coderity Wallet currently only works with Stripe.

Installation
------------

[](#installation)

Wallet follows closely with the [Laravel Cashier Installation Guide](https://laravel.com/docs/5.5/billing#introduction) - with some subtle differences.

#### Composer

[](#composer)

First, add the Wallet package for Stripe to your dependencies:

```
composer require "coderity/wallet":"~1.0"

```

#### Service Provider

[](#service-provider)

If your version of Laravel is version 5.5 or greater, you can skip the following step.

Next, register the `Coderity\Wallet\WalletServiceProvider` ervice provider in your `config/app.php` configuration file.

#### Database Migrations

[](#database-migrations)

Before using Wallet, we'll also need to prepare the database. We need to add several columns to your `users` table and create a new `subscriptions` table to hold all of our customer's subscriptions:

```
Schema::table('users', function ($table) {
    $table->string('stripe_id')->nullable();
    $table->string('card_brand')->nullable();
    $table->string('card_last_four')->nullable();
    $table->timestamp('trial_ends_at')->nullable();
});

Schema::create('subscriptions', function ($table) {
    $table->increments('id');
    $table->integer('user_id');
    $table->string('name');
    $table->string('stripe_id');
    $table->string('stripe_plan');
    $table->integer('quantity');
    $table->timestamp('trial_ends_at')->nullable();
    $table->timestamp('ends_at')->nullable();
    $table->timestamps();
});

```

Once the migrations have been created, run the `migrate` Artisan command.

#### Billable Model

[](#billable-model)

Next, add the `Billable` trait to your model definition. This trait provides various methods to allow you to perform common billing tasks, such as creating subscriptions, applying coupons, and updating credit card information:

```
use Coderity\Wallet\Billable;

class User extends Authenticatable
{
    use Billable;
}

```

#### API Keys

[](#api-keys)

Finally, you should configure your Stripe key in your `services.php` configuration file. You can retrieve your Stripe API keys from the Stripe control panel:

```
'stripe' => [
    'model'  => App\User::class,
    'key' => env('STRIPE_KEY'),
    'secret' => env('STRIPE_SECRET'),
],

```

Documentation
-------------

[](#documentation)

You should be familiar with [Laravel Cashier Installation Guide](https://laravel.com/docs/5.5/billing) to see all of the methods and features available.

The following highlights the specific methods of Coderity Wallet.

#### Adding a Credit Card

[](#adding-a-credit-card)

You can add a credit card easily for a user by passing the `addCard()` method:

```
$user = User::find(1);

$user->addCard([
    'cardNumber' => 4242424242424242,
    'expiryMonth' => 12,
    'expiryYear' => 2021,
    'cvc' => 123
]);
```

If you would like to set the new card as the default card, you can pass true as the second parameter:

```
$user->addCard([
    'cardNumber' => 4242424242424242,
    'expiryMonth' => 12,
    'expiryYear' => 2021,
    'cvc' => 123
], true);
```

If you already have a token generated, you can also pass a token as the first parameter:

```
$user->addCard($token);
```

#### Generate a Token

[](#generate-a-token)

If you need to generate a token or even validate a credit card, use the `generateToken()` method:

```
$result = $user->generateToken([
    'cardNumber' => 4242424242424242,
    'expiryMonth' => 12,
    'expiryYear' => 2021,
    'cvc' => 123
]);

$token = $result['token'];
```

#### Get all Cards

[](#get-all-cards)

You can see all the cards for a user by passing the `cards()` method:

```
$user->cards();
```

An array of cards will be returned. Note, the card ID (`$card->id`) will be a prefixed with `card_`, e.g. `card_1BGBDfLBsAc3LtzZbIEQ8xpF`. This is the ID you will need to use the card in other methods.

#### Get a Card

[](#get-a-card)

To get a specific card, you can pass the card ID to the `getCard()` method:

```
$user->getCard($cardID);
```

#### Charging with a Specific Card

[](#charging-with-a-specific-card)

The `charge()` method works the same [Laravel Cashier](https://laravel.com/docs/5.5/billing#single-charges) with the following additional parameter:

```
$this->user->charge(100, [
     'cardId' => $cardId
]);
```

This parameter will charge the specific card with $100 in this case.

#### Charging without a Subscription

[](#charging-without-a-subscription)

Coderity Wallet also makes doing simple charging very easy. By passing two methods, you can easily make a one off charge (without needing the user to have signed up for a subscription):

```
$card = $user->addCard([
    'cardNumber' => 4242424242424242,
    'expiryMonth' => 12,
    'expiryYear' => 2021,
    'cvc' => 123
]);

$this->user->charge(100, [
     'cardId' => $card['cardId']
]);
```

#### Creating a Subscription with a Specific Card

[](#creating-a-subscription-with-a-specific-card)

You can create a subscription with a specific card, by including the `useCard()` method, before calling `create()` when adding a subscription.

```
$this->user->newSubscription('main', 'monthly-10-1')
    ->trialDays(10)
    ->useCard($cardId)
    ->create();
```

Note that the currently functionality will actually set this card as the default card for all the user's subscriptions - this is how Stripe currently handles multiple subscriptions for a customer.

#### Update Default Card

[](#update-default-card)

Of course, you can update the default card at any stage by using the `updateDefaultCard()` method:

```
$user->updateDefaultCard($cardId);
```

#### Get Default Card

[](#get-default-card)

If you want to get the users default card, simple use the `getDefaultCard()` method:

```
$card = $user->getDefaultCard();
```

#### Delete a Specific Card

[](#delete-a-specific-card)

You can delete a specific card by passing the card ID to the `deleteCard()` method:

```
$user->deleteCard($cardId);
```

For more use cases, please refer to the [Unit Tests](https://github.com/coderity/wallet/blob/master/tests/WalletTest.php).

Running Wallet's Tests Locally
------------------------------

[](#running-wallets-tests-locally)

You will need to set the following details locally and on your Stripe account in order to run the Wallet unit tests:

### Environment

[](#environment)

#### .env

[](#env)

```
STRIPE_KEY=
STRIPE_SECRET=
STRIPE_MODEL=User

```

### Stripe

[](#stripe)

#### Plans

[](#plans)

```
* monthly-10-1 ($10)

```

Contributing
------------

[](#contributing)

Please read the [Contributing Guide](https://github.com/coderity/wallet/blob/master/contributing.md) if you would like to make any suggestions for improvements to Coderity Wallet.

License
-------

[](#license)

Coderity Wallet is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

28

—

LowBetter than 51% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

3218d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9151420?v=4)[Coderity](/maintainers/coderity)[@coderity](https://github.com/coderity)

---

Tags

laravelstripebillingwalletcashier

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[lanos/laravel-cashier-stripe-connect

Adds Stripe Connect functionality to Laravel's main billing package, Cashier.

84173.2k](/packages/lanos-laravel-cashier-stripe-connect)[expdev07/laravel-cashier-stripe-connect

Adds Stripe Connect functionality to Laravel's main billing package, Cashier.

63143.7k](/packages/expdev07-laravel-cashier-stripe-connect)[mmanos/laravel-billing

A billing package for Laravel 4.

461.3k](/packages/mmanos-laravel-billing)[certly/spark

Laravel Spark provides a starter scaffolding for Laravel SaaS applications.

451.6k](/packages/certly-spark)[helori/laravel-saas

Software as a Service scaffholding for Laravel based on Vue 3, Tailwindcss and Stripe. Inspired by Laravel Jetstream and Spark.

121.4k](/packages/helori-laravel-saas)

PHPackages © 2026

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