IP Address of Payment gateway on return

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 years ago
We are trying to Integrate with a new Payment gateway provider.
In the requirement they need us to verify the IP address from which the payment response is returned.

So in Return method we used following to retrieve IP address:
string responseIP = _webHelper.GetCurrentIpAddress();


But this is returning 127.0.0.1 which is local.

So I am not sure what am I missing in this.

Thanks
8 years ago
Hey ,

Would be glad to try and help you out a bit since I have just finished my payment plugin.

Could you elaborate a bit on the flow of this verification ? Do I understand correctly that you make  payment request without customer redirection ? Do you need to get the IP in your own controller which is being called in response ?


Looking forward to hear from you!


Regards
Rafal
8 years ago
Hi Rafal,

It is a simple payment plugin in which the user is redirected to payment gateway with required parameters and the payment gateway returns to my controller with specific response.
So now I need to know the IP address of this response in my controller.

Hope this makes sense.

Thanks
8 years ago
Try this

var IP = Request.ServerVariables["REMOTE_ADDR"];
8 years ago
Please see http://www.geekpedia.com/KB32_How-do-I-get-the-visitors-IP-address.html this page. So you should try the following:
1. Open \src\Presentation\Nop.Web\Web.config
2. Add "ForwardedHTTPheader" app setting with "REMOTE_ADDR" value.
Or you can simply replace "X-FORWARDED-FOR" with "REMOTE_ADDR" in the "GetCurrentIpAddress" method of \Libraries\Nop.Core\WebHelper.cs file
8 years ago
rafPe wrote:
Try this

var IP = Request.ServerVariables["REMOTE_ADDR"];


As quick alternative you may also use

Request.UserHostAddress


Hope this helps!

Regards
Rafal
8 years ago
a.m. wrote:
Please see http://www.geekpedia.com/KB32_How-do-I-get-the-visitors-IP-address.html this page. So you should try the following:
1. Open \src\Presentation\Nop.Web\Web.config
2. Add "ForwardedHTTPheader" app setting with "REMOTE_ADDR" value.
Or you can simply replace "X-FORWARDED-FOR" with "REMOTE_ADDR" in the "GetCurrentIpAddress" method of \Libraries\Nop.Core\WebHelper.cs file


rafPe wrote:
Try this
var IP = Request.ServerVariables["REMOTE_ADDR"];
Request.UserHostAddress



No luck yet, all above solutions gives me the same local/User IP address.

When I was debugging it was my local system IP (127.0.0.1). But when I tested it on remote test server, I realised that the IP address was of the User logged in because in this case it was my public IP.
So it getting the user IP instead of response server IP.

Regards,
Renish
8 years ago
So basically in PostProcess you do redirect user and then for your payment gateway you set return URL to custom URL of your plugin ?

If so then when external payment gateway hots back your controller you should be able to get that IP address
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.