简体   繁体   中英

How to know Remote IP Address in JSP

I have web application through which payment transactions will happen.

The flow of the Application

User will open my application and click the pay button. Now i will redirect the request to Payment Gateway provider (ICICI, EBS, PayPal etc). Now, the payment gateway provider pages will appear in my website. Now the payment process will go through, and Payment gateway provider will post their response to my application(to JSP page). After capture the response i will process the request.

My requirement

How can i know the ICICI, PayPal or EBS server ip address when they call my JSP. If i call request.getRemoteAddr() it will give the client IP address. I want to know the IP address of payment gateway server.

Provider is posting the data as GET instead of POST. Here i didnt mention my acutal payment gateway provider.

In general, you can only know this without help from the payment provider if

  • there are no proxies between you and the provider, and
  • the provider sends a HTTP POST (or similar) directly to you

In that case ServletRequest.getRemoteAddr() should give you the provider's address.

If you get the client browser's address instead, then probably the provider does not send the POST directly to you, but instead instructs the client browser to send it (most likely using Javascript). In that case, there is no way for you to find out the address the provider was sending from.


At any rate, why do you need to know the payment provider's IP address? You redirect to the provider yourself, so you already have the address, don't you?

Maybe you could explain in more detail what the flow of data is between you, the client browser and the payment provider, and why you want to know the provider's IP address? Maybe then we can help better.

For PayPal you can use IPN
https://www.paypal.com/ipn

Instant Payment Notification (IPN) is PayPal's message service that sends a notification when a transaction is affected. Once IPN is integrated, sellers can automate their back office so they don't have to wait for payments to come in to trigger order fulfillment.

With IPN you get a POST/GET call to your IPN url from the PayPal servers. This means that the customer does not have to return to your website after paying and you do not have to validate the customer data - instead, the PayPal servers do a 3-way handshake: they send you the payment data, you send back a check, and they validate the check that the data you have is correct. In this case the server ip is the originating ip from the http call.

Other services will probably have something similar to this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM