udaykumar77/stripe 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2016-09-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固