datalive / stripe
用于将应用程序与 stripe 连接的 PHP 组件
dev-master
2018-10-03 15:56 UTC
Requires
- php: ^7.1.3
- cartalyst/stripe-laravel: 8.0.*
- datalive/serviceinfrastructure: *
Requires (Dev)
- phpunit/phpunit: ^7
This package is auto-updated.
Last update: 2024-09-05 04:45:32 UTC
README
描述
用于将应用程序与 stripe 连接的 PHP 组件
安装/使用
通过 Composer
$ composer require datalive/stripe
通过 composer 安装后,运行迁移命令
$ php artisan migrate
在 Stripe 中创建账户
在仪表板选项中
-开发者 -API 密钥
复制密钥
在 laravel 环境文件中应包含以下数据 -STRIPE_KEY (Stripe 的密钥) -APP_ENV -APP_NAME
要求
- PHP 7.1.3
- Laravel 5.6 或更高版本
使用
namespace App\Http\Controllers; use datalive\stripe\Stripe; class UserController extends Controller { public function createCustomer(Request $request) { $wallet = new Stripe; $customer = $wallet->createConstumer($user->id); } }
方法
##createConstumer
-code
$wallet = new Stripe; $customer = $wallet->createConstumer($user->id);
-
params
- account_id: 要将 Stripe 客户端链接到的账户的本地标识符
-
return
- 存储在 Stripe 中的所有客户数据
##getCostumerId
-code
$wallet = new Stripe; $customer = $wallet->getCostumerId($user->id);
-
params
- account_id: 账户的本地标识符。
-
return
- Stripe 中的客户标识符
##getDataCustomer -code
$wallet = new Stripe; $customer = $wallet->getDataCustomer($user->id);
-
params
- account_id: 账户的本地标识符。
-
return
- 存储在 Stripe 中的所有客户数据
##createCreditCard -code
$wallet = new Stripe; $customer = $wallet->createCreditCard($user->id,$token_card);
-
params
- account_id: 账户的本地标识符。
- $token: 由 Stripe 前端使用公钥生成的令牌。
-
return
- 存储在 Stripe 中的所有信用卡数据
##getCreditCards
-code
$wallet = new Stripe; $customer = $wallet->getCreditCards($user->id,$card_id);
-
params
- account_id: 账户的本地标识符。
- $card_id: (可选) Stripe 中信用卡的标识符,如果未发送值,则函数返回信用卡列表
-
return
- 存储在 Stripe 中的所有信用卡数据/信用卡列表
##deleteCreditCard -code
$wallet = new Stripe; $customer = $wallet->deleteCreditCard($user->id,$card_id);
-
params
- account_id: 账户的本地标识符。
- $card_id: Stripe 中信用卡的标识符
-
return
- 操作布尔响应
##updateCreditCard
-code
$wallet = new Stripe; $customer = $wallet->updateCreditCard($user->id,$card_id,[ 'name' => 'John Doe', 'address_line1' => 'Example Street 1', ]);
-
params
- account_id: 账户的本地标识符。
- $card_id: Stripe 中信用卡的标识符
- $data: 包含单个可修改的信用卡数据的数组
$data = [ 'name' => 'John Doe', 'address_line1' => 'Example Street 1', 'address_line2' => 'Example Street 2', 'address_state' => 'Texas', 'address_zip' => '55555', 'exp_month' => '03', 'exp_year' => '2025', ]
-
return
- 存储在 Stripe 中的所有信用卡数据
##generateTokenCreditCard
注意:此方法仅应用于测试目的,因为在生产环境中使用可能导致敏感数据被滥用,容易遭受欺诈或欺诈
-code
$wallet = new Stripe; $customer = $wallet->generateTokenCreditCard($user->id,[ 'number' => '4242424242424242', 'exp_month' => 10, 'cvc' => 314, 'exp_year' => 2020, ]);
-
params
- account_id: 账户的本地标识符。
- $data: 包含信用卡数据的数组
注意:如果函数中未发送修复,则创建带有测试数据的测试令牌
$data =[ 'number' => '4242424242424242', 'exp_month' => 10, 'cvc' => 314, 'exp_year' => 2020, ]
-
return
- 信用卡令牌
##loadCharge
-code
$wallet = new Stripe; $customer = $wallet->loadCharge($account_id,$amount,$description,$metadata,$currency)
-
params
- account_id: 账户的本地标识符。
- $amount: 充值金额
- $description: 充值描述
- $metadata: 包含附加充值数据的数组
- $currency: (如果没有发送默认值为 USD)
-
return
- 存储在 Stripe 中的所有充值数据