smile/hipay-sylius-plugin

此包已被废弃且不再维护。未建议替代包。

Sylius 的一个插件,用于添加支付方式 Hipay。

安装: 118

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 12

分支: 3

开放问题: 1

类型:symfony-bundle

1.0.0-beta5 2022-02-22 16:09 UTC

This package is auto-updated.

Last update: 2022-02-25 10:16:09 UTC


README

➡️ 由于无法投入更多时间,该项目现在已被废弃,但“beta”代码将保持在线,以帮助您将 Hipay 支付方式集成到您的项目中。请注意,项目仍不稳定,可能存在未发现的漏洞。




Total Downloads Latest Stable Version License Extended Coding Style Symfony Coding Standards Semver compliant

此插件旨在通过 Payum 在 Sylius 中添加新的网关以支持 Hipay 支付。

安装

$ composer require smile/hipay-sylius-plugin

在您的应用程序 Kernel 中启用它。

<?php
// config/bundles.php
return [
    //...
   Smile\HipaySyliusPlugin\SmileHipaySyliusPlugin::class => ['dev' => true, 'test' => true],
];

导入路由

# config/routes.yaml

sylius_hipay_routing:
    resource: "@SmileHipaySyliusPlugin/config/routing.yaml"

配置您的凭证。在第一个名为 api 的节点中,您必须填写主要账户凭证。在第二个名为 api_moto 的节点中,您必须填写 Mo/To 账户凭证。

# config/packages/sylius_hipay.yaml

sylius_hipay:
    # The "api" key works for credit cards (as hosted field) but also for paiement 3x/4x
    api:
        api_private_username: 'Username for api'
        api_private_password: 'Password for api'
        api_secret_passphrase: 'Secret Passphrase for api'
        stage: 'stage or prod'
        locale: 'fr'
        # notify_url: '' # Optional; for development purpose, e.g a link to a requestbin listener.
        do_refunds: true

    # The "api_moto" key is a dedicated creddential for Mo/To paiements
    api_moto:
        api_private_username: 'Username for api Mo/TO'
        api_private_password: 'Password for api Mo/TO'
        api_secret_passphrase: 'Secret Passphrase for api Mo/TO'
        stage: 'stage or prod'
        locale: 'fr'
        # notify_url: '' # Optional; for development purpose, e.g a link to a requestbin listener.
        do_refunds: true

配置

覆盖 twig 文件

在文件末尾添加块 JavaScript,在您的其他覆盖块之后

# templates/bundles/SyliusShopBundle/Order/show.html.twig

{% block javascripts %}
    {{ parent() }}
    {% include '@SmileHipaySyliusPlugin/Scripts/hipay_scripts.html.twig' %}
{% endblock %}
# templates/bundles/SyliusShopBundle/Checkout/selectPayment.html.twig

{% block javascripts %}
    {{ parent() }}
    {% include '@SmileHipaySyliusPlugin/Scripts/hipay_scripts.html.twig' %}
{% endblock %}

您可以通过覆盖此文件来激活 Hipay 字段,并为 cartAmount(在后台办公室配置)添加限制。

# templates/bundles/SyliusShopBundle/Checkout/SelectPayment/_choice.html.twig

{% set cartAmount = order.total / 100 %}
{% set cartAmountMin = method.gatewayConfig.config.cartAmountMin ?? null %}
{% set cartAmountMax = method.gatewayConfig.config.cartAmountMax ?? null %}

{% if (cartAmountMin is null or cartAmountMin <= cartAmount) and (cartAmountMax is null or cartAmountMax >= cartAmount) %}
    <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')) }}
            </div>
        </div>
        <div class="content">
            <a class="header">{{ form_label(form, null, {'label_attr': {'data-test-payment-method-label': ''}}) }}</a>
            {% if method.description is not null %}
                <div class="description">
                    <p>{{ method.description }}</p>
                </div>
            {% endif %}
            {{ include('@SmileHipaySyliusPlugin/Payment/hipay_gateways.html.twig') }}
            {% if method.gatewayConfig.factoryName == 'sylius.pay_pal' %}
                {{ render(controller('Sylius\\PayPalPlugin\\Controller\\PayPalButtonsController:renderPaymentPageButtonsAction', {'orderId': order.id})) }}
            {% endif %}
        </div>
    </div>
{% endif %}