Sylius PayumBundle 是否错误地处理了付款细节?

Is Sylius PayumBundle handling payment details incorrectly?

我正在测试 Bitbag/PayUPlugin,我被网关 API 阻止并出现错误 "Required data missing"。

经过一些调试,我意识到 Sylius 支付实体,特别是 "details" 属性,没有填充数据。

第 53 行更改条件后:

https://github.com/Sylius/Sylius/blob/4e06a4dfb8dc56731470016bb97165f3025947b7/src/Sylius/Bundle/PayumBundle/Action/CapturePaymentAction.php#L53

if ($status->isNew() || $status->isUnknown()) {

支付网关似乎工作正常。

是bug还是我做错了什么?

Sylius/Sylius v1.4.6 Bitbag/PayUPluginv1.8.0

不太可能PayumBundle/CapturePaymentAction有错误(因为使用PayumBundle的人多于PayUPlugin,所以出现bug的概率较小),概念上开头的支付对象状态应该是"new"而不是"unknown",所以条件应该有效。

所以你应该找出https://github.com/BitBagCommerce/SyliusPayUPlugin/blob/master/src/Action/StatusAction.php#L58 class,为什么它没有到达markNew()行。

我猜 BitBagCommerce/SyliusPayUPlugin 已经死了,因为自 7 月以来这个问题还没有得到解决。

为了解决这个问题,我不得不装饰 StatusAction class:

<?php

declare(strict_types=1);

namespace App\Payment\PayU;

use BitBag\SyliusPayUPlugin\Action\StatusAction;
use BitBag\SyliusPayUPlugin\Bridge\OpenPayUBridgeInterface;
use Payum\Core\Action\ActionInterface;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\Exception\RequestNotSupportedException;
use Payum\Core\Request\GetStatusInterface;

final class StatusActionDecorator implements ActionInterface
{
    private $action;

    public function __construct(StatusAction $action)
    {
        $this->action = $action;
    }

    public function setApi($api): void
    {
        $this->action->setApi($api);
    }

    public function execute($request): void
    {
        /** @var $request GetStatusInterface */
        RequestNotSupportedException::assertSupports($this, $request);

        $model = ArrayObject::ensureArrayObject($request->getModel());
        $status = $model['statusPayU'] ?? null;

        if (empty($status) || OpenPayUBridgeInterface::NEW_API_STATUS === $status) {
            $request->markNew();

            return;
        }

        if (OpenPayUBridgeInterface::PENDING_API_STATUS === $status) {
            $request->markPending();

            return;
        }

        if (OpenPayUBridgeInterface::CANCELED_API_STATUS === $status) {
            $request->markCanceled();

            return;
        }

        if (OpenPayUBridgeInterface::WAITING_FOR_CONFIRMATION_PAYMENT_STATUS === $status) {
            $request->markSuspended();

            return;
        }

        if (OpenPayUBridgeInterface::COMPLETED_API_STATUS === $status) {
            $request->markCaptured();

            return;
        }

        $request->markUnknown();
    }

    public function supports($request): bool
    {
        return $this->action->supports($request);
    }
}

然后在 services.yaml:

App\Payment\PayU\StatusActionDecorator:
    decorates: bitbag.payu_plugin.action.status
    arguments: ['@App\Payment\PayU\StatusActionDecorator.inner']