From a7633d24dd3cf01d2bb87d8df79f2cf9f861f6ca Mon Sep 17 00:00:00 2001 From: Michael Tintiuc Date: Fri, 6 May 2016 15:13:33 +0100 Subject: [PATCH] Added overrideable getIp method --- UnitPay.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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'); }