【问题标题】:Payum new payment gateway notification actionPayum 新支付网关通知操作
【发布时间】:2014-07-25 10:42:22
【问题描述】:

我在 Payum 中实现了一个新的支付网关,我正在尝试更改通知操作中的响应,默认情况下 payum 发送 204 并且支付网关需要接收 200。

如何更改响应?

namespace xxxx\Bundle\xxxxxBundle\Pago\RedsysGateway\Action;

class StoreNotificationAction extends PaymentAwareAction
{


/**
 * {@inheritDoc}
 */
public function execute($request)
{

    /** @var $request SecuredNotifyRequest */
    if(!$this->supports($request)) {
        throw RequestNotSupportedException::createActionNotSupported($this, $request);
    }

    /** @var NotifyRequest $request */
    $notification = new NotificationDetails;
    $notification->setPaymentName($request->getToken()->getPaymentName());

    //save notification


}

/**
 * {@inheritDoc}
 */
public function supports($request)
{
    return
        $request instanceof SecuredNotifyRequest &&
        $request->getModel() instanceof Pago
        ;
}
}

这是 payum NotifyController:

namespace Payum\Bundle\PayumBundle\Controller;

use Payum\Core\Request\NotifyRequest;
use Payum\Core\Request\SecuredNotifyRequest;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class NotifyController extends PayumController
{
public function doUnsafeAction(Request $request)
{
    $payment = $this->getPayum()->getPayment($request->get('payment_name'));

    $payment->execute(new NotifyRequest(array_replace(
        $request->query->all(),
        $request->request->all()
    )));

    return new Response('', 204);
}

public function doAction(Request $request)
{
    $token = $this->getHttpRequestVerifier()->verify($request);

    $payment = $this->getPayum()->getPayment($token->getPaymentName());


    $payment->execute(new SecuredNotifyRequest(
        array_replace($request->query->all(), $request->request->all()),
        $token
    ));

    return new Response('', 204);
}
}

【问题讨论】:

    标签: symfony payum


    【解决方案1】:

    您可以在NotifyAction 末尾添加throw a response interactive request

    class NotifyAction extends AbstractPaymentStateAwareAction
    {
        public function execute($request)
        {
            // ...
    
            throw new ResponseInteractiveRequest(new Response('OK', 200));
        }
    
        public function supports($request)
        {
            return $request instanceof NotifyRequest;
        }
    }
    

    阅读有关交互式请求的https://github.com/Payum/Payum/blob/master/src/Payum/Core/Resources/docs/the-architecture.md

    【讨论】:

      猜你喜欢
      • 2013-03-27
      • 1970-01-01
      • 2014-07-22
      • 2015-04-10
      • 1970-01-01
      • 2017-12-28
      • 2017-12-21
      • 2011-05-17
      • 2015-05-24
      相关资源
      最近更新 更多