Payment failing due to encoding issue in IPN paypal response
-
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
- The topic ‘Payment failing due to encoding issue in IPN paypal response’ is closed to new replies.