robmcvey / cakephp-paypal

CakePHP 2.0 plugin for PayPal Website Payment Pro
60 stars 44 forks source link

PaypalRedirectException is never thrown due to an empty $parsed['TOKEN’] on line 413 #33

Closed alusev closed 9 years ago

alusev commented 9 years ago

I had an actual ‘paypal redirect error’ (10486) while calling doExpressCheckoutPayment. I noticed that $parsed doesn’t have a TOKEN key. So I used the $token passed as an argument and it worked great.

throw new PaypalRedirectException($this->expressCheckoutUrl( $token ));

PS: Great plugin! Thanks a lot!

alusev commented 9 years ago

I almost forgot. I also altered the if statement on line 411:

if (in_array($parsed['L_ERRORCODE0'], $this->redirectErrors)) {
    // We can catch an exception that requires a redirect back to paypal
    throw new PaypalRedirectException($this->expressCheckoutUrl( $token ));
}
robmcvey commented 9 years ago

I don't suppose you logged the full response from PayPal when you received the 10486 error code did you? It would be great to update the tests with this.

robmcvey commented 9 years ago

OK I've found an example;

(
    [TIMESTAMP] => 2014-02-17T19:36:38Z
    [CORRELATIONID] => eb921d
    [ACK] => Failure
    [VERSION] => 53.0
    [BUILD] => 972069
    [L_ERRORCODE0] => 10486
    [L_SHORTMESSAGE0] => This transaction couldn't be completed.
    [L_LONGMESSAGE0] => This transaction couldn't be completed. Please redirect your customer to PayPal.
    [L_SEVERITYCODE0] => Error
)

Thanks for spotting this, will add a fix shortly :smile:

alusev commented 9 years ago

Yes, I have logged it: Array ( [TIMESTAMP] => 2015-04-07T19:01:02Z [CORRELATIONID] => da002affa0d97 [ACK] => Failure [VERSION] => 104.0 [BUILD] => 16057073 [L_ERRORCODE0] => 10486 [L_SHORTMESSAGE0] => This transaction couldn't be completed. [L_LONGMESSAGE0] => This transaction couldn't be completed. Please redirect your customer to PayPal. [L_SEVERITYCODE0] => Error )

Sorry, I guess I am a little bit late.