Support

Home Forums Event Espresso Premium Passing parameter to PayPal

Passing parameter to PayPal

Posted: September 27, 2018 at 1:49 pm

Viewing 25 reply threads


prepdoctors

September 27, 2018 at 1:49 pm

Dear support,
How can I pass The primary registrant (Attendee) name and event name details to PayPal so it would show under Invoice Description?
PayPal shows the name of the person who made the payment, but does not show the name of the person who registered for the event.
Please advise
Thank you


Tony

  • Support Staff

September 27, 2018 at 1:56 pm

Hi there,

How and what you need to pass depends on which of the PayPal payment methods you are using, so can you let me know the specific PayPal payment method you are using so I can take a look, please?


prepdoctors

September 27, 2018 at 2:58 pm

I use the standard PayPal Business account (Not the Pro)


Josh

  • Support Staff

September 27, 2018 at 9:20 pm

If you’re using your standard PayPal Business account with the Event Espresso PayPal Express gateway, you’ll add the following code from this gist:

https://gist.github.com/joshfeck/28fd4886176dd189f09d51f6a5ffd2b2

You can add the above to a functions plugin and it will apply the changes to the PayPal order description.


prepdoctors

September 28, 2018 at 11:14 am

Awesome! I’ll try it and keep you posted
Thanks


prepdoctors

October 1, 2018 at 4:20 pm

We’ll start using Stripe pretty soon, can you please share the code to be used with the stripe add-on as well
Much appreciated


prepdoctors

October 2, 2018 at 2:46 pm

Hi Josh,
Nothing happened after I placed the code in functions,
How can I confirm that we’re using PayPal Express?


Josh

  • Support Staff

October 2, 2018 at 2:52 pm

You can confirm you’re using PayPal Express by going to Event Espresso > Payment Methods. That page lists the activated payment methods. If you’re using PayPal Express, that will be indicated there.

Also, if you’ve placed the code into a plugin’s file, did you follow the step by step guide linked earlier that instructs to activate the plugin?


Josh

  • Support Staff

October 3, 2018 at 8:22 am

We’ll start using Stripe pretty soon, can you please share the code to be used with the stripe add-on as well

You’ll add this:

https://gist.github.com/joshfeck/a7578b2a75c6b7bdcb67abdbff4b55d3


prepdoctors

October 3, 2018 at 8:39 am

It doesn’t say in my settings, please see screenshot:
https://drive.google.com/file/d/1gYfM1m_sRZA1T_r7r-JCv66U_hR7YKW7/view?usp=sharing


prepdoctors

October 3, 2018 at 8:46 am

Also, if you’ve placed the code into a plugin’s file, did you follow the step by step guide linked earlier that instructs to activate the plugin?
=================
We did not place it in the plugin’s file, we placed the code in WordPress Theme Functions,
By plugin’s file, Do you mean this: [screenshot below]
https://drive.google.com/file/d/1Gy3ulr6RbZAx9kUbVTpuufUiP0ZEhEae/view?usp=sharing


Josh

  • Support Staff

October 3, 2018 at 8:46 am

You can thank whoever changed the name in the settings for the confusion. Since that’s been changed, you can verify by clicking on the PayPal option there, then click the deactivate button that appears at the bottom of the page. At that point if that’s PayPal Express, you’ll see the following text:

PayPal Express (Express Checkout) is an off-site payment method for accepting payments via PayPal and is available to event organizers in many countries.

Then you’ll click on the Activate button.


Josh

  • Support Staff

October 3, 2018 at 8:48 am

We did not place it in the plugin’s file, we placed the code in WordPress Theme Functions,

That will not work.

By plugin’s file, Do you mean this: [screenshot below]
https://drive.google.com/file/d/1Gy3ulr6RbZAx9kUbVTpuufUiP0ZEhEae/view?usp=sharing

No. That’s the core EE4 plugin and you do not edit that.

You’ll need to follow this guide to add the code to your site:
https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/


prepdoctors

October 3, 2018 at 8:52 am

Confirmed!
We’re using PayPal Express


prepdoctors

October 3, 2018 at 8:59 am

