We have a situation where we require the buyers of certain events to pay for choosing the payment method(gateway). I found the following set of code very useful to start with
Can this code be further modified to select only certain events that the surcharge applies? I’m thinking maybe you could hard-code event_id’s somewhere that can do the job but I’m not so sure.
The code can be modified to include some checks for event ID’s. Before you do that though, you’ll need to get the event information from the transaction object. You’ll note that on line 31 of the example code it has the transaction object set as $transaction:
You can get the event object by adding the following:
if ( $transaction instanceof EE_Transaction ) {
foreach ( $transaction->registrations() as $registration ) {
if ( $registration instanceof EE_Registration ) {
$event = $registration->event();
// you have the $event object now, so you can compare your array of event ID's to $event-ID();
}
}
}
Here, ‘invoice’ obviously is the slug for method Invoice
Lets say we are adding a method called ‘123’, what would be the slug for it to use in this particular code?
You can look in the database with a tool like phpMyAdmin to get this information. You go to the _esp_payment_method table and look at the PMD_slug column in your custom payment method’s row.
Viewing 3 reply threads
The support post ‘Surcharge for payment gateway’ 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.
Support forum for Event Espresso 3 and Event Espresso 4.