Skip to content

Commit 7471173

Browse files
committed
Merge pull request #11 from paynl/Validate-IsPaynlServerIp
Validate is paynl server ip
2 parents f0592fd + 40cc935 commit 7471173

File tree

6 files changed

+104
-7
lines changed

6 files changed

+104
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ nbproject/*
22
index.php
33
vendor/*
44
composer.lock
5+
.idea/*

.idea/vcs.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

samples/validate/isPayServerIp.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/*
3+
* Copyright (C) 2015 Andy Pieters <andy@pay.nl>
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
require_once '../../vendor/autoload.php';
20+
21+
$results = array();
22+
23+
$results[] = \Paynl\Validate::isPayServerIp('12.34.56.78'); // not a pay server ip
24+
$results[] = \Paynl\Validate::isPayServerIp('37.46.137.135'); // pay server ip
25+
26+
var_dump($results);

src/Api/Api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function doRequest($endpoint, $version = null)
6060

6161
$result = $curl->post($uri, $data);
6262

63-
$output = self::processResult($result);
63+
$output = static::processResult($result);
6464

6565
return $output;
6666
}

src/Api/Validate/IsPayServerIp.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: andy
5+
* Date: 21-12-2015
6+
* Time: 12:27
7+
*/
8+
9+
namespace Paynl\Api\Validate;
10+
11+
use \Paynl\Api\Api;
12+
use \Paynl\Error;
13+
14+
class isPayServerIp extends Api
15+
{
16+
protected function getData()
17+
{
18+
19+
if (!isset($this->data['ipAddress'])) {
20+
throw new Error\Required('ipAddress is required');
21+
}
22+
23+
return $this->data;
24+
}
25+
26+
public function setIpAddress($ipAddress)
27+
{
28+
$this->data['ipAddress'] = $ipAddress;
29+
}
30+
31+
protected function processResult($result)
32+
{
33+
return (bool)$result->result;
34+
}
35+
36+
public function doRequest($endpoint = null, $version = null)
37+
{
38+
return parent::doRequest('validate/isPayServerIp', 1);
39+
}
40+
}

src/Validate.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/*
3+
* Copyright (C) 2015 Andy Pieters <andy@andypieters.nl>
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
namespace Paynl;
20+
21+
use \Paynl\Api\Validate\isPayServerIp as Api;
22+
23+
/**
24+
* Description of Paymentmethods
25+
*
26+
* @author Andy Pieters <andy@andypieters.nl>
27+
*/
28+
class Validate
29+
{
30+
public static function isPayServerIp($ipAddress)
31+
{
32+
$api = new Api();
33+
$api->setIpAddress($ipAddress);
34+
return $api->doRequest();
35+
}
36+
}

0 commit comments

Comments
 (0)