Support for new version reCAPTCHA / V2

< ... < 2 3 4 5 6
Posted: April 16, 2018 at 3:28 PM Quote #203277
I was on 3.7. I figured if I was doing the work I'd go to 4.

I ran the 3.7-3.8 script. I ran the 3.8-3.9 script. I ran the 3.9-4.0 script.

I pulled the site contents down via git (I'm running in Azure). I deleted everything. Copied in all the 4.00 stuff. Copied back my two .txt files as per the instructions. Committed and pushed back to the server.

That all seemed to work - the site came up, I can see my previous orders, customers, products.

I just checked now and it finally does appear to have updated the captcha setting. Perhaps there's some data caching that takes time to clear/refresh?

Now at least my error is about keys - so I must have mis-entered the new v2 keys and I'll need to try them again.

I assumed private=private and public=secret, but maybe it is the other way around?
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: April 16, 2018 at 3:37 PM Quote #203278
Glad to hear it's working finally if it was just a caching issue. And...

Nop's "public" key = reCaptcha "site" key
Nop "private" key = reCaptcha "secret" key
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: May 12, 2018 at 6:09 AM Quote #204216
gyn wrote:
Hi,

I have implemented this with reCAPTCHA4net from http://recaptcha4net.codeplex.com/
Demo at shop.getyournet.ch

Step 1
In Nop.Web.Framework, add a reference to the assembly Recaptcha.Web
Also add a reference to System.Net.Http

Step 2
In Nop.Web.Framework > UI > Captcha, change the file HtmlExtensions.cs

using System.IO;
using System.Web.Mvc;
using System.Web.UI;
using Nop.Core.Infrastructure;

namespace Nop.Web.Framework.UI.Captcha
{
    public static class HtmlExtensions
    {
        public static string GenerateCaptcha(this HtmlHelper helper)
        {
            var captchaSettings = EngineContext.Current.Resolve<CaptchaSettings>();

            var theme = !string.IsNullOrEmpty(captchaSettings.ReCaptchaTheme) ? captchaSettings.ReCaptchaTheme : "white";
            var captchaControl = new Recaptcha.Web.UI.Controls.Recaptcha
            {
                ID = "recaptcha",
                ColorTheme = Recaptcha.Web.ColorTheme.Light,
                PublicKey = captchaSettings.ReCaptchaPublicKey,
                PrivateKey = captchaSettings.ReCaptchaPrivateKey
            };

            var htmlWriter = new HtmlTextWriter(new StringWriter());

            captchaControl.RenderControl(htmlWriter);

            return htmlWriter.InnerWriter.ToString();
        }
    }
}


Step 3
In Nop.Web.Framework > UI > Captcha, change the file CaptchaValidatorAttribute.cs

using System.Web.Mvc;
using Nop.Core.Infrastructure;
using System;
using System.Net.Http;
using Newtonsoft.Json.Linq;
using Nop.Services.Tasks;
using System.Threading.Tasks;

namespace Nop.Web.Framework.UI.Captcha
{
    public class CaptchaValidatorAttribute : ActionFilterAttribute
    {
        private const string RESPONSE_FIELD_KEY = "g-reCAPTCHA-response";

        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var valid = false;
            var captchaResponseValue = filterContext.HttpContext.Request.Form[RESPONSE_FIELD_KEY];
            if (!string.IsNullOrEmpty(captchaResponseValue))
            {
                var captchaSettings = EngineContext.Current.Resolve<CaptchaSettings>();
                if (captchaSettings.Enabled)
                    valid = System.Threading.Tasks.Task.Factory.StartNew(async () => await ValidateResponse(captchaResponseValue, captchaSettings.ReCaptchaPrivateKey).ConfigureAwait(false)).Unwrap().Result;
            }

            //this will push the result value into a parameter in our Action  
            filterContext.ActionParameters["captchaValid"] = valid;

            base.OnActionExecuting(filterContext);
        }

        private async Task<bool> ValidateResponse(string captchaResponseValue, string key)
        {
            var valid = false;
            var uribuilder = new UriBuilder("https://www.google.com/recaptcha/api/siteverify")
            {
                Query = string.Format("secret={0}&response={1}", key, captchaResponseValue)
            };
            using (var httpClient = new HttpClient())
            {
                var async = await httpClient.GetAsync(uribuilder.Uri);
                async.EnsureSuccessStatusCode();
                var readstring = await async.Content.ReadAsStringAsync();
                var resultobject = JObject.Parse(readstring);
                valid = resultobject.Value<bool>("success");
            }
            return valid;
        }
    }
}


Step 4
Compile the project and copy Nop.Web.Framework.dll and Recaptcha.Web.dll to the bin folder of your production site


Thanks a lot! I've managed to successfully include it in NopCommerce 3.60. However, the captcha generated DIV is not centered.

EDIT: You can center it by modifing the styles.css:

.captcha-box {
  text-align: center;
  line-height: 0; /*firefox line-height bug fix*/
        width: 304px;
        margin: 0 auto;
}
.captcha-box > div {
  display: inline-block;
        max-width: 100%;
        margin: auto;
}
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: January 01, 2019 at 4:40 AM Quote #217597
Hi all
and happy new year
Does 4.10 support captcha v3?
If it does, how can we use it? cause there is no dropdown list to select version in demo 4.10
http://admin-demo.nopcommerce.com/Admin/Setting/GeneralCommon

thanks in advanceac
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: January 02, 2019 at 1:13 AM Quote #217612
HI All,

we are using Nop V2.60 version, is it possible to convert reCAPTCHA V1 to V2. if possible how can I follow the steps.

Thanks,
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Thanks,
Venkat Goud,
https://venkatb4me.wordpress.com/
Posted: January 03, 2019 at 5:37 AM Quote #217649
venkatgoud wrote:
we are using Nop V2.60 version, is it possible to convert reCAPTCHA V1 to V2. if possible how can I follow the steps

Download one of the next version (e.g. 3.90) and see how it's implemented there. Then do the same in your 2.60
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Interested in the dedicated Premium support services provided by core developers? Please visit http://www.nopcommerce.com/supportservices.aspx

Regards,
Andrei Mazulnitsyn
Posted: February 22, 2019 at 12:13 PM Quote #221298
Hi there,

Does 4.10 support captcha v3?
This post/answer is useful
1
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Kind regards,
Odinn Thor
Posted: July 09, 2019 at 10:06 AM Quote #242306
Hi,

When I use nopcommerce 3.9, recaptcha has no error when submitting the form. I have upgraded to nopcommerce 4.2 and feel recaptcha errors regularly. I submit the form 10 times, the error is 8 times or 9 times and only 1 time.
I use the login form, contact us etc. by default nopcommerce.

Has anyone ever encountered this problem with nopcommerce version 4.2. I install nopcommerce 4.2
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Plugin Dynamic Form for nopCommerce (Plugin Contact Form Nopcommerce): http://nopplugin.com/dynamic-form-nopcommerce

Nopcommerce Amp Plugin: http://nopplugin.com/google-accelerated-mobile-for-nopcommerce

Nopcommerce Multi Tenant: http://nopplugin.com/nopcommerce-multi-tenant-download
< ... < 2 3 4 5 6
Premium support services
  • Dedicated premium support services provided by core developers are intended for persons who run mission critical websites, work on projects with tight deadlines, or want to get dedicated support.
Professional services
  • Want to open a new store? Want to take your store to the next level? Need a custom extension? We can customize nopCommerce to fit your store perfectly. Request a quote to get started.
eCommerce CONFERENCE 2019
Learn more