Search code examples
symfonypayum

Calling ipn paypal, PayumBundle


I have problems with paypal calling the notification function, i think i have everything set up correctly, however there is little documentation available about this

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

which i am calling with a service defined in services.yml and also this is my configuration according to the git example:

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

Solution

  • Please check you correctly setup NOTIFY_URL. For this you have to generate tokenForNotifyRoute and use its targetUrl as notify. See an example of prepareAction in the sandbox.