Redirection Payment method in NopCommerce 4.00

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
I have developed a payment plugin(PaymentMethodType.Redirection) 3.90 and it is worked fine.

also; I create a form in PostProcessPayment and post it(POST method necessary). Page goes to the Bank Payment Page and return result.

        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {//3.90
            var myForm = "<form action=\"{0}\" method=\"POST\" />" +
        "<input type=\"hidden\" name=\"secure3dsecuritylevel\" value=\"CUSTOM_PAY\" />" +
              "<input type=\"hidden\" name=\"successurl\" value=\"{1}\" />" +
              "<input type=\"hidden\" name=\"errorurl\" value=\"{2}\" />" +
              "<input type=\"hidden\" name=\"secure3dhash\" value=\"{3}\" />" +
              "</form>"+
                "<script> document.forms[0].submit();</script>";  
            
                _httpContext.Response.Clear();
                _httpContext.Response.Write(myForm);
                _httpContext.Response.End();
        }

but at 4.00 not worked.

        void IPaymentMethod.PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {//4.00

                byte[] data = System.Text.Encoding.UTF8.GetBytes(myForm);

                _httpContextAccessor.HttpContext.Response.Clear();
                _httpContextAccessor.HttpContext.Response.Body.Write(data, 0, data.Length);
                _httpContextAccessor.HttpContext.Response.Body.Close();
  }
  

  As a result, it writes myForm to the page as text.
  
  PaypalStandart is not a good example for me. I need to send form with POST.

  Is there any solution suggestion?
5 years ago
If it's outputting your form as plaintext then it sounds like the Content Type header is not being set correctly. Check your browser's devtools to see what headers are being sent.
5 years ago
thanks timmit,

I added Header to myForm and it is right.


            <!DOCTYPE html><html><head><meta charset="utf-8" /> </head>
             <body>

               ///myForm

            </body></html>"
5 years ago
I'm talking about the Content-Type HTTP header
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type
5 years ago
Hello,
This is actually pretty easy todo. There is builint method in Nop.Web.Framework. Here you can find in other plugins as well. Here is the code for it:

      
            var post = new RemotePost
            {
                FormName = "alipaysubmit",
                Url = "https://www.alipay.com/cooperate/gateway.do?_input_charset=utf-8",
                Method = "POST"
            };

            post.Add("service", Service);
            post.Add("partner", partner);
            post.Add("seller_email", sellerEmail);
            post.Add("out_trade_no", outTradeNo);
            post.Add("subject", subject);
            post.Add("body", body);
            post.Add("total_fee", totalFee);
            post.Add("show_url", ShowUrl);
            post.Add("return_url", returnUrl);
            post.Add("notify_url", notifyUrl);
            post.Add("payment_type", "1");
            post.Add("sign", sign);
            post.Add("sign_type", SignType);

            post.Post();


https://github.com/nopSolutions/alipay-plugin-for-nopcommerce/blob/bfc2700483dba3c494ce012f714bd1ca725568d5/Nop.Plugin.Payments.AliPay/AliPayPaymentProcessor.cs#L155

https://github.com/nopSolutions/okpay-plugin-for-nopcommerce/blob/13872a8e7546461aae03a78e5ff21078beb5349f/Nop.Plugin.Payments.OkPay/OkPayPaymentProcessor.cs#L187
5 years ago
dotnetdreamer wrote:
Hello,
This is actually pretty easy todo. There is builint method in Nop.Web.Framework. Here you can find in other plugins as well. Here is the code for it:

      
            var post = new RemotePost
            {
                FormName = "alipaysubmit",
                Url = "https://www.alipay.com/cooperate/gateway.do?_input_charset=utf-8",
                Method = "POST"
            };

            post.Add("service", Service);
            post.Add("partner", partner);
            post.Add("seller_email", sellerEmail);
            post.Add("out_trade_no", outTradeNo);
            post.Add("subject", subject);
            post.Add("body", body);
            post.Add("total_fee", totalFee);
            post.Add("show_url", ShowUrl);
            post.Add("return_url", returnUrl);
            post.Add("notify_url", notifyUrl);
            post.Add("payment_type", "1");
            post.Add("sign", sign);
            post.Add("sign_type", SignType);

            post.Post();


https://github.com/nopSolutions/alipay-plugin-for-nopcommerce/blob/bfc2700483dba3c494ce012f714bd1ca725568d5/Nop.Plugin.Payments.AliPay/AliPayPaymentProcessor.cs#L155

https://github.com/nopSolutions/okpay-plugin-for-nopcommerce/blob/13872a8e7546461aae03a78e5ff21078beb5349f/Nop.Plugin.Payments.OkPay/OkPayPaymentProcessor.cs#L187


You saved me. Thanks a lot
4 years ago
tekin7707 wrote:
I have developed a payment plugin(PaymentMethodType.Redirection) 3.90 and it is worked fine.

also; I create a form in PostProcessPayment and post it(POST method necessary). Page goes to the Bank Payment Page and return result.

        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {//3.90
            var myForm = "<form action=\"{0}\" method=\"POST\" />" +
        "<input type=\"hidden\" name=\"secure3dsecuritylevel\" value=\"CUSTOM_PAY\" />" +
              "<input type=\"hidden\" name=\"successurl\" value=\"{1}\" />" +
              "<input type=\"hidden\" name=\"errorurl\" value=\"{2}\" />" +
              "<input type=\"hidden\" name=\"secure3dhash\" value=\"{3}\" />" +
              "</form>"+
                "<script> document.forms[0].submit();</script>";  
            
                _httpContext.Response.Clear();
                _httpContext.Response.Write(myForm);
                _httpContext.Response.End();
        }

but at 4.00 not worked.

        void IPaymentMethod.PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {//4.00

                byte[] data = System.Text.Encoding.UTF8.GetBytes(myForm);

                _httpContextAccessor.HttpContext.Response.Clear();
                _httpContextAccessor.HttpContext.Response.Body.Write(data, 0, data.Length);
                _httpContextAccessor.HttpContext.Response.Body.Close();
  }
  

  As a result, it writes myForm to the page as text.
  
  PaypalStandart is not a good example for me. I need to send form with POST.

  Is there any solution suggestion?


Thank you Tekin, I'm working on iPara integration. It solved my problem in 4.1 version.
2 years ago
Can I add external JavaScript library "payment gateway library" in the form and use data from it ?

Thank you
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.