0

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?

Maksim Kotlyar
  • 3,821
  • 27
  • 31
Marc Juchli
  • 2,240
  • 24
  • 20
  • 1
    I likely answer this question but before I want to clarify somethings? When you say "For example he closes the paypal process I keep data saved." you mean the user close a browser or click paypal cancel button and come back to your site? Could you post what your model contains before you try pay again and after? BTW: payments_transaction_success - is not the right name, all failed\pending\success payments redirected to that url. You have to check status there – Maksim Kotlyar Nov 17 '13 at 11:58
  • Exactly, when he closes the window or something. The model contains only like: id, token, correlationid, paymentaction (sale), return/cancel url. The rest is an empty json. Thanks for the tipp. I do status checking in this controller but seems like a better idea to do so right here. – Marc Juchli Nov 17 '13 at 16:58
  • does he close the window after he logged in on paypal or before? – Maksim Kotlyar Nov 18 '13 at 07:15

1 Answers1

2

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.

Maksim Kotlyar
  • 3,821
  • 27
  • 31
  • Ah I see the point now with: PaymentActionNotInitiated. Thank you for the detailed investigation! I think this is good to handle. Either delete the current (no initiated) payment and create a new one at the point when a user wants to pay afterwards. Or keep data and create an additional one on payment. (The second one would mean that I'd have to deal with many-to-one in my specific case. I prefer the way with delete and create and go along with one-to-one). – Marc Juchli Nov 20 '13 at 06:27