To make sure that the function and the filter are working properly, we used this simple code (to always return the word ‘Tickets’ in the item description but nothing changed

add_filter( ‘FHEE__EE_Gateway___order_description’,
‘att_name_event_name_order_description’, 10, 3
);
function att_name_event_name_order_description( $desc, $gateway, $payment ) {
$desc = ‘Tickets’;
return $desc;
}


Josh

  • Support Staff

October 3, 2018 at 9:02 am

May I ask did you follow this guide when you added the code to the site?

https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/


prepdoctors

October 3, 2018 at 9:12 am

We’ll try this method now
Thanks Josh


prepdoctors

October 3, 2018 at 9:38 am

We see improvement
However, the change we made showed up in the ‘note’ section in PayPal highlighted in red square
We want the attendee name to be in the ‘item name’ section highlighted in Green
https://drive.google.com/file/d/10qiPDzvPbnHkwaZnIdBsCu37PJjxQt-u/view?usp=sharing

Here is how it looks in a Paypal invoice:
https://drive.google.com/file/d/1SZwU3nCfYfuThcQOgOzG_z67mzkz178i/view?usp=sharing


Josh

  • Support Staff

October 3, 2018 at 1:27 pm

I’m glad you got the custom plugin put together and working.

To change the item name, you’ll use a different filter hook. e.g.

add_filter(
    'FHEE__EE_gateway___line_item_name',
    'att_name_event_name_line_items',
    10,
    4
);
function att_name_event_name_line_items(
    $output,
    $object,
    $line_item,
    $payment
) {
  $transaction = $payment->transaction();
  if( $transaction instanceof EEI_Transaction ) {
    $primary_registrant = $transaction->primary_registration();
    if( $primary_registrant instanceof EE_Registration ) {
      $attendee = $primary_registrant->attendee();
      if ($attendee instanceof EE_Attendee) {
        $output = $attendee->get('ATT_full_name'); 
      }
      $event = $primary_registrant->event_obj();
      if ( $event instanceof EEI_Event ) {
        $output .= '  ' . $event->name(); 
      }
    }
  }
  return $output;
}


prepdoctors

October 3, 2018 at 2:25 pm

It worked! Thanks Josh!
Another small request
Is there a way to auto-populate the PayPal checkout form with attendee first name, last name, country, address, email?


Josh

  • Support Staff

October 3, 2018 at 3:22 pm

The billing address fields (including Country) are automatically passed. Please see these screenshots that show an example:
https://slack-files.com/T02SY781D-FD6K4JGGK-fcbc583b20
https://slack-files.com/T02SY781D-FD6K4T1DZ-288087117a

The other fields (like email) are passed to PayPal but apparently PayPal doesn’t use those to autopopulate the checkout form.


prepdoctors

October 3, 2018 at 4:18 pm

Strange, this doesn’t work for me, however, it’s not a big deal..

The last issue I’m dealing with is the Cancel / Return Page:

When someone is ready to pay and goes to Paypal then decides to cancel by clicking on “Cancel and Return” (screenshot1), it takes them to a strange page (screenshot2)
If you look at our Critical Pages configuration (screenshot3), it looks good, and we used the shortcode in the Page (screenshot4), and the page should look like this (screenshot5)

Note that, other critical pages, such as the Thank You Page, works perfectly, but not the cancel page

How can we troubleshoot this problem?

screenshot folder:
https://drive.google.com/open?id=105k14umNaDfJfYWlhqswEhKUVcY1zIzl


Tony

  • Support Staff

October 4, 2018 at 2:45 am

Hi there,

I responded to your other thread last week regarding this, in case you missed it, it’s here: https://eventespresso.com/topic/paypal-cancel-registration-link-does-not-forward-to-cancellation-page/

There are details missing from your checkout form which are then not passed to PayPal checkout, so when PayPal returns the users to the site it doesn’t have all of the details used to post them back and EE has no idea what details to output to the page.


prepdoctors

October 4, 2018 at 8:21 am

Thanks Tony, unfortunately, the developers I was working with dropped the ball so I had to continue the troubleshooting myself
I’ll take a look and keep you posted


Josh

  • Support Staff

October 4, 2018 at 9:55 am

Strange, this doesn’t work for me, however, it’s not a big deal..

You might try using a private browser session (like with Chrome’s Incognito mode) because if your browser has cookies from PayPal.com, that will affect the behavior of the PayPal checkout page.


prepdoctors

October 4, 2018 at 2:54 pm

The return page also worked,
thanks guys for your brilliant support

Viewing 25 reply threads

The support post ‘Passing parameter to PayPal’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso