RemotePost doesn't work properly. (4.2)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years 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();
        }
4 years 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.
4 years ago
Hi
Have you solved the problem
4 years ago
We'll check the issue in the near time. Here is a work item
4 years 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");
                    }
4 years ago
Thank you qheylan,
But it does not work for me
4 years 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;

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

Headers are read-only, response has already started.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.