Title: Doesn&#8217;t work with Paypal
Last modified: November 15, 2019

---

# Doesn’t work with Paypal

 *  Resolved [megosoft](https://wordpress.org/support/users/megosoft/)
 * (@megosoft)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/doesnt-work-with-paypal/)
 * We have an ecommerce, where is made the integration with mailchimp. When direct
   pay payment method is selected, everything is OK, but when user select PayPal,
   and pay for the goods, only FNAME, LNAME, EMAIL is saved in mailchimp. How can
   I add more fields to mailchimp?
    Via direct payment everything is OK, via PayPal
   not.
 * Here’s the code snippet
    `add_filter( ‘mc4wp_integration_woocommerce_data’, function(
   $data ) { foreach( WC()->cart->get_cart() as $cart_item ){ $product_var_name 
   = array(); $product_id = $cart_item[‘variation_id’]; $product_name = (get_the_title(
   $product_id)); //$product_var_name = str_replace(“Lístok na preteky”, “Lístok”,
   $product_name); }
 *  // Grab Mailchimp field values from the current request
    $data[‘SEX’] = sanitize_text_field(
   $_POST[‘billing_gender’] ); $data[‘BIRTHDATE’] = sanitize_text_field( $_POST[‘
   billing_birthdate’] ); $data[‘CITY’] = sanitize_text_field( $_POST[‘billing_city’]);
   $data[‘ADDRESS’] = sanitize_text_field($_POST[‘billing_address_1’]); $data[‘CATEGORY’]
   = sanitize_text_field($product_name); $data[‘PHONE’] = sanitize_text_field($_POST[‘
   billing_phone’]);
 *  // Return the fields so the plugin knows to send them to Mailchimp
    return $
   data; });

Viewing 13 replies - 1 through 13 (of 13 total)

 *  Plugin Contributor [Harish Chouhan](https://wordpress.org/support/users/hchouhan/)
 * (@hchouhan)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/doesnt-work-with-paypal/#post-12140223)
 * Hello,
 * Can you please share a link to your checkout page?
 * Also, when you go to the “MC4WP > Others” menu, do you see any errors?
 *  Thread Starter [megosoft](https://wordpress.org/support/users/megosoft/)
 * (@megosoft)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/doesnt-work-with-paypal/#post-12144313)
 * Hi, there is something like this
 *     ```
       [2019-11-16 09:58:21] ERROR: WooCommerce Checkout > Mailchimp API Error: Bad Request. Invalid Resource. kari************@gm***.con looks fake or invalid, please enter a real email address.
       Request: POST https://us20.api.mailchimp.com/3.0/lists/2a3c06b967/members - {"status":"subscribed","email_address":"kari************@gm***.con","interests":{},"merge_fields":{"ADDRESS":"Oslobodite\u013eov 264","BIRTHDATE":"2000-02-15","CATEGORY":"L\u00edstok – CLASSIC","CITY":"Kr\u00e1snohorsk\u00e9 Podhradie","FNAME":"Karin","LNAME":"Voz\u00e1rov\u00e1","PHONE":"0904819080","SEX":"\u017dena"},"email_type":"html","ip_signup":"185.214.192.24","tags":[]}
       Response: 400 Bad Request - {"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/","title":"Invalid Resource","status":400,"detail":"kari************@gm***.con looks fake or invalid, please enter a real email address.","instance":"0dfc6262-bc60-48ce-a0d3-d11809cd2503"}
       ```
   
 * But the e-mail is stored in MCH. Also name of product. What is missing, is additional
   fields in checkout.
 * Link on checkout – please, click this link: [https://therace.sk/registracia-kategorie/elite/](https://therace.sk/registracia-kategorie/elite/)
   and click there “Kúp si lístok” red button. This is a custom link to add a variation
   to cart and redirect to checkout.
    -  This reply was modified 6 years, 6 months ago by [megosoft](https://wordpress.org/support/users/megosoft/).
 *  Plugin Contributor [Harish Chouhan](https://wordpress.org/support/users/hchouhan/)
 * (@hchouhan)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/doesnt-work-with-paypal/#post-12145340)
 * Hello,
 * Can you please let us know what you mean by “MCH”?
 * Also, is this email “kari************@gm***.con” yours? Can you test from a different
   email address and see if the details are sent to MailChimp.com even when selecting
   PayPal?
 *  Thread Starter [megosoft](https://wordpress.org/support/users/megosoft/)
 * (@megosoft)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/doesnt-work-with-paypal/#post-12145543)
 * Hi, MCH == MailChimp 🙂
 * this kari***… is not my e-mail, but client’s. Here’s the screenshot of the MCH
   audience list
    [https://prnt.sc/pyiajr](https://prnt.sc/pyiajr)
 * E-mail is e-mail. You understand. Everything is OK. Krstné meno == first name,
   Priezvisko == last name, Pohlavie == gender, Kategória == product (variant)
 * So where is nothing else, but e-mail, it’s OK, this is subscribers from newsletter
   form, they will be filtered to send newsletter mails. That’s OK.
 * Where is everything (including Pohlavie – gender), those guys paid by direct 
   bank pay. Everything is OK. Where gender is missing, those guys paid by PayPal.
   We need those information, but they are not in audience lists. I don’t know why?
 * I can understand, if no gender was there, but not if only product is paid via
   PayPal… ? For paypal there is “Paypal express” plugin used.
 *  Plugin Author [Danny van Kooten](https://wordpress.org/support/users/dvankooten/)
 * (@dvankooten)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/doesnt-work-with-paypal/#post-12146494)
 * Hello [@megosoft](https://wordpress.org/support/users/megosoft/),
 * This is because the data is no longer in `$_POST` by the time the customer is
   redirect back from the PayPal website to your website to finalise the order. 
   No worries though, because the data is saved by WooCommerce we can look it up
   from where they stored it – on the order itself.
 *     ```
       add_filter( 'mc4wp_integration_woocommerce_data', function( $data, $order_id ) {
       	$product_name = '';
       	foreach( WC()->cart->get_cart() as $cart_item ){
       		$product_var_name = array();
       		$product_id = $cart_item['variation_id'];
       		$product_name = (get_the_title($product_id));
       		//$product_var_name = str_replace(“Lístok na preteky”, “Lístok”, $product_name);
       	}
   
       	$order = wc_get_order( $order_id );
   
       	// Grab Mailchimp field values from the current request
       	$data['SEX'] = $order->get_meta('billing_gender', true );
       	$data['BIRTHDATE'] = $order->get_meta('billing_birthdate', true );
       	$data['CITY'] = $order->get_billing_city();
       	$data['ADDRESS'] = $order->get_billing_address_1();
       	$data['CATEGORY'] = $product_name;
       	$data['PHONE'] = $order->get_billing_phone();
   
       	// Return the fields so the plugin knows to send them to Mailchimp
       	return $data;
       }, 10, 2);
       ```
   
 * Hope that helps. If not, let us know please.
 * PS. I notice you’re trying to send data to Mailchimp about the products bought.
   I would recommend using the order to look for bought products instead of using
   the cart object, as the cart may have already been emptied at the time this snippet
   runs.
 * An even better solution would be to use [our e-commerce integration feature in Mailchimp for WordPress Premium](https://mc4wp.com/premium-features/ecommerce/)
   as it allows you to see exactly what was bought by your subscribers and when.
 *  Thread Starter [megosoft](https://wordpress.org/support/users/megosoft/)
 * (@megosoft)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/doesnt-work-with-paypal/#post-12149103)
 * Please, what means ,10, 2 in the last line of code?
 *  Thread Starter [megosoft](https://wordpress.org/support/users/megosoft/)
 * (@megosoft)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/doesnt-work-with-paypal/#post-12149134)
 * Your code with direct bank pay works OK, thank you. I must wait for new order
   by PayPal 🙂 hope, everything will be OK
 *  Plugin Contributor [Lap](https://wordpress.org/support/users/lapzor/)
 * (@lapzor)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/doesnt-work-with-paypal/#post-12149620)
 * Awesome, ​Thanks for letting me know.
 * FYI:
    The 10 is the $priority parameter (10 is default) which defines when your
   function will run in regards to the other functions which are attached to the
   nav_menu_css_class filter. 2 is the $accepted_args parameter which tells wordpress
   how many parameters the function you want to add will take.
 * Hope that helps. If you have any questions, please let me know!
 *  Thread Starter [megosoft](https://wordpress.org/support/users/megosoft/)
 * (@megosoft)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/doesnt-work-with-paypal/#post-12149629)
 * Ok, Just one question. In $order_id there is an id of current order?
 *  Plugin Contributor [Lap](https://wordpress.org/support/users/lapzor/)
 * (@lapzor)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/doesnt-work-with-paypal/#post-12149639)
 * Yes I would suppose so, the internal ID.
 *  Thread Starter [megosoft](https://wordpress.org/support/users/megosoft/)
 * (@megosoft)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/doesnt-work-with-paypal/#post-12153380)
 * Hi, I have a new order by PayPal, address, phone and city are stored in mailchimp(
   default woo fields), but additional fields – gender and birthdate are not stored
   🙁
 * In case of direct bank pay everything is OK
 *  Thread Starter [megosoft](https://wordpress.org/support/users/megosoft/)
 * (@megosoft)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/doesnt-work-with-paypal/#post-12158638)
 * Hi, update.
    The problem is not in your plugin. The additional fields are missing
   in database, while user pays via PayPal express. Your plugin is awesome 😉 Thanks
   for help
 *  Plugin Author [Danny van Kooten](https://wordpress.org/support/users/dvankooten/)
 * (@dvankooten)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/doesnt-work-with-paypal/#post-12160155)
 * Awesome, glad to hear it [@megosoft](https://wordpress.org/support/users/megosoft/).
   Thanks for letting us know!
 * If you have a quick minute to spare to [leave us a plugin review](https://wordpress.org/support/plugin/mailchimp-for-wp/reviews/),
   it’d make us very happy!

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘Doesn’t work with Paypal’ is closed to new replies.

 * ![](https://ps.w.org/mailchimp-for-wp/assets/icon-256x256.png?rev=1224577)
 * [MC4WP: Mailchimp for WordPress](https://wordpress.org/plugins/mailchimp-for-wp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mailchimp-for-wp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mailchimp-for-wp/)
 * [Active Topics](https://wordpress.org/support/plugin/mailchimp-for-wp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mailchimp-for-wp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mailchimp-for-wp/reviews/)

 * 13 replies
 * 4 participants
 * Last reply from: [Danny van Kooten](https://wordpress.org/support/users/dvankooten/)
 * Last activity: [6 years, 6 months ago](https://wordpress.org/support/topic/doesnt-work-with-paypal/#post-12160155)
 * Status: resolved