سوسچه / walletstripe
php 组件,用于将应用程序与 Stripe 连接
dev-master
2018-10-10 13:41 UTC
Requires
- php: ^7.1.3
- cartalyst/stripe-laravel: 8.0.*
Requires (Dev)
- phpunit/phpunit: ^7
This package is auto-updated.
Last update: 2024-09-11 03:32:37 UTC
README
描述
php 组件,用于将应用程序与 Stripe 连接
安装/使用
1. 使用 Composer
$ composer require suseche/walletstripe
2. 运行迁移命令
$ php artisan migrate
3. 在 Stripe 中创建账户
在仪表板选项中,转到
- 开发者
- API 密钥
复制 Stripe 提供的密钥,并在 laravel 环境文件中添加以下内容
-STRIPE_KEY (Secret key from stripe)
-APP_ENV
-APP_NAME
要求
- PHP 7.1.3
- Laravel 5.6
使用方法
namespace App\Http\Controllers; use suseche\walletstripe\WalletStripe; class UserController extends Controller { public function createCustomer(Request $request) { $wallet = new WalletStripe; $customer = $wallet->createConstumer($user->id); } }
方法
- createConstumer
$wallet = new WalletStripe; $customer = $wallet->createConstumer($user->id);
-
参数
account_id:您想将客户 Stripe 链接到账户的本地标识符。
-
返回
存储在 Stripe 中的所有客户数据
- getCostumerId
$wallet = new WalletStripe; $customer = $wallet->getCostumerId($user->id);
-
参数
- account_id:账户的本地标识符。
-
返回
- Stripe 中的客户标识符
- getDataCustomer
$wallet = new WalletStripe; $customer = $wallet->getDataCustomer($user->id);
-
参数
- account_id:账户的本地标识符。
-
返回
- 存储在 stripe 中的所有客户数据
- createCreditCard
$wallet = new WalletStripe; $customer = $wallet->createCreditCard($user->id,$token_card);
-
参数
- account_id:账户的本地标识符。
- $token:使用公钥由 Stripe 前端生成的令牌。
-
返回
- 存储在 stripe 中的所有信用卡数据
- getCreditCards
$wallet = new WalletStripe; $customer = $wallet->getCreditCards($user->id,$card_id);
-
参数
- account_id:账户的本地标识符。
- $card_id:可选的 stripe 中的信用卡标识符,如果不发送值,函数将返回信用卡列表
-
返回
- 存储在 stripe 中的所有信用卡数据/信用卡列表
- deleteCreditCard
$wallet = new WalletStripe; $customer = $wallet->deleteCreditCard($user->id,$card_id);
-
参数
- account_id:账户的本地标识符。
- $card_id:stripe 中的信用卡标识符
-
返回
- 操作布尔响应
- updateCreditCard
$wallet = new WalletStripe; $customer = $wallet->updateCreditCard($user->id,$card_id,[ 'name' => 'John Doe', 'address_line1' => 'Example Street 1', ]);
-
参数
- 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', ]
-
返回
- 存储在 stripe 中的所有信用卡数据
- generateTokenCreditCard
注意:此方法仅应用于测试目的,因为其在生产环境中的使用可能导致敏感数据的误用,这些数据容易受到诈骗或欺诈的影响
$wallet = new WalletStripe; $customer = $wallet->generateTokenCreditCard($user->id,[ 'number' => '4242424242424242', 'exp_month' => 10, 'cvc' => 314, 'exp_year' => 2020, ]);
-
参数
- account_id:账户的本地标识符。
- $data:包含信用卡数据的数组
注意:如果未在函数中发送数组,则创建具有测试数据的测试令牌
$data =[ 'number' => '4242424242424242', 'exp_month' => 10, 'cvc' => 314, 'exp_year' => 2020, ]
-
返回
- 信用卡令牌
- loadCharge
$wallet = new WalletStripe; $customer = $wallet->loadCharge($account_id,$amount,$description,$metadata,$currency)
-
参数
- account_id:账户的本地标识符。
- $amount:收费金额
- $description:收费描述
- $metadata:包含附加收费数据的数组
- $currency:表示 ISO 格式的货币的字符串(如果没有发送,默认值为 USD)
-
返回
- 存储在 stripe 中的所有收费数据