bridge-payment-sylius/sylius-payment-plugin

通过银行电汇实现Bridge的Sylius支付插件

This package is auto-updated.

Last update: 2024-09-23 12:11:48 UTC


README

Bridge - Sylius payment plugin

Bridge - Sylius支付插件

Bridge是一个新的即时转账支付解决方案,允许您通过提供从客户账户即时、安全和无缝的收款来提高您的转化率。
本模块为您做了什么
集成Bridge,一个安全的即插即用支付解决方案,以降低成本提高您的转化率。享受便捷的核对和低欺诈率。

Bridge支付解决方案允许商家

- 提供高支付限额
允许顶级购物车立即支付大额款项,从而提高您的转化率。
- 利用低成本支付解决方案

成本管理和现金流管理都得到了简化。您可以通过只对您网站上进行的交易支付低比例的费用,来利用比使用信用卡更具竞争力的成本。
- 享受即时支付

快速将资金存入您的银行账户
- 受益于支付的不可撤销性

支付不可撤销。换句话说,客户不能取消或修改他们的支付。
- 减少欺诈率并提供安全支付

要创建沙盒应用程序,请参阅以下链接: https://docs.bridgeapi.io/docs/dashboard

安装

使用Composer在Bridge packagist中安装插件

composer require bridge-payment-sylius/sylius-payment-plugin

修改您的config/bundles.php文件,添加插件的行

<?php

return [
    //..
    Bridge\SyliusBridgePlugin\BridgeSyliusPaymentPlugin::class => ['all' => true],

然后在config/packages/bridge_plugin.yaml中创建配置文件

imports:
    - { resource: "@BridgeSyliusPaymentPlugin/Resources/config/services.yaml" }

然后导入config/routes/bridge_plugin.yaml中的路由

bridge_plugin_routing:
    resource: "@BridgeSyliusPaymentPlugin/Resources/config/routes.yaml"

使用以下Linux命令生成密钥(加密密钥)

openssl enc -aes-256-cbc -k secret -P -md sha1

执行此命令时,应显示如下结果

user@linux:~$ openssl enc -aes-256-cbc -k secret -P -md sha1

Using -iter or -pbkdf2 would be better.
salt=A1540F931FD70663
key=92206EDA1EF9E2EF2121396B2FCD2F9EA16193B98B03940C109E9CE422B0CC73
iv =BF9DC31C16714F4CAD663090E1B4076F

您应复制key并将其添加到您的.env中的变量BRIDGE_CYPHER_KEY中

###> Bridge Cypher key
BRIDGE_CYPHER_KEY=
###< Bridge Cypher key

执行以下命令以复制必要的twig文件

cp vendor/bridge-payment-sylius/sylius-payment-plugin/src/Resources/views/PaymentMethod/_form.html.twig templates/bundles/SyliusAdminBundle/PaymentMethod

cp vendor/bridge-payment-sylius/sylius-payment-plugin/src/Resources/views/Checkout/SelectPayment/_payment.html.twig  templates/bundles/SyliusShopBundle/Checkout/SelectPayment 

cp vendor/bridge-payment-sylius/sylius-payment-plugin/src/Resources/views/Order/show.html.twig templates/bundles/SyliusShopBundle/Order 

templates/bundles/SyliusShopBundle/Checkout/SelectPayment/_choice.html.twig中的代码替换为以下内容

{% set isBridgePaymentMethod = method.gatewayConfig.factoryName == 'bridge-payment' %}

<div class="item" {{ sylius_test_html_attribute('payment-item') }}>
    <div class="field">
        <div class="ui radio checkbox" {{ sylius_test_html_attribute('payment-method-checkbox') }}>
            {{ form_widget(form, sylius_test_form_attribute('payment-method-select')| sylius_merge_recursive({'attr': {'data-is-bridge-payment-method': isBridgePaymentMethod ? 1 : 0}})) }}
        </div>
    </div>
    <div class="content">
        <a class="header">
            {{ form_label(form, null, {'label_attr': {'data-test-payment-method-label': ''}}) }}
            {% include '@BridgeSyliusPaymentPlugin/Checkout/SelectPayment/_bridge_logo.html.twig' %}
        </a>

        {% include '@BridgeSyliusPaymentPlugin/Checkout/SelectPayment/_banks.html.twig' %}

        {% if method.description is not null %}
            <div class="description">
                <p>{{ method.description }}</p>
            </div>
        {% endif %}
        {% if method.gatewayConfig.factoryName == 'sylius.pay_pal' %}
            {{ render(controller('Sylius\\PayPalPlugin\\Controller\\PayPalButtonsController:renderPaymentPageButtonsAction', {'orderId': order.id})) }}
        {% endif %}
    </div>
</div>

更新实体src/Entity/Payment/Payment.php

<?php

declare(strict_types=1);

namespace App\Entity\Payment;

use Bridge\SyliusBridgePlugin\Model\Payment\PaymentTrait as BridgePaymentTrait;
use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Core\Model\Payment as BasePayment;

/**
 * @ORM\Entity
 * @ORM\Table(name="sylius_payment")
 */
class Payment extends BasePayment
{
    use BridgePaymentTrait;
}

更新实体src/Entity/Payment/PaymentMethod

<?php

declare(strict_types=1);

namespace App\Entity\Payment;

use Bridge\SyliusBridgePlugin\Model\Payment\PaymentMethodTrait as BridgePaymentMethodTrait;
use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Core\Model\PaymentMethod as BasePaymentMethod;
use Sylius\Component\Payment\Model\PaymentMethodTranslationInterface;

/**
 * @ORM\Entity
 * @ORM\Table(name="sylius_payment_method")
 */
class PaymentMethod extends BasePaymentMethod
{
    use BridgePaymentMethodTrait;

    protected function createTranslation(): PaymentMethodTranslationInterface
    {
        return new PaymentMethodTranslation();
    }
}

对数据库应用迁移

php bin/console doctrine:migrations:migrate

重建缓存以正确显示所有翻译

php bin/console cache:clear
php bin/console cache:warmup

有关银行列表,一个html Mokup模板可供您使用,位置在

plugin/SyliusBridgePlugin/src/Resources/views/Mokup/index.html.twig

执行以下命令后,您可以访问Mockup模板

php bin/console assets:install 

Mockup的路径如下

/admin/bridge/shop/mockup