Search code examples
symfonypayum

Payum - How to repeat Paypal payment when user close browser being on paypal side.


I have an ExpressCheckout up and running. Now I want to give the user the chance to make the payment at a later time. For example he closes the paypal process I keep data saved.

I guess this must be pretty straightforward but somehow it wont redirect me to paypal anymore. The only thing I did so far is to use the identifier to find an existing model instead of creating a new one. This part works so it'll find the specific record of the PaypalExpressPaymentDetails table. But as I said it wont redirect to paypal. Here is the code:

$paymentName = 'demo_paypal';
    $storage = $this->get('payum')->getStorageForClass(
        'Demo\UserBundle\Entity\PaypalExpressPaymentDetails',
        $paymentName
    );

    /** @var $paymentDetails PaymentDetails */
    $paymentDetails = $storage->createModel();
    $paymentDetails->setPaymentrequestCurrencycode(0, $currency);
    $paymentDetails->setPaymentrequestAmt(0, $amount);
    $storage->updateModel($paymentDetails);


    $captureToken = $this->getTokenFactory()->createCaptureToken(
        $paymentName,
        $paymentDetails,
        'payments_transaction_success'
    );

    $paymentDetails->setReturnurl($captureToken->getTargetUrl());
    $paymentDetails->setCancelurl($captureToken->getTargetUrl());
    $paymentDetails->setInvnum($paymentDetails->getId());
    $storage->updateModel($paymentDetails);

Executed Controller:

...
$identificator = new Identificator($entity->getId(), 'Demo\UserBundle\Entity\PaypalExpressPaymentDetails');
$captureToken = $this->payLateByPaypal($entity->getAmount(), "USD", $entity->getId(), $identificator);
return $this->redirect($captureToken->getTargetUrl());

Any ideas?


Solution

  • I've reproduce it in the sandbox. Unfortunately it is a known issue. If the user logged in and access the page second time the payment considered as canceled. That's done this way to avoid endless redirection between your site and paypal one. I dont see an easy way to solve it.

    UPDATE

    In version 1.0 the cancel issue is handled correctly.