ImadJomaa / Banker by ImadJomaa

A Laravel interface to Stripe charges
Package Data
Maintainer Username: ImadJomaa
Maintainer Contact: (Imad Jomaa)
Package Create Date: 2016-08-30
Package Last Update: 2016-08-30
Language: PHP
License: MIT
Last Refreshed: 2020-02-22 03:07:57
Package Statistics
Total Downloads: 4
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 1
Total Watchers: 0
Total Forks: 0
Total Open Issues: 0


A Laravel interface to Stripe charges.

Build Status Latest Stable Version Latest Unstable Version License

$user = User::find($id);


// ...

$user->charge(100, $cardToken, $bRememberCard);

// ...

$user->charge()->create(100, [
    'capture' => false,

// ...


// ...

$user->charge()->create(100, [
    'description'   => 'Laravel Lanyard',
    'receipt_email' => $user->email,


With Composer

You can install Banker with the Composer require command.

$ composer require banker/banker

Or by adding "banker/banker": "~1.0" to the composer.jsonfile and running composer update.

Service Provider

Register the Banker\BankerServiceProvider in your config/app.php file.

// ...
// ...

Database migration

After installing the package with composer and registering the service provider, you will need to create the migration that adds the appropriate columns to your preferred model - usually your users table. You can do this by running the banker:table command in the Artisan console. Banker requires these columns to store relevant information about your users' Stripe customer details.

$ php artisan banker:table users

Once the migration has been created, run the migrate command.

$ php artisan migrate


You will need to configure your Stripe secret key in your config/services.php file. The Stripe secret key can be found in your Stripe account settings.

'banker' => [
    'secret' => env('BANKER_SECRET'),  

Adding the Banker trait

Lastly, you will need to add the Banker trait to your model.

use Banker\Banker;
use Banker\Contracts\Banker as BankerContract;

class User extends Model implements BankerContract {
    use Banker;

Getting Started

Banker is purposefully designed to be a familiar transition from Laravel Cashier - having a familiar interface between subscriptions and charges in Laravel with Stripe.

Making a charge

You can make a charge on a user by passing the amount (in cents) and a valid card token to the charge method on the model.

$user = User::find($id);

$user->charge(100, $cardToken);

Remebering a user's credit card details

Banker utilizes Stripe's Customer object to remember a user's payment details for future charges. If you would like Stripe to remember your users' preferred payment details, set remember to true when making a charge for a user.

$user->charge(100, $cardToken, $bRememberCard);

Any subsequent charges on the user can be performed without a credit card token.


Passing Stripe options

If you would like to pass additional options with the charge, for example, a description or an email address to send a receipt to, you can use the create method.

$user->charge()->create(100, [
    'description'   => 'Laravel Lanyard',
    'receipt_email' => $user->email,

If the user does not have any default payment details on file, you will be required to pass the credit card token as an option denoted as source.

Updating a user's credit card details

Updating the credit card details of a user can be done in one of two ways: during a charge, or as a standalone update.

To update a user's credit card details without performing any charges, pass the new credit card token to the updateCard method on the model.


Updating a credit card during a charge

To update a user's credit card details during a charge, pass the new credit card token and set it to remember the details. If the user has an existing card on file, the existing card details will be replaced with the new card details provided.

$user->charge(100, $newCardToken, $bRememberCard);

Deleting a user's credit card details

You can remove a credit card that is on file for a particular user by using the deleteCard method on the model.


Two-step payment flows (auth and capture)

Pre-authorizing a charge allows you to authorize a charge on a card to later capture the funds. This is useful for example, if you need to authorize a charge when a user places an order, and accept payment after preparing a user's shipment. You can learn more about it in the Stripe Documentation.

Authorizing a charge

To authorize a charge with Banker, you pass a capture option when making a charge request.

$charge = $user->charge()->create(100, [
    'capture' => false,
$charge = $user->charge()->create(100, [
    'capture' => false,
    'source'  => $cardToken,

Capturing a charge

You can capture a pre-authorized charge by using the capture method on the charge.


Retreiving a charge

You can retreive a charge by id using the whereId method.


Retreiving a list of a user's charges

You can retreive a list of all of a given user's charges by using the charge method on the model.


You can limit the number of charges to retreive by using the limit method, and offset by using the before and after methods.