gatsby-plugin-mailchimp
gatsby-plugin-mailchimp copied to clipboard
Plugin fails if Enable reCAPTCHA is enabled
Overview
If you have a mailing list with the setting for Enable reCAPTCHA turned on, publishing to the list will fail with the error message: captcha.
To get things working I turned off this setting, but it would be nice to have an option for having this feature enabled. I am not exactly sure of the best course of action to get this resolved. At a minimum, the README should be updated to document this issue.
It would be nice to have the option to using this feature within this plugin, if their API supports it then it should be added.
looking into this.
Thanks for pointing this out @mikelax
I don't know if the Mailchimp API allows it. I can look into this.
In the meantime, got a moment to open a PR updating the README? I can merge this week.
@benjaminhoffman sure will do. do you first want to merge #16 ?
not sure if there is any way around this. open to suggestions.
I fell into this issue as well. I think I have a work around which could potentially be integrated into the plugin. If I receive "captcha" back as the error, I manually build the URL for the popup window that is triggered in the normal mailchimp embedded form case. I can then open that popup and successfully fulfill the captcha and sign up the user. It's not a great user experience since they need to allow popups but its no worse than using that captcha otherwise. You may be able to load the url in an iframe on the page and allow the user to finish the flow there. The url for the pop up looks like this:
const { result, msg, params } = await addToMailchimp(this.state.email);
if (msg === 'captcha') {
window.open(`https://<same domain used in plugin config>/subscribe/post?u=${params.u}&id=${params.id}&EMAIL=${encodeURIComponent(params.EMAIL)});
}
I haven't tried it with any of the additional fields that can be passed along as listFields but I expect they could be handled similarly.
EDIT:
I see the url is pretty much exactly the same one as I configured the plugin with. I'm not sure if doing it this way, cancels out some of the point of having the plugin if we know we have the captcha enabled, we could just open that url in a popup on form submit instead of calling addToMailchimp()