Steps to reproduce:
1. Disable clean URLs on the site (admin/settings/clean-urls)
2. Set a Successful payment URL to someplace other than "node" (admin/ecsettings/rtypes)
3. Set up PayPal as a checkout option for the site (admin/ecsettings/rtypes)
4. Checkout, complete your purchase on PayPal, follow the link to return to the site.
5. *Bug* You will land back on the homepage, not your defined successful payment URL.

Why? The return path that gets sent to PayPal in this case includes a GET variable, q, which is equal to the path we want the user to land on, and by default PayPal will overwrite this and any GET variables we send with their own in an attempt to tell the site about the transaction.

The Fix:
On line 624 in ec_paypal.module an array of parameters is defined. If the parameter 'rm' is added and set to 2, PayPal will not touch our q variable (in the 'return' parameter) and instead send back the transaction details via POST (which no longer interfere). The user will then land on the page defined in the successful payment URL box on admin/ecsettings/rtypes.

So in terms of a code change - I'd recommend replacing this (starting line 624):
$params = array(
'cmd' => '_xclick',
'business' => ec_paypal_variable_get('ec_paypal_receiver_email', variable_get('site_mail', ini_get('sendmail_from'))),
'return' => url('paypal/return', array('absolute' => TRUE)),
'cancel_return' => url('paypal/cancel', array('query' => 'receipt='. $receipt->erid, 'absolute' => TRUE)),
'notify_url' => url('paypal/ipn', array('absolute' => TRUE)),
'currency_code' => $receipt->currency,
'custom' => 'erid='. $receipt->erid,
'item_name' => variable_get('ec_paypal_cart_description', t('@site_name purchase', array('@site_name' => variable_get('site_name', t('Drupal'))))),
'no_note' => 1,
);

With this (starting line 624):
$params = array(
'cmd' => '_xclick',
'business' => ec_paypal_variable_get('ec_paypal_receiver_email', variable_get('site_mail', ini_get('sendmail_from'))),
'return' => url('paypal/return', array('absolute' => TRUE)),
'rm'=> 2,
'cancel_return' => url('paypal/cancel', array('query' => 'receipt='. $receipt->erid, 'absolute' => TRUE)),
'notify_url' => url('paypal/ipn', array('absolute' => TRUE)),
'currency_code' => $receipt->currency,
'custom' => 'erid='. $receipt->erid,
'item_name' => variable_get('ec_paypal_cart_description', t('@site_name purchase', array('@site_name' => variable_get('site_name', t('Drupal'))))),
'no_note' => 1,
);

Here's the PayPal page that defines the "rm" variable:
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=develo...

CommentFileSizeAuthor
#1 ecommerce-ec_paypal-824374.patch900 bytesSoren Jones

Comments

Soren Jones’s picture

Version: 6.x-4.0-rc18 » 6.x-4.x-dev
Status: Active » Needs review
StatusFileSize
new900 bytes

Patch attached for review.

gordon’s picture

Status: Needs review » Fixed

Thanks, committed to dev

hacmx’s picture

Status: Fixed » Needs review

#1: ecommerce-ec_paypal-824374.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, ecommerce-ec_paypal-824374.patch, failed testing.