我正在测试Bitbag/PayUPlugin,但是我被网关API阻止,错误为“缺少必需的数据”。
经过一些调试后,我意识到Sylius Payment实体(尤其是“ details”属性)没有用数据实现。
第53行的更改条件之后:
到
if ($status->isNew() || $status->isUnknown()) {
付款网关似乎正常工作。
是错误还是我做错了什么?
Sylius / Sylius v1.4.6 Bitbag / PayUPlugin v1.8.0
答案 0 :(得分:0)
PayumBundle / CapturePaymentAction不太可能出现错误(因为使用PayumBundle的人多于PayUPlugin,因此发生错误的可能性较小),从概念上讲,开始时付款对象的状态应为“新”而不是“未知”,因此条件应该可以。
因此,您应该找出https://github.com/BitBagCommerce/SyliusPayUPlugin/blob/master/src/Action/StatusAction.php#L58类,为什么它没有达到markNew()
行。
答案 1 :(得分:0)
我想BitBagCommerce/SyliusPayUPlugin
已死,因为自7月以来尚未解决此问题。
为了解决这个问题,我必须装饰StatusAction
类:
<?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']