symfonypayum

Payum new payment gateway notification action


I have implemented a new payment gateway in Payum, I am trying to change the response in notification action, by default payum send 204 and the payment gateway need to receive 200.

How can I change the response?

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
        ;
}
}

This is 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);
}
}

Solution

  • You can throw a response interactive request at the end of NotifyAction.

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

    Read about interactive request's https://github.com/Payum/Payum/blob/master/src/Payum/Core/Resources/docs/the-architecture.md