2017 © Pedro Peláez
 

library stripe

stripe easy integration with laravel

image

udaykumar77/stripe

stripe easy integration with laravel

  • Saturday, September 3, 2016
  • by udaykumar77
  • Repository
  • 1 Watchers
  • 1 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Stripe + Laravle Cashier (L 5.2)

Stripe is the best way to accept payments online and in mobile apps. We handle billions of dollars every year for forward-thinking businesses around the world., (*1)

Installation (Laravel Cashier)

Composer

First, add the Cashier package for Stripe to your composer.json file and run the composer update command:, (*2)

"laravel/cashier": "~6.0"

Service Provider

Next, register the Laravel\Cashier\CashierServiceProvider service provider in your app configuration file., (*3)

Laravel\Cashier\CashierServiceProvider::class,

Database Migrations

Before using Cashier, 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:, (*4)

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, simply run the migrate Artisan command., (*5)

Model Setup

Next, add the Billable trait to your model definition:, (*6)

use Laravel\Cashier\Billable;

class User extends Authenticatable
{
    use Billable;
}

Provider Keys

Next, you should configure your Stripe key in your services.php configuration file:, (*7)

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

Installation Stripe

composer

First, add the udaykumar77/stripe package to your composer.json file and run the composer update command:, (*8)

"udaykumar77/stripe": "v1.0"

Service Provider

Next, register the UdayKumar77\Stripe\StripeServiceProvider service provider in your app configuration file., (*9)

UdayKumar77\Stripe\StripeServiceProvider::class,

Facade

Next, register the UdayKumar77\Stripe\Facade\StripeController facade in your app configuration file aliases., (*10)

'Stripe' => UdayKumar77\Stripe\Facade\StripeController::class,

Command

Run the following command from your terminal., (*11)

composer dump-autoload

Register your stripe account

  • Go to Account Settings -> API Keys
  • Add the Secret & Publishable keys in your .env file

.env

Add the following in your .env file, (*12)

STRIPE_SECRET=**************************
STRIPE_PUBLISHABLE_SECRET=*********************

Methods

  • To generate Stripe Token
Stripe::generateCardToken(array $params)

$params = ["number"     => "4242424242424242",
            "exp_month" => "9",
            "exp_year"  => "2017",
            "cvc"       => "456"]

Usage

use the name space in your controller like this, (*13)

<?php
namespace App\Http\Controllers\Stripe;
use Stripe;

public function generateToken() {
        $stripeToken = Stripe::generateCardToken(
                               ["number"    => "4242424242424242",
                                "exp_month" => "9",
                                "exp_year"  => "2017",
                                "cvc"       => "456"]);
        return response()->json($stripeToken);
    }

License

MIT License (MIT) @ Uday Kumar Gudivada, (*14)

The Versions

03/09 2016

dev-master

9999999-dev

stripe easy integration with laravel

  Sources   Download

MIT

by Uday Gudivada

02/09 2016

v1.0

1.0.0.0

stripe easy integration with laravel

  Sources   Download

by Uday Gudivada