innoweb / silverstripe-silvershop-stripe
为 silvershop 添加 stripe 客户和信用卡保存功能
2.0.0-beta1
2024-07-24 00:47 UTC
Requires
- omnipay/stripe: ^3.0
- silvershop/core: ^3.1
- silverstripe/cms: ^5
- silverstripe/vendor-plugin: ^2
This package is auto-updated.
Last update: 2024-09-24 01:09:09 UTC
README
Stripe 使用与其他处理器略有不同的支付流程,您需要进行一些客户端 JavaScript 操作来设置它,并获取令牌而不是信用卡处理字段。
此模块使用 Omnipay 的 Stripe 适配器,但覆盖了 SilverShop 的默认结账组件,以注入正确的 JavaScript。
基于 Mark Guinn 的 SS3 版本,扩展了将令牌保存到 Member 对象以供以后使用的功能。
要求
- SilverStripe CMS 4.*
- SilverShop 核心 3.*
- Omnipay Stripe 3.*
使用 Stripe.js v3
安装
composer require innoweb/silverstripe-silvershop-stripe
配置
支付意向
在 app/_config/payment.yml
文件中创建一个类似以下内容的文件
---
Name: payment
---
SilverStripe\Omnipay\Model\Payment:
allowed_gateways:
- 'Stripe_PaymentIntents'
SilverStripe\Omnipay\GatewayInfo:
Stripe_PaymentIntents:
failureUrl: '/checkout/summary'
parameters:
apiKey: sk_test_SECRET-KEY-FOR-YOUR-TEST-ACCOUNT
publishableKey: pk_test_PUBLISHABLE-KEY-FOR-TEST-ACCOUNT
---
Only:
environment: 'live'
---
SilverStripe\Omnipay\GatewayInfo:
Stripe_PaymentIntents:
failureUrl: '/checkout/summary'
parameters:
apiKey: sk_live_SECRET-KEY-FOR-YOUR-LIVE-ACCOUNT
publishableKey: pk_live_PUBLISHABLE-KEY-FOR-LIVE-ACCOUNT
如果需要,客户将被重定向到 Stripe 或其银行,通过 SCA 或 3D-Secure 验证交易。
可以在此处指定自定义的失败 URL,以便在付款失败时使用(例如,卡片被拒绝)。
Stripe 充值(已弃用)
在 app/_config/payment.yml
文件中创建一个类似以下内容的文件
---
Name: payment
---
SilverStripe\Omnipay\Model\Payment:
allowed_gateways:
- 'Stripe'
SilverStripe\Omnipay\GatewayInfo:
Stripe:
parameters:
apiKey: sk_test_SECRET-KEY-FOR-YOUR-TEST-ACCOUNT
publishableKey: pk_test_PUBLISHABLE-KEY-FOR-TEST-ACCOUNT
---
Only:
environment: 'live'
---
SilverStripe\Omnipay\GatewayInfo:
Stripe:
parameters:
apiKey: sk_live_SECRET-KEY-FOR-YOUR-LIVE-ACCOUNT
publishableKey: pk_live_PUBLISHABLE-KEY-FOR-LIVE-ACCOUNT
保存卡片
在处理付款时,模块会创建 Stripe 客户和卡片。要禁用在结账过程中使用之前存储的卡片,请将以下内容添加到您的配置中
---
Name: app-stripe-config
After: silvershop-stripe-config
---
Innoweb\SilvershopStripe\Checkout\Components\StripeOnsitePayment:
enable_saved_cards: false
这将隐藏支付表单中用于选择之前存储的卡片的字段。卡片令牌仍将存储在后台,以便能够处理退款和未来的手动付款。
许可
BSD 3-Clause 许可证,请参阅 许可