Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PayPal Express on events #16692

Merged
merged 1 commit into from
Mar 9, 2020
Merged

Conversation

MegaphoneJon
Copy link
Contributor

@MegaphoneJon MegaphoneJon commented Mar 5, 2020

https://lab.civicrm.org/dev/financial/issues/119

Overview

PayPal Express 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.

@civibot
Copy link

civibot bot commented Mar 5, 2020

(Standard links)

@civibot civibot bot added the master label Mar 5, 2020
@eileenmcnaughton
Copy link
Contributor

@kcristiano do you have any capacity to test this - I'm thinking of merging based on it looking clearly right & then hoping you will test during rc testing

@kcristiano
Copy link
Member

@eileenmcnaughton I should be able to in the next few days.

@eileenmcnaughton
Copy link
Contributor

Thanks @kcristiano

@kcristiano
Copy link
Member

@eileenmcnaughton I gave this an r-run I could not reproduce the error on the site I have PayPal Pro/Express configured.

It does work with PR applied, so I'd merge.

@seamuslee001
Copy link
Contributor

I'm going to merge based on @kcristiano's review

@seamuslee001 seamuslee001 merged commit c7d8841 into civicrm:master Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants