christianbraybrooke / stripe-laravel-payment-intents
0.0.2
2019-08-19 08:30 UTC
Requires
- stripe/stripe-php: ^6.40
Requires (Dev)
- orchestra/testbench: ^3.5
This package is auto-updated.
Last update: 2024-09-19 20:48:27 UTC
README
此软件包仍在开发中,需要更多文档。如有需要,请通过电子邮件 chris@purplemountmedia.com 联系我们。
Composer
首先,在终端中使用以下片段从 packagist.org 获取包。Laravel 5.5 及更高版本将自动加载我们的 Service 提供器。
composer require christianbraybrooke/stripe-laravel-payment-intents
数据库
默认情况下,我们将使用 payment_records 表存储所有交易。如果这不是您想要的,请将以下内容放置在您的 \App\Providers\AppServiceProvider 的 boot 方法中。
use ChrisBraybrooke\LaravelStripePaymentIntent\Facades\StripePaymentIntent; /** * Bootstrap any application services. * * @return void */ public function boot() { StripePaymentIntent::dontSavePaymentRecords(); }
接下来,您需要发布所需的迁移并进行迁移。
php artisan vendor:publish --tag="payment-migrations"
php artisan migrate
Stripe
为了让我们能够与 Stripe 通信,您需要在 .env 文件中添加您的 API 密钥(如果您尚未添加)。您可以在 https://dashboard.stripe.com/apikeys 找到您的密钥。
STRIPE_KEY=### STRIPE_SECRET=###
使用方法
支付表单
开箱即用,我们提供了一个简单的支付表单组件,让您能够快速启动。只需将支付字段和脚本组件添加到目标页面,即可开始使用!
@paymentFields([ // Amount in lowest currency (pence, cents etc.). // Currency in valid currency code. // Success URL is the route we will post to completed form data to. 'amount' => 12500, 'currency' => 'GBP', 'successUrl' => route('payment.submit') ]) @endpaymentFields // Somewhere towards the footer @paymentScripts() @endpaymentScripts
自定义
目前,您可以通过两种方式更改支付表单的外观。这些可以在您的 \App\Providers\AppServiceProvider 的 boot 方法中注册。
use ChrisBraybrooke\LaravelStripePaymentIntent\Facades\StripePaymentIntent; /** * Bootstrap any application services. * * @return void */ public function boot() { // Will give the inputs on the payment form a class of: 'form-control' StripePaymentIntent::setInputClass('form-control'); // Will change the colour of elements like the submit button. StripePaymentIntent::setThemeColor('#efefef'); }