Support

Home Forums Event Espresso Premium Charge Paypal Fee per Ticket.

Charge Paypal Fee per Ticket.

Posted: March 25, 2016 at 6:14 am

Viewing 11 reply threads


toppetsales

March 25, 2016 at 6:14 am

Hi!

Recently came across this code and applied it to charge Paypal fees. Our country has a 4.4% + Php 15.00 Paypal charge. The problem is, the fee is only charged to 1 ticket whenever someone buys multiple tickets.

Example:

A ticket is worth Php1,000 so a Paypal fee is charged at Php59.00 (4.4% + 15). But if someone buys 2 tickets, a fee of Php59.00 is still charged instead of Php 118.00.


<?php
/*
Plugin Name: Site plugin - Add PayPal Fees to Event Espresso 4 
Description: A simple plugin for including PayPal fees in the cost of a ticket for a registration for Event Espresso 4.
*/
/* Begin Adding Functions Below This Line; Do not include an opening PHP tag as this sample code already includes one! */

function add_pp_args($args){
 
  $ppamt = $args['amount_1'] + $args['tax_cart'];
  $ppamt = ( ($ppamt * .044) + 15 ); 
  $ppamt = number_format((float)$ppamt, 2, '.', '');
  //remove debug
  foreach($args as $key => $val) if( substr($key,-2) == '_2' ) unset($args[$key]);
  $args['item_name_2'] = "Processing Fee";
  $args['amount_2'] = $ppamt;
  $args['quantity_2'] = $count;
  return $args;
}
 
add_filter('FHEE__EEG_Paypal_Standard__set_redirection_info__arguments','add_pp_args');

/* Stop Adding Functions */

Hope you can help

Thank you!


Josh

  • Support Staff

March 25, 2016 at 7:59 am

You can use and adapt this example code instead:

https://github.com/eventespresso/ee-code-snippet-library/blob/master/checkout/bc_add_cart_modifier.php

The above will apply a percentage surcharge to the entire cart.


toppetsales

March 25, 2016 at 10:46 am

Hi Josh!

How do I apply the surcharge to Paypal payments only? Sorry I’m kind of new to this.

       $cart_modifier_name = 'Paypal Fee';
	$cart_modifier_amount = 0.044 + 15;
	$cart_modifier_description = 'Paypal Fee';
	$cart_modifier_taxable = false; // or false if surcharge is not taxable
	$payment_methods_with_surcharges = array( 'paypal' );

Is this correct? The goal is to charge 4.4% + 15 per item for Paypal only.

Thank you!


Josh

  • Support Staff

March 25, 2016 at 11:34 am

No that’s not correct because you can only pass a percentage amount to the add_percentage_based_item(). With that 15 PayPal fee, is that per item or per transaction?


toppetsales

March 25, 2016 at 11:35 am

The 4.4% + 15 is per item.


Lorenzo Orlando Caum

  • Support Staff

March 25, 2016 at 12:39 pm

Hello,

There is a problem with the original sample code that you shared.

Although it may be add that charge, it will set your transactions to overpaid. This is because it is adjusting the balance on the payment option for PayPal just before you go to pay so when you pay and arrive back, Event Espresso is seeing an amount that is higher than what is actually due.

I recommend going with the suggestion that Josh shared:

https://github.com/eventespresso/ee-code-snippet-library/blob/master/checkout/bc_add_cart_modifier.php

However, there are some things to be aware of.

It adds a surcharge to the payment option that is specified.

It adds a percentage based surcharge.

If you would like to use that function, then you should change the entry for invoice here (https://github.com/eventespresso/ee-code-snippet-library/blob/master/checkout/bc_add_cart_modifier.php#L14) to this:

paypal_standard

Next, change the entry for 10 (https://github.com/eventespresso/ee-code-snippet-library/blob/master/checkout/bc_add_cart_modifier.php#L11) to a percentage such as 5.

Once that is running, then you’ll see a fee added to PayPal standard transactions for the percentage that you added. If you need an exact calculation for the PayPal fees (e.g. percentage + a fixed fee), then feel free to reach out to an Event Espresso professional here:

https://eventespresso.com/developers/event-espresso-pros/


Lorenzo


toppetsales

March 25, 2016 at 1:09 pm

Hi Lorenzo,

Thank you for that. It’s almost working now except for this issue:

After I fill up the attendee information on Step 1, once I have selected Paypal from the payment options, the value it passes to Paypal is not computed with the surcharge. I have to go back to the registration site to refresh the details.


toppetsales

March 27, 2016 at 11:31 am

Tried a couple of registrations but still no luck. You have to refresh the page once you have selected PayPal as a payment option. Of you don’t refresh, the declared PayPal fee still won’t push thru PayPal.

Any help?

Thanks!


toppetsales

March 28, 2016 at 5:23 am

Hello,

Since your replies are incomplete, I am still using the old code posted above

If I use this code:

<?php
/*
Plugin Name: Site plugin - Add PayPal Fees to Event Espresso 4 
Description: A simple plugin for including PayPal fees in the cost of a ticket for a registration for Event Espresso 4.
*/
/* Begin Adding Functions Below This Line; Do not include an opening PHP tag as this sample code already includes one! */

function add_pp_args($args){
 
  $ppamt = $args['amount_1'] + $args['tax_cart'];
  $ppamt = ( ($ppamt * .044) + 15 ); 
  $ppamt = number_format((float)$ppamt, 2, '.', '');
  //remove debug
  foreach($args as $key => $val) if( substr($key,-2) == '_2' ) unset($args[$key]);
  $args['item_name_2'] = "Processing Fee";
  $args['amount_2'] = $ppamt;
  $args['quantity_2'] = 1;
  return $args;
}
 
add_filter('FHEE__EEG_Paypal_Standard__set_redirection_info__arguments','add_pp_args');

/* Stop Adding Functions */

How can I make it get the quantity of the item in cart. What should I change in this line?

$args['quantity_2'] = 1;

Thank you!


Lorenzo Orlando Caum

  • Support Staff

March 28, 2016 at 12:30 pm

Hello,

Support isn’t available on the weekends as team members take time off to spend with their families.

Please take another look at my earlier reply:

https://eventespresso.com/topic/charge-paypal-fee-per-ticket/#post-197693

The old function that you are trying to use will result in an overpaid status so I do not recommend using it.

Is the new example that I mentioned being used in a site specific plugin?


Lorenzo


toppetsales

March 28, 2016 at 5:25 pm

I temporarily used the earlier code and relabeled the ‘overpaid’ status to compensate.

Yes. It worked but you have to refresh it so the value will pass on to PayPal or once you have selected PayPal, you have to go back to the checkout page then finalize it again.


Josh

  • Support Staff

March 29, 2016 at 3:28 pm

Another option you have (and this one doesn’t involve any custom coding) is you set up a separate event for collecting PayPal payments. You can set the price modifiers per ticket (both percentage fees and fixed fees) right in the ticket editor. Then, you install the Payment Methods Pro add-on and set the event to only use the PayPal gateway. The other events without the fees can be set to use the other payment methods.

Viewing 11 reply threads

The support post ‘Charge Paypal Fee per Ticket.’ 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