[MKT_949]:feat/cloudflare turnstile integration - #394
Open
jaaaaavier wants to merge 7 commits into
Open
Conversation
Member
|
The markdown table format seems to not be correct @jaaaaavier |
sg-gs
previously approved these changes
Jul 28, 2026
sg-gs
left a comment
Member
There was a problem hiding this comment.
Please add the list of new environment variables in the PR's description @jaaaaavier
xabg2
reviewed
Jul 28, 2026
|
xabg2
approved these changes
Jul 29, 2026
sg-gs
approved these changes
Jul 29, 2026
sg-gs
left a comment
Member
There was a problem hiding this comment.
Adding the environment variables @jaaaaavier
Member
|
Secrets updated @jaaaaavier Turnstile Widget updated to consider |
7 tasks
|
It will be automatically closed in 7 days if no further updates are made. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Changes
The purpose of this PR is to integrate Cloudflare Turnstile into the repo. To do this, we’ve done the following:
assertCaptchafile. Here, we basically decide whether to use the newverifyTurnstilefunction or the oldverifyRecaptchafunction. This allows us to keep what we already had and know works as a fallbackverifyTurnstilefile, we’ve set up everything needed to verify with Cloudflare that the token is correct. This file was created based on the official Cloudflare Turnstile documentation.isTransientNetworkErrormethod to thenetworkRetryfile, since we’ll be using it in different parts of the code.verifyRecaptchawith theasserCaptchadescribed above, markedcaptchaTokenas optional, and addedturnstileTokenin the same way; now, one of these two must be requiredTest
Cloudflare publishes a set of dummy keys: public sitekey/secret pairs that force a deterministic
outcome (always pass, always fail, force an interactive challenge) while still going through the real
siteverifyAPI. They let us exercise the whole chain — browser widget → drive-web → payments →Cloudflare — without creating a widget in the dashboard.
Each scenario was run through a full checkout, checking three places: the request payload in the
browser, the payments logs, and the resulting HTTP status.
1x…BB(pass, invisible) + secret1x…AA(pass)POST /checkout/customerandPOST /checkout/payment-intentboth carry aturnstileTokenalongside the reCAPTCHAcaptchaToken. No fallback warning in the logs. Payment completes.2x…AA(always fails)Turnstile rejected the token: invalid-input-response→ 403, and reCAPTCHA is never consulted.responseTime: 60msconfirms no retries were attempted, i.e. the code was correctly treated as terminal rather than transient.2x…BB(always fails, invisible)600010; noturnstileTokenin the payload; payment completes through reCAPTCHA.generateTurnstileToken()returnsundefined, checkout is unaffected and falls back to reCAPTCHA.I can add some images or video in the task if needed but i think we will need some QA
Notes
The enviroment variables required are:
TURNSTILE_ENDPOINT=https://challenges.cloudflare.com/turnstile/v0/siteverifyTURNSTILE_SECRET=the one used on ai-server