3 minutes November 20, 2026

How to Fix Google reCAPTCHA v3 Issues in Custom AJAX Forms in Shopware

Custom AJAX forms using FormCmsHandler may fail Google reCAPTCHA v3 validation on the live Shopware storefront, even when the reCAPTCHA keys and server-side verification are configured correctly.

When inspecting the network request, the _grecaptcha_v3 field may contain the value recaptcha-pending instead of a valid Google reCAPTCHA token.

As a result, Google’s siteverify endpoint rejects the request, and the form submission fails.

Cause

Shopware’s Google reCAPTCHA plugin generates the token asynchronously. However, custom form plugins that implement sendAjaxFormSubmit() may submit the form before token generation is complete.

Shopware’s reCAPTCHA integration uses the formSubmittedByCaptcha flag to manage form submissions. It expects the custom form plugin to defer its AJAX submission so that the reCAPTCHA plugin can take over and submit the form once a valid token is available.

When the custom form submits too early, the request contains the placeholder value recaptcha-pending instead of the actual Google reCAPTCHA token.

Solution

Update the custom form plugin to follow Shopware’s reCAPTCHA submission flow. This prevents the form from submitting before the CAPTCHA token is ready.

Apply the following changes:

1. Initialise the reCAPTCHA submission flag

Set this.formSubmittedByCaptcha = false inside the plugin’s init() method. Shopware’s reCAPTCHA plugin uses this flag to manage the submission process.

2. Defer the initial AJAX submission

In _submitForm(), call sendAjaxFormSubmit() only when this.formSubmittedByCaptcha is false.

This allows Shopware’s GoogleReCaptchaBasePlugin to take over the submission process and call sendAjaxFormSubmit() after generating the token.

3. Validate the CAPTCHA token before submission

Before executing the AJAX request, check the _grecaptcha_v3 or _grecaptcha_v2 input field.

If the field is empty or still contains recaptcha-pending, stop the submission instead of sending an invalid request.

Example Code

Update the custom form plugin as follows:

4. Apply the Fix to Theme Overrides

If your Shopware storefront uses a theme override of FormCmsHandler, apply the same submission-handling pattern there as well.

For example, custom theme implementations such as HeinzTheme should also be checked and updated to prevent the same issue from occurring.

5. Rebuild the Storefront JavaScript

After making the changes:

  1. Rebuild the Shopware storefront JavaScript.
  2. Clear the relevant storefront caches.
  3. Test the custom form on the staging or live storefront.
  4. Inspect the network request and verify that _grecaptcha_v3 contains a valid token instead of recaptcha-pending.
  5. Confirm that the AJAX form submission completes successfully.

Conclusion: Expected Result

The custom AJAX form waits for Shopware’s reCAPTCHA integration to generate a valid token before submitting the request.

This prevents premature form submissions and allows Google reCAPTCHA validation to complete successfully.

Greetings! I'm Aneesh Sreedharan, CEO of 2Hats Logic Solutions. At 2Hats Logic Solutions, we are dedicated to providing technical expertise and resolving your concerns in the world of technology. Our blog page serves as a resource where we share insights and experiences, offering valuable perspectives on your queries.
Aneesh ceo
Aneesh Sreedharan
Founder & CEO, 2Hats Logic Solutions
Subscribe to our Newsletter
Aneesh ceo

    Stay In The Loop!

    Subscribe to our newsletter and learn about the latest digital trends.