Package Data | |
---|---|
Maintainer Username: | udaykumar77 |
Maintainer Contact: | gudivadaudaykumar@gmail.com (Uday Gudivada) |
Package Create Date: | 2016-09-02 |
Package Last Update: | 2016-09-03 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-02-09 15:15:19 |
Package Statistics | |
---|---|
Total Downloads: | 14 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
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.
First, add the Cashier package for Stripe to your composer.json file and run the composer update command:
"laravel/cashier": "~6.0"
Next, register the Laravel\Cashier\CashierServiceProvider service provider in your app configuration file.
Laravel\Cashier\CashierServiceProvider::class,
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:
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.
Next, add the Billable trait to your model definition:
use Laravel\Cashier\Billable;
class User extends Authenticatable
{
use Billable;
}
Next, you should configure your Stripe key in your services.php configuration file:
'stripe' => [
'model' => App\User::class,
'secret' => env('STRIPE_SECRET'),
],
First, add the udaykumar77/stripe package to your composer.json file and run the composer update command:
"udaykumar77/stripe": "v1.0"
Next, register the UdayKumar77\Stripe\StripeServiceProvider service provider in your app configuration file.
UdayKumar77\Stripe\StripeServiceProvider::class,
Next, register the UdayKumar77\Stripe\Facade\StripeController facade in your app configuration file aliases.
'Stripe' => UdayKumar77\Stripe\Facade\StripeController::class,
Run the following command from your terminal.
composer dump-autoload
Add the following in your .env file
STRIPE_SECRET=**************************
STRIPE_PUBLISHABLE_SECRET=*********************
Stripe::generateCardToken(array $params)
$params = ["number" => "4242424242424242",
"exp_month" => "9",
"exp_year" => "2017",
"cvc" => "456"]
use the name space in your controller like this
<?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);
}
MIT License (MIT) @ Uday Kumar Gudivada