首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Payum新付款网关通知行动

Payum新付款网关通知行动
EN

Stack Overflow用户
提问于 2014-06-04 16:53:56
回答 1查看 1.1K关注 0票数 1

我已经在Payum中实现了一个新的支付网关,我试图在通知操作中更改响应,默认的payum发送204和支付网关需要接收200。

我怎样才能改变反应呢?

代码语言:javascript
复制
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:

代码语言:javascript
复制
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);
}
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-06-05 06:08:09

您可以在抛出响应交互请求的末尾使用NotifyAction

代码语言:javascript
复制
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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24043242

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档