PayPal Express Checkout fails on events
To replicate:
- Set up PayPal Pro.
- Create a paid event using PayPal Pro as the payment processor.
- Attempt to pay via PayPal.
Expected result:
- Payment goes through.
Actual result:
Your browser session has expired and we are unable to complete your form submission. We have returned you to the initial step so you can complete and resubmit the form. If you experience continued difficulties, please contact us for assistance.
Why:
CRM_Event_Form_Registration_Register->postProcess()
has these lines:
$params['component'] = 'event';
// This code is duplicated multiple places and should be consolidated.
$params = $this->prepareParamsForPaymentProcessor($params);
$this->handlePreApproval($params);
But CRM_Core_Form::handlePreApproval()
has this line:
$params['component'] = 'contribute';
As a result, the $params['component']
is ALWAYS treated as contribute
, which causes Civi to send the wrong URL to PayPal as the "success URL". so you're redirected back to civicrm/contribute/transact
instead of civicrm/event/register
.
I have a solution, but I don't have any idea how one tests this. You would need to mock up the PayPal API. Also, this amazingly seems to have been a problem back to 4.7alpha1.