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

Highlighted
Tourist
25 0 3

 

 

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

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1555 81 282

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.

0 Likes
Highlighted
Tourist
25 0 3

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.

 

 

0 Likes
Highlighted
Shopify Partner
1 0 0

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

0 Likes