拨打ipn paypal,PayumBundle

时间:2013-09-01 08:53:50

标签: symfony payum

我在使用paypal调用通知功能时遇到问题,我认为我已经正确设置了所有内容,但是关于此内容的文档很少

use Maxim\CMSBundle\Entity\NotificationDetails;
use Payum\Action\ActionInterface;
use Payum\Request\NotifyTokenizedDetailsRequest;
use Symfony\Bridge\Doctrine\RegistryInterface;
use Maxim\CMSBundle\Entity\Visitor;

class StoreNotificationAction implements ActionInterface
{
    protected $doctrine;
    protected $logger;

    public function __construct(RegistryInterface $doctrine, $logger) {
        $this->doctrine = $doctrine;
        $this->logger   = $logger;
    }

    /**
     * {@inheritDoc}
     */
    public function execute($request)
    {
        /** @var NotifyTokenizedDetailsRequest $request */
        $this->logger->err("hi");
        $notification = new NotificationDetails;
        $notification->setPaymentName($request->getTokenizedDetails()->getPaymentName());
        $notification->setDetails($request->getNotification());
        $notification->setCreatedAt(new \DateTime);
        $this->doctrine->getManager()->persist($notification);

        $this->doctrine->getManager()->flush();
    }

    /**
     * {@inheritDoc}
     */
    public function supports($request)
    {
        return $request instanceof NotifyTokenizedDetailsRequest;
    }
}

我用services.yml中定义的服务调用,这也是我根据git示例的配置:

payum:
    contexts:
        paypal_express_checkout_plus_doctrine:
            paypal_express_checkout_nvp:
                api:
                    options:
                        username:  'MYUSER'
                        password:  'MYPAS'
                        signature: 'MYSIGNATURE'
                        sandbox: true
                actions:
                    - myname.action.store_notification
            storages:
                myname\mybundle\Entity\PaypalExpressPaymentDetails:
                    doctrine:
                        driver: orm
                        payment_extension: true
                myname\mybundle\Entity\TokenizedDetails:
                    doctrine:
                        driver: orm
                        payment_extension: true

1 个答案:

答案 0 :(得分:1)

请检查您是否正确设置NOTIFY_URL。为此,您必须生成tokenForNotifyRoute并将其targetUrl用作notify。请参阅沙箱中prepareAction的示例。