udaykumar77/stripe
Composer 安装命令:
composer require udaykumar77/stripe
包简介
stripe easy integration with laravel
README 文档
README
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.
Installation (Laravel Cashier)
Composer
First, add the Cashier package for Stripe to your composer.json file and run the composer update command:
"laravel/cashier": "~6.0"
Service Provider
Next, register the Laravel\Cashier\CashierServiceProvider service provider in your app configuration file.
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:
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.
Model Setup
Next, add the Billable trait to your model definition:
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:
'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:
"udaykumar77/stripe": "v1.0"
Service Provider
Next, register the UdayKumar77\Stripe\StripeServiceProvider service provider in your app configuration file.
UdayKumar77\Stripe\StripeServiceProvider::class,
Facade
Next, register the UdayKumar77\Stripe\Facade\StripeController facade in your app configuration file aliases.
'Stripe' => UdayKumar77\Stripe\Facade\StripeController::class,
Command
Run the following command from your terminal.
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
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
<?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
udaykumar77/stripe 适用场景与选型建议
udaykumar77/stripe 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15 次下载、GitHub Stars 达 1, 最近一次更新时间为 2016 年 09 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 udaykumar77/stripe 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 udaykumar77/stripe 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 15
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2016-09-02