Support » Plugin: Event Registration » Payment failing due to encoding issue in IPN paypal response

  • fgirard

    (@fgirard)


    Hi there,

    Just though that I should share this as I wasted a few frustrating hours to figure it out. Basically, when a member registered to our event, he paid through paypal. Even though the payment made it to our paypal account, he kept seeing “No payment received!” in the confirmation page.

    After a lot of digging, I was able to point it out to a French accented character coming back in the IPN response that cause the INSERT statement for the payment to fail. In fact, it did not make it to the INSERT, it failed in the check_ascii method of wp-db.php. The quick and dirty workaround for me was to strip off the bad character as it was not getting displayed anywhere for the user to see.

    The real solution is likely to figure out the right encoding to use when reading the IPN response, but, here is my dirty workaround:

    in evr_ipn.php:

    in funtion evr_paypal_txn:

    right before:
    if ($wpdb->insert( get_option(‘evr_payment’), $sql, $sql_data ) {

    insert the following:

    // WFormation.com fix - Create query instead of using $wpdb->insert
           $mysql = 'INSERT INTO ' . get_option ( 'evr_payment' ) . ' (payer_id, event_id, payment_date, txn_id, first_name,
                     last_name, payer_email, payer_status, payment_type, memo,
                     item_name, item_number, quantity,
                     mc_gross, mc_currency, address_name, address_street,
                     address_city, address_state,
                     address_zip, address_country, address_status,
                     payer_business_name, payment_status,
                     pending_reason, reason_code, txn_type) VALUES (';
            foreach($sql as $key=>$value){
            	$mysql .= "'" . $value . "',";
            }
            $mysql = rtrim($mysql, ",");
            $mysql .= ")";
    
            // WFormation.com fix -  Remove non-ascii char
            $mysql = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $mysql);
    
            // WFormation.com fix -  Execute manually created clean query
            if ($wpdb->query( $mysql)) {
    		//if ($wpdb->insert( get_option('evr_payment'), $sql, $sql_data ) {
    			$headers = "From: " . $company_options ['company'] . " <" . $company_options ['company_email'] . ">\r\n";

    Hope this helps!!!!

    Frederic Girard
    Co-Founder WFormation.com

    https://wordpress.org/plugins/event-registration/

Viewing 1 replies (of 1 total)
  • Hey there,

    I know PayPal can be troublesome. I spent a lot of time trying to fix this plugin, Event Registration, many years ago. I have since solved these issues by implementing PayPal Express in my own event registration plugin, Event Espresso. We have spent a lot of time debugging and fixing PayPal issues over the years with Event Espresso.

    Since it seems this plugin, Event Registration, is now defunct/removed from WordPress and you need a reliable event registration plugin, I would highly recommend Event Espresso: https://wordpress.org/plugins/event-espresso-decaf/

    Hope that helps. Please let me know if I can help in any way.

Viewing 1 replies (of 1 total)
  • The topic ‘Payment failing due to encoding issue in IPN paypal response’ is closed to new replies.