bcismariu/laravel-payments

An alternative to Cashier

Downloads

67

Stars

2

Version

v0.1.12

Laravel Payments

Build Status Latest Stable Version License Total Downloads

A very basic alternative to Laravel Cashier built to allow lighter implementations.

Installation

Use composer to install the package.

composer require bcismariu/laravel-payments

Edit config/app.php and add the following line to your providers list:

Bcismariu\Laravel\Payments\PaymentsServiceProvider::class

Publish the package configuration files.

php artisan vendor:publish --provider="Bcismariu\\Laravel\\Payments\\PaymentsServiceProvider" --tag="config" --force

Migrate the database

php artisan migrate

Attention!

If you plan using the konnektive driver, you should also require its dependencies.

composer require hassletauf/konnektive-crm

Add the following lines to your .env file:

KONNEKTIVE_LOGIN=your-konnektive-loginId
KONNEKTIVE_PASSWORD=your-konnektive-password

Usage

Add the Billable trait on your User model:

use Bcismariu\Laravel\Payments\Billable;

class User
{
    use Billable;

Import the Credit Card info into your User object and charge it:

$user->setCreditCard(new Card([
    'brand'     => 'visa',
    'number'    => '0000000000000000',
    'exp_month' => '02',
    'exp_year'  => '2017',
    'cvc_check' => '123', 
]));

$response = $user->charge(5, [
        'product_id'    => 1234
    ]);

Handling subscriptions


// Import the Credit Card info into your User object:

$user->setCreditCard(new Card([
    'brand'     => 'visa',
    'number'    => '0000000000000000',
    'exp_month' => '02',
    'exp_year'  => '2017',
    'cvc_check' => '123', 
]));

// Register the subscription and charge a certain amount:

$subscription = $user->subscribe('plan-name', 5);

// Check if the user has subscribed to a given plan

$user->subscribed('plan-name');
bcismariu

Author

bcismariu