marqant-lab / marqant-pay-stripe
marqant/marqant-pay 包的 Stripe 支付提供商。
Requires
- spatie/laravel-stripe-webhooks: ^2.3
- stripe/stripe-php: ^7.29
- dev-master
- v0.1.0
- v0.0.23
- v0.0.22
- v0.0.21
- v0.0.20
- v0.0.19
- v0.0.18
- v0.0.17
- v0.0.16
- v0.0.15
- v0.0.14
- v0.0.13
- v0.0.12
- v0.0.11
- v0.0.10
- v0.0.9
- v0.0.8
- v0.0.7
- v0.0.6
- v0.0.5
- v0.0.4
- v0.0.3
- v0.0.2
- v0.0.1
- dev-development
- dev-feature/tjv/chargeable-subscriptions
- dev-feature/dsv/GRETA-851-webhook_payment_failed
- dev-feature/dsv/Github-billable-config
- dev-feature/tjv/manual-subscriptions
- dev-feature/dsv/GRETA-811-webhooks-tests
- dev-bugfix/tjv/fix-hasPaymentMethod-method
- dev-feature/dsv/GRETA-810-webhook-charges-subscriptions
- dev-feature/tjv/setup-pdf-invoices
- dev-feature/tjv/invoice-query
- dev-feature/tjv/3d-secure-and-additional-authentication
- dev-feature/tjv/add-subscriptions-graphql
- dev-feature/tjv/add-plans-and-subscriptions
- dev-feature/tjv/change-composer-vendor-name
This package is auto-updated.
Last update: 2024-09-19 20:38:42 UTC
README
此包使 Stripe 支付提供商对 marqant/marqant-pay 包可用。
安装
您可以通过 composer 需求此包,如下所示。
composer require marqant-lab/marqant-pay-stripe
然后您必须将服务信息添加到 Laravel 的 services.php 配置文件。为此,更新配置文件如下。
return [ // other services // ... 'stripe' => [ 'key' => env('STRIPE_KEY'), 'secret' => env('STRIPE_SECRET'), ], ];
接下来,您需要添加环境变量。转到您的 Stripe 控制面板,获取您的 Stripe 密钥和密钥,然后将其添加到您的 .env 文件中。
STRIPE_KEY=pk_test_iLokikJOvEuI2HlWgH4olf3P STRIPE_SECRET=sk_test_BQokikJOvBiI2HlWgH4olfQ2
现在,在 marqant-pay.php 配置文件中启用支付提供商。
return [ /* |-------------------------------------------------------------------------- | Gateways |-------------------------------------------------------------------------- | | In this section you can define all payment gateways that you need for | your project. | */ 'gateways' => [ 'stripe' => \Marqant\MarqantPayStripe\StripePaymentGateway::class, ], ];
接下来,您需要在 marqant-pay 设置中设置的账单上添加 Stripe 字段。因此,为每个已设置的账单模型(或将要设置的)运行以下操作。
php artisan marqant-pay:migrations:stripe
如果您正在使用 marqant-lab/marqant-pay-subscriptions 包来启用订阅,则需要在所选命令中添加 --subscriptions 标志。
php artisan marqant-pay:migrations:stripe --subscriptions
现在,您可以像往常一样运行迁移。
php artisan migrate
就是这样,现在您应该可以开始了。
### WebHooks
我们使用 spatie/laravel-stripe-webhooks 包来处理 Stripe WebHooks。
##### 配置
将 STRIPE_WEBHOOK_SECRET 添加到 .env
您可以在 Stripe 控制面板 的 WebHook 配置设置中找到使用的密钥。
如果您之前没有做,运行 $ php artisan migrate
转到您的 your_project/app/Http/Middleware/VerifyCsrfToken.php 并添加以下行
/** * The URIs that should be excluded from CSRF verification. * * @var array */ protected $except = [ '/stripe/webhook' ];
最后,处理路由
在 Stripe 控制面板中,您必须配置 Stripe WebHooks 应该击中您的应用程序的哪个 URL。
您应该将其设置为 '/stripe/webhook'。
端点 URL 的示例
http://your.awesome.site/stripe/webhook
可用的 Stripe 事件
- payment_intent.succeeded
- invoice.payment_succeeded
- payment_intent.payment_failed
- charge.failed (未完成)
对于 'payment_intent.payment_failed',您应该在配置文件中设置 'marqant-pay.payment_urls.base_url' 和 'marqant-pay.payment_urls.payment_sub_url',
描述在配置文件中。
您还需要查看 'marqant-pay.support_emails' 配置。
您还可以将以下键添加到项目/resources/lang中进行翻译
- "Here"
- "Payment failed."
- "Requires payment method."
- "You needs to update your payment method in the"
别忘了:它应该是 json 文件。
示例 resources/lang/en.json
{
"Payment failed.": "Payment failed translation."
}
它们用于 'payment_intent.payment_failed' 事件的电子邮件
这就是您所需要的