Payum新的支付网关通知操作

时间:2014-06-04 16:53:56

标签: symfony payum

我在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);
}
}

1 个答案:

答案 0 :(得分: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