Webhook orders/create api gives wrong client browser ip address.

Milind2
Excursionist
25 0 12

 

 

Hello everyone,

I am working with one of my apps and I have registered "orders/create" webhook when App is installed.

When "orders/create" webhook is called, it gives the wrong browser IP address in response.

https://help.shopify.com/en/api/reference/orders/order

"client_details": {
  "accept_language": "en-US,en;q=0.9",
  "browser_height": 1320,
  "browser_ip": "216.191.105.146",
  "browser_width": 1280,
  "session_hash": "9ad4d1f4e6a8977b9dd98eed1e477643",
  "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36"
}

I have developed this APP using PHP.

I store client IP address in the database when a user clicks on the product and when a user orders any product I store the data from "orders/create" webhook response like product_id, order_id, ip_address.

Now I used this "client_details" response to get an IP address of the user when he orders the product.

But it is totally different then the IP address I store when a user clicks on the product.

Following is the PHP code I used to get user IP address:

function getIp()
    {
        $ip = '';
        if (!empty($_SERVER["HTTP_CLIENT_IP"]))
        {
         //check for ip from share internet
         $ip = $_SERVER["HTTP_CLIENT_IP"];
        }
        elseif (!empty($_SERVER["HTTP_X_FORWARDED_FOR"]))
        {
         // Check for the Proxy User
         $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
        }
        else
        {
         $ip = $_SERVER["REMOTE_ADDR"];
        }
        return $ip;
    }

 

Can anyone please help me out to figure out why is this happening.

Thank you in advance.

 

Thanks & regards

Replies 3 (3)

Alex
Shopify Staff
1561 81 341

I would need an example order (an ID will suffice) which was placed within the past two weeks (the more recently the better) to offer any insight possibly. Is it possible that the checkout was processed from a different IP address from that which they assembled their cart in? I believe mobile networks in particular can be fairly dynamic.

Cheers.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Milind2
Excursionist
25 0 12

Hi Alex Richter,

Thank you for your reply.

I would need an example order (an ID will suffice) which was placed within the past two weeks (the more recently the better) to offer any insight possibly.

=> Below is the most recent order I made:
Order #1016
https://edzdemoappoutsource.myshopify.com/admin/orders/886346219633

Is it possible that the checkout was processed from a different IP address from that which they assembled their cart in?

=> I am testing my app from my machine. So I believe that there should be the same IP address but I am not getting the same IP address.

 

 

joe_camae
Shopify Partner
1 0 0

Any response on this issue? I'm looking for this answer myself. Shame it was not discussed in public.