infinite-software/sylius-ecommpay-plugin

Sylius 的 Ecommpay 支付插件。


README

安装

$ composer require infinite-software/sylius-ecommpay-plugin

将插件依赖项添加到您的 app/AppKernel.php 文件中

public function registerBundles()
{
    return array_merge(parent::registerBundles(), [
        ...
        
        new IS\SyliusEcommpayPlugin\ISSyliusEcommpayPlugin(),
    ]);
}

在您的项目管理部分添加新的支付方式,使用 Ecommpay 网关,您应该添加提供的 secretkeyproject_id

请 Ecommpay 支持人员将回调 URL 设置为 http://example.com/payment/notify/unsafe/ecommpay(如果需要,可以将此操作的路线重新分配到另一个位置)

添加支付页面额外参数

如果您需要在发送请求到 Ecommpay 之前添加参数(例如,从 https://developers.ecommpay.com/ru/ru_PP_Parameters.html),将 Payum\Ecommpay\Action\ConvertPaymentAction 类的内容复制到位于 src/Payment/Ecommpay/ConvertPaymentAction 的新文件中

namespace App\Payment\Ecommpay;

//use ...;

final class ConvertPaymentAction implements ActionInterface, ApiAwareInterface
{
    ...

    /**
     * {@inheritDoc}
     *
     * @param Convert $request
     */
    public function execute($request)
    {
        RequestNotSupportedException::assertSupports($this, $request);

        /** @var PaymentInterface $payment */
        $payment = $request->getSource();

        /** @var OrderInterface $order */
        $params = [
            'payment_id' => $payment->getNumber(),
            'payment_amount' => $payment->getTotalAmount(),
            'payment_currency' => $payment->getCurrencyCode(),
            'project_id' => $this->api['projectId'],
            'customer_id' => $payment->getClientId(),
            // my extra parameter
            'force_payment_method' => 'card'
        ];
        $request->setResult($params);
    }
    ...
}

最后,在 services.yaml 中将其声明为服务。不要忘记将服务设置为 public,如下所示

App\Payment\Ecommpay\ConvertPaymentAction:
    public: true
    tags:
        - { name: payum.action, factory: ecommpay, alias: payum.action.convert_payment }