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