Support

Home Forums Pre-Sales Country and address2 not available in gateway?

Country and address2 not available in gateway?

Posted: September 16, 2013 at 8:50 am


Dom Latter

September 16, 2013 at 8:50 am

EE Version 3.1.34.1.P on WP 3.6.1.

I’ve just been extending our Sage Pay gateway. Previously it was installed for a UK customer and “GB” was hardcoded into the billing address. (Sage pay requires that the ISO3166 two letter country code be given for the BillingCountry and DeliveryCountry).

On the interface side we built a drop-down with the two letter country codes. The code gets put in the attendee table as ‘country_id’.

My code is loosely based on the paypal gateway and includes this in sagepay_form_vars.php:
function espresso_display_sagepay_form($payment_data) {
[…]
extract($payment_data);
[…]

This extracts $fname, $lname, $attendee_email, and so on but NOT the address2 and country fields.
I’ve fixed it thus:
$sql = “SELECT address2, country_id FROM wp_events_attendee “;
$sql .= “where id = %d “;
$extra = $wpdb->get_row( $wpdb->prepare( $sql, $attendee_id ));
$address2 = $extra->address2;
$country = $extra->country_id;

It seems to me that this information should be provided automatically. I tried adding them to the SQL query at line 23 of process_payments.php in the function espresso_prepare_payment_data_for_gateways() but that didn’t work for some reason.

Comments welcome.


Seth Shoultes

  • Support Staff

September 16, 2013 at 10:40 am

Interesting. I’ll take a look at this.


Seth Shoultes

  • Support Staff

September 16, 2013 at 10:56 am

Hi Dom,

I think you can add the @address2 variable to the gateways/gateway_display.php. Here is a screenshot: http://www.screencast.com/t/XI4FGC2KGx

I haven’t tested it yet, so please let me know if that works for you. If it does, I will make sure it is added to the next release of Event Espresso.


Dom Latter

September 16, 2013 at 11:09 am

NB the country is not coming through either – I think (but am not sure) that I had a look at what variables were set at that point in the code and that’s what took me to the SQL query which doesn’t actually get these things out. I am sticking with the kludge for now!


Dom Latter

September 17, 2013 at 6:38 am

OK I have had a look at what’s available at that point.
(using print_r(get_defined_vars()) and mail()).

$address2 is there as a top-level variable so your fix will work for that. $country is also there, but empty in our case. The existing code is meant to then use $country_id instead – but $country_id is not set as a top-level variable. country_id *is* set up inside the attendee object (and is also visible inside the last_result inside the wpdb object). So I would guess that another fix is also required.


Jonathan Wilson

March 25, 2015 at 2:00 pm

Hey there,

I wanted to let you all know that we have released our Sage Pay Gateway for Event Espresso 4 and it is now available in our store:

https://eventespresso.com/add-ons/

I’ll be happy to answer any questions you might have.

The support post ‘Country and address2 not available in 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.

Event Espresso