RemotePost doesn't work properly. (4.2)

7 months ago
I create my payment plugin.

I have set propery "PaymentMethodType" to Redirection.

In chrome consele "Failed to load resource: net::ERR_CONNECTION_RESET" and i have get white screen.





Any suggestion?


public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            
            RemotePost remotePost = new RemotePost();
            remotePost.Url = "*************";
            remotePost.Add("clientid", "*************");
            remotePost.Add("clientIp", "*************");
            remotePost.Add("storetype", "*************");
            remotePost.Add("hash", "*************");
            remotePost.Add("islemtipi", "*************");
            remotePost.Add("amount", "*************");
            remotePost.Add("currency", "*************");
            remotePost.Add("oid", "*************");
            remotePost.Add("okUrl", "*************");
            remotePost.Add("taksit", "*************");
            remotePost.Add("rnd", "*************");
            remotePost.Add("failUrl", "*************");

            remotePost.Post();
        }
7 months ago
Even I am also getting the same issue. I am getting proper html when i inspect in elements tab. some how the error it shows is ERR_CONNECTION_RESET.
3 months ago
Hi
Have you solved the problem
3 months ago
We'll check the issue in the near time. Here is a work item
3 months ago
Ars4m wrote:
Hi
Have you solved the problem


Yes. I found a solution.  
You should override "CheckoutController/ConfirmOrder" action and return html content of RemotePost.


                    if (_webHelper.IsRequestBeingRedirected || _webHelper.IsPostBeingDone)
                    {
                        var _httpContextAccessor = EngineContext.Current.Resolve<IHttpContextAccessor>();
                      
                        if (_httpContextAccessor.HttpContext.Session.TryGetValue("RedirectToThirdParty",out _))
                        {
                            var value = _httpContextAccessor.HttpContext.Session.Get<string>("RedirectToThirdParty");
                            if (!string.IsNullOrEmpty(value))
                            {
                                return Content(value, @"text/html");
                            }
                          
                        }
                        //redirection or POST has been done in PostProcessPayment
                        return Content("Redirected");
                    }
3 months ago
Thank you qheylan,
But it does not work for me
3 months ago
To get rid of net::ERR_CONNECTION_RESET error and empty page I didn't change CheckoutController.ConfirmOrder but made small adjustment in RemotePost.Post method.


            //post
            var httpContext = _httpContextAccessor.HttpContext;
            var response = httpContext.Response;
            response.Clear();
            var data = Encoding.UTF8.GetBytes(sb.ToString());

            response.OnStarting(state =>
            {
                var context = (HttpContext)state;
                context.Response.Headers.Add("Content-Type", "text/html; charset=utf-8");
                context.Response.Headers.Add("Content-Length", data.Length.ToString());

                return Task.CompletedTask;
            }, httpContext);

            response.Body.Write(data, 0, data.Length);

            //store a value indicating whether POST has been done
            _webHelper.IsPostBeingDone = true;

3 months ago
Thanks for the investigation. You can see changes here.
1 month ago
In version 4.30 I get the same error. Anybody find the solution?