remp / crm-stripe-module
CRM Stripe 模块
Requires
- php: ^8.1
- stripe/stripe-php: v7.105.0
- dev-master
- 3.4.0
- 3.3.0
- 3.2.0
- 3.1.0
- 3.0.0
- 2.11.0
- 2.10.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.0
- 2.4.0
- 2.3.0
- 2.2.0
- 2.1.0
- 2.0.0
- 1.2.0
- 1.1.0
- 1.0.0
- 1.0.0-beta2
- 1.0.0-beta1
- 0.39.0
- 0.38.0
- 0.37.0
- 0.36.0
- 0.35.0
- 0.34.0
- 0.33.0
- 0.32.0
- 0.31.0
- 0.30.0
- 0.29.0
- 0.28.0
- 0.27.0
- 0.26.0
- 0.25.0
- 0.24.0
- 0.23.0
- 0.22.0
- 0.21.0
- 0.20.0
- 0.18.0
- 0.17.0
- 0.16.0
- 0.15.0
- 0.14.0
- 0.13.0
- 0.12.0
- 0.11.0
- 0.10.0
- 0.9.0
This package is auto-updated.
Last update: 2024-09-20 12:57:40 UTC
README
安装
我们建议使用 Composer 进行安装和更新管理。要将 CRM Stripe 扩展添加到您的 REMP CRM 应用程序,请使用以下命令
composer require remp/crm-stripe-module
在您的 app/config/config.neon
文件中启用已安装的扩展
extensions: # ... - Crm\StripeModule\DI\StripeModuleExtension
初始化 Stripe 支付网关及其配置
php bin/command.php application:seed
配置 & API 密钥
将 Stripe API 密钥输入到 CRM 中
- 访问 CRM 管理员设置(齿轮图标)- 支付
- 输入 Stripe 发布 密钥
- 输入 Stripe 秘密 密钥
密钥可以在 Stripe 控制台 中找到。如果您还没有账户,您需要创建一个。
使用模块
Stripe Checkout
Stripe Checkout 是使用 Stripe 处理支付最安全和最健壮的场景。用户将被重定向到 Stripe 的结账页面,在那里他们输入卡信息并提交支付。
我们建议使用此场景,因为 Stripe 已针对各种设备优化了页面。当此模块启用时,Stripe Checkout 是默认流程。
如果您使用 remp2020/crm-salesfunnel-module,您需要做的所有事情是,在您的销售漏斗中(CRM 管理员 - 销售漏斗 - 详细信息 - 支付网关)启用 Stripe 和 Stripe Recurrent 网关。您可以使用我们的 示例漏斗 进行集成测试,它将在您启用后立即显示新网关。
Stripe Elements
Stripe Elements 提供了一种在销售漏斗中直接收集卡数据的安全方式。要使用 Stripe Elements,将以下代码片段添加到您的销售漏斗中。
包含 Stripe JS 库。
<script src="https://js.stripe.com/v3/"></script>
添加将初始化以收集数据的元素。
<div> <label>Card holder</label> <input id="cardholder-name" class="form-control mb-4" type="text"> <!-- placeholder for Elements --> <div id="card-element" class="form-control"></div> <!-- Used to display form errors --> <div id="card-errors" role="alert"></div> <!-- Used to store generated payment method ID as payment metadata --> <input type="hidden" name="payment_metadata[payment_method_id]" id="stripePaymentMethodId"> </div>
初始化 Stripe Elements 并使用您的 Stripe 发布 密钥,而不是我们准备的占位符。
<script type="text/javascript"> var stripe = Stripe('-- INCLUDE YOUR PUBLISHABLE KEY HERE --'); var elements = stripe.elements(); var cardElement = elements.create("card"); cardElement.mount("#card-element"); cardElement.addEventListener('change', function(event) { var displayError = document.getElementById('card-errors'); if (event.error) { displayError.textContent = event.error.message; } else { displayError.textContent = ''; } }); </script>
将 Stripe 处理程序附加到表单提交过程。
function processStripe(form) { var paymentMethodIdField = $('#stripePaymentMethodId'); var cardholderName = $('#cardholder-name'); var selectedGateway = $('input[name=payment_gateway]').val(); if (selectedGateway === 'stripe') { stripe.createPaymentMethod('card', cardElement, { billing_details: {name: cardholderName.value } }).then(function(result) { if (result.error) { alert(result.error.message); } else { paymentMethodIdField.val(result.paymentMethod.id); debugger; form.submit(); } }); return false; } if (selectedGateway === 'stripe_recurrent') { $.post('/api/v1/stripe/setup-intent', function($data) { stripe.confirmCardSetup( $data['client_secret'], { payment_method: { card: cardElement, billing_details: { name: cardholderName.value, }, } }, ).then(function(result) { if (result.error) { alert(result.error.message); } else { paymentMethodIdField.val(result.setupIntent.payment_method); form.submit(); } }); }, 'json'); return false; } } $(form).submit(function() { processStripe(); });
Stripe 模块还包含了 使用 Stripe Elements 的漏斗示例。您可以在 CRM 管理员 - 销售漏斗 - stripe-elements-sample 中找到它。要使其工作,搜索 -- INCLUDE YOUR PUBLISHABLE KEY HERE --
并将其替换为您的 Stripe 控制台中可用的 Stripe 发布 密钥。
钱包支付(ApplePay/GooglePay)- Stripe 支付请求按钮
要使用 ApplePay 或 GooglePay,您必须使用 StripeWallet 支付网关。CRM 中的配置与 Stripe Elements 相同,但您可以设置一个额外的配置 - Stripe 显示名称。此文本用作商家名称,用作支付窗口中总金额的标签。
此支付网关通过 Stripe 显示正确支付按钮的精确实现处理 ApplePay 和 GooglePay。
建议:在销售漏斗中,请使用文档中的javascript代码,并根据客户端浏览器支持情况启用/禁用此支付方式。如果不可用,显示ApplePay/GooglePay作为有效支付选项是没有意义的。您可以使用官方文档中的javascript代码 -
它看起来是这样的
var stripe = Stripe("you-public-key", { apiVersion: "2020-08-27", }); var paymentRequest = stripe.paymentRequest({ country: "SK", currency: "eur", total: { label: "something", amount: 100, // 1 eur is OK right now }, }); const elements = stripe.elements(); const prButton = elements.create('paymentRequestButton', { paymentRequest: paymentRequest, }); // Check the availability of the Payment Request API first. paymentRequest.canMakePayment().then(function(result) { if (result) { if (result.applePay == true) { // applePay is available // you can unhide payment method } else if (result.googlePay == true) { // googlePay is available // you can unhide payment method } } else { // no wallet payment method is available // you shoud hide payment methods here, but i recommend to keep it hidden by default } });
已知限制
- 您必须将您的Stripe公钥复制到每个希望检查钱包支付选项支持的销售漏斗中。
- 我们不支持
- 从钱包导入收货地址(但可能实现)。
- 从钱包导入客户的电子邮件(但可能实现)。
- 周期性付款(但看起来可能实现)。
- 在我们的CRM产品模块(电商)中使用StripeWallet。