IOTPay DocumentationIOTPay Documentation
  • Introduction
  • Signing
  • General Order API
  • Customer Scan QR Code
  • Merchant Scan Barcode
  • Payment in WeChat Web Browser
  • WeChat Mini Program
  • Online Secure Payment
  • App integrate IOTPay
  • Order Query
  • Asynchronous Notify
  • Get Client IP
  • Refund interface
  • Query Refund
  • POS Semi-Integration
  • Wordpress WooCommerce plugin
  • V3

    • Introduction
    • Redirected Integration
    • Redirected Integration With 3DS and AVS
    • Embedded Integration
    • Direct Method
    • Query Card
    • Purchase With Token
    • Purchase with Wallet
    • Void Transaction
    • Refund Transaction
    • Query Transaction
    • UnionPay ExpressPay API
  • V2

    • Credit Card API V2(Deprecated)
  • Introduction
  • Contract Signing
  • Payment
  • Query Order API
  • Callback
  • English
  • 简体中文
  • Introduction
  • Signing
  • General Order API
  • Customer Scan QR Code
  • Merchant Scan Barcode
  • Payment in WeChat Web Browser
  • WeChat Mini Program
  • Online Secure Payment
  • App integrate IOTPay
  • Order Query
  • Asynchronous Notify
  • Get Client IP
  • Refund interface
  • Query Refund
  • POS Semi-Integration
  • Wordpress WooCommerce plugin
  • V3

    • Introduction
    • Redirected Integration
    • Redirected Integration With 3DS and AVS
    • Embedded Integration
    • Direct Method
    • Query Card
    • Purchase With Token
    • Purchase with Wallet
    • Void Transaction
    • Refund Transaction
    • Query Transaction
    • UnionPay ExpressPay API
  • V2

    • Credit Card API V2(Deprecated)
  • Introduction
  • Contract Signing
  • Payment
  • Query Order API
  • Callback
  • English
  • 简体中文
  • General Order

    • Introduction
    • Signing
    • General Order API
    • Customer Scan QR Code
    • Merchant Scan Barcode
    • Payment in WeChat Web Browser
    • WeChat Mini Program
    • Online Secure Payment
    • App integrate IOTPay
    • Order Query
    • Asynchronous Notify
    • Get Client IP
    • Refund interface
    • Query Refund
    • POS Semi-Integration
    • Wordpress WooCommerce plugin
  • CreditCard

    • V3

      • Introduction
      • Redirected Integration
      • Redirected Integration With 3DS and AVS
      • Embedded Integration
      • Direct Method
      • Query Card
      • Purchase With Token
      • Purchase with Wallet
      • Void Transaction
      • Refund Transaction
      • Query Transaction
      • UnionPay ExpressPay API
    • Credit Card API V2(Deprecated)
  • Autodebit

    • Introduction
    • Contract Signing
    • Payment
    • Query Order API
    • Callback

Get Client IP

Merchant need to pass clientIp parameter when calling creating order endpoint, hopefully this document will be helpful.

If No Proxy Exist

If there is no proxy at merchant's frontend, just use REMOTE_ADDR to get client ip.

If Proxy Exist

nginx proxy config

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-Port $remote_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

Apache proxy config

vi /usr/local/apache/conf/httpd.conf
Include conf/extra/httpd-remoteip.conf
vi /usr/local/apache/conf/extra/httpd-remoteip.conf
LoadModule remoteip_module modules/mod_remoteip.so
RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy 127.0.0.1

php sample code

function real_ip()
{
    static $realIp = NULL;

    if ($realIp !== NULL)
    {
        return $realIp;
    }

    if (isset($_SERVER))
    {
        if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
        {
            $arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);

            foreach ($arr AS $ip)
            {
                $ip = trim($ip);

                if ($ip != 'unknown')
                {
                    $realIp = $ip;

                    break;
                }
            }
        }
        elseif (isset($_SERVER['HTTP_CLIENT_IP']))
        {
            $realIp = $_SERVER['HTTP_CLIENT_IP'];
        }
        else
        {
            if (isset($_SERVER['REMOTE_ADDR']))
            {
                $realIp = $_SERVER['REMOTE_ADDR'];
            }
            else
            {
                $realIp = '0.0.0.0';
            }
        }
    }
    else
    {
        if (getenv('HTTP_X_FORWARDED_FOR'))
        {
            $realIp = getenv('HTTP_X_FORWARDED_FOR');
        }
        elseif (getenv('HTTP_CLIENT_IP'))
        {
            $realIp = getenv('HTTP_CLIENT_IP');
        }
        else
        {
            $realIp = getenv('REMOTE_ADDR');
        }
    }

    preg_match("/[\d\.]{7,15}/", $realIp, $onlineIp);
    $realIp = !empty($onlineIp[0]) ? $onlineIp[0] : '0.0.0.0';

    return $realIp;
}
Last Updated: 8/19/25, 5:54 PM
Prev
Asynchronous Notify
Next
Refund interface