diff --git a/UnitPay.php b/UnitPay.php index d020b49..c1ef52a 100644 --- a/UnitPay.php +++ b/UnitPay.php @@ -66,6 +66,16 @@ private function getMd5sign($params) return md5(join(null, $params).$this->secretKey); } + /** + * Return IP address + * + * @return string + */ + protected function getIp() + { + return $_SERVER['REMOTE_ADDR']; + } + /** * Get URL for pay through the form * @@ -145,7 +155,7 @@ public function api($method, $params = array()) */ public function checkHandlerRequest() { - $ip = $_SERVER['REMOTE_ADDR']; + $ip = $this->getIp(); if (!isset($_GET['method'])) { throw new InvalidArgumentException('Method is null'); }