Skip to content

Commit da8b7e8

Browse files
author
Krzysztof Grzelak
committed
2 parents 2bca586 + a56729a commit da8b7e8

File tree

11 files changed

+979
-883
lines changed

11 files changed

+979
-883
lines changed

README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,47 @@
1-
# SimPay-API-php
1+
# SimPay-API-php
2+
3+
## SMS XML
4+
Partner przygotowuje link URL zgodnie z opisaną specyfikacją SimPay. W momencie złożenia przez użytkownika zamówienia (wysłanie wiadomości SMS), nasz system odpytuje URL podany przez partnera oraz pobiera kod bezpośrednio.
5+
6+
[Przykłady Implementacji](https://github.com/SimPaypl/SimPay-API-php/tree/master/examples/smsXml)
7+
8+
## Direct Billing
9+
Płatności Direct Billing
10+
11+
[Przykłady Implementacji](https://github.com/SimPaypl/SimPay-API-php/tree/master/examples/directbilling)
12+
13+
## SMS
14+
Płatności SMS obsługiwane przez SimPay
15+
16+
[Przykłady Implementacji](https://github.com/SimPaypl/SimPay-API-php/tree/master/examples/sms)
17+
18+
## Dokumentacja
19+
[Dokumentacji API](https://docs.simpay.pl/#wstep)
20+
21+
## Requirements
22+
* PHP 7.0+
23+
24+
## Installation
25+
26+
The SimPay_PHP_SMS_Client can be installed using [Composer](https://packagist.org/packages/simpaypl/sms_xml_api).
27+
28+
### Composer
29+
30+
#### Automatic install
31+
```composer require simpaypl/simpay```
32+
33+
#### Manual install
34+
Inside of `composer.json` specify the following:
35+
36+
``` json
37+
{
38+
"require": {
39+
"simpaypl/simpay": "dev-master"
40+
}
41+
}
42+
```
43+
44+
# Kontakt
45+
W razie jakicholwiek pytań w implementacji , problemów, próśb o dodanie funkcjonalności zachęcamy do kontaktu poprzez:
46+
47+
<kontakt@simpay.pl>

composer.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
{
2-
"name": "kgrzelak/simpay",
3-
"description": "Simpay",
4-
"type": "library",
5-
"version": "1.1",
6-
"license": "MIT",
7-
"minimum-stability": "stable",
2+
"name": "simpaypl/simpay",
3+
"description": "Official SimPay API",
4+
"type": "library",
5+
"version": "1.0",
6+
"license": "MIT",
7+
"minimum-stability": "stable",
88
"require": {
99
"php": ">=7.0",
10-
"guzzlehttp/guzzle": "~6.0"
10+
"guzzlehttp/guzzle": "~6.0"
1111
},
1212
"authors": [
1313
{
1414
"name": "Krzysztof Grzelak",
15-
"email": "k.grzelak@systemy.net"
15+
"email": "k.grzelak@simpay.pl"
1616
}
1717
],
1818
"autoload": {
19-
"psr-4": {
19+
"psr-0": {
2020
"simpay\\": "src"
2121
}
22-
}
23-
}
22+
}
23+
}

examples/directbilling/ipn/plain/mysql_query.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ function checkIp($ip)
3636
$response = json_decode(curl_exec($curl));
3737
curl_close($curl);
3838

39-
if (in_array($ip, $response->respond->ips)) {
40-
return true;
41-
} else {
42-
return false;
43-
}
39+
return in_array($ip, $response->respond->ips);
4440
}
4541

4642
if (!checkIp(getRemoteAddr())) {

examples/directbilling/ipn/plain/mysqli.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ function checkIp($ip)
3636
$response = json_decode(curl_exec($curl));
3737
curl_close($curl);
3838

39-
if (in_array($ip, $response->respond->ips)) {
40-
return true;
41-
} else {
42-
return false;
43-
}
39+
return in_array($ip, $response->respond->ips);
4440
}
4541

4642
if (!checkIp(getRemoteAddr())) {

examples/directbilling/ipn/plain/mysqli_ob.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ function checkIp($ip)
3636
$response = json_decode(curl_exec($curl));
3737
curl_close($curl);
3838

39-
if (in_array($ip, $response->respond->ips)) {
40-
return true;
41-
} else {
42-
return false;
43-
}
39+
return in_array($ip, $response->respond->ips);
4440
}
4541

4642
if (!checkIp(getRemoteAddr())) {

examples/directbilling/ipn/plain/pdo.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ function checkIp($ip)
3636
$response = json_decode(curl_exec($curl));
3737
curl_close($curl);
3838

39-
if (in_array($ip, $response->respond->ips)) {
40-
return true;
41-
} else {
42-
return false;
43-
}
39+
return in_array($ip, $response->respond->ips);
4440
}
4541

4642
if (!checkIp(getRemoteAddr())) {

examples/directbilling/ipn/plain/plain.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ function checkIp($ip)
3030
$response = json_decode(curl_exec($curl));
3131
curl_close($curl);
3232

33-
if (in_array($ip, $response->respond->ips)) {
34-
return true;
35-
} else {
36-
return false;
37-
}
33+
return in_array($ip, $response->respond->ips);
3834
}
3935

4036
if (!checkIp(getRemoteAddr())) {

src/Components.php

Lines changed: 48 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,57 +4,55 @@
44
use GuzzleHttp\Client;
55
use GuzzleHttp\RequestOptions;
66

7-
class Components {
8-
9-
protected $client = '';
10-
11-
public function __construct() {
12-
13-
$this->client = new Client();
14-
15-
}
16-
17-
public function request($data, $url, $type = "params") {
18-
19-
if ($type == "params") {
20-
21-
$response = $this->client->request('POST', $url, [
22-
'form_params' => $data,
23-
'allow_redirects' => false,
24-
'connect_timeout' => 4,
25-
'verify' => false
26-
]);
27-
28-
} else {
29-
30-
$response = $this->client->request('POST', $url, [
31-
'body' => $data,
32-
'allow_redirects' => false,
33-
'connect_timeout' => 4,
34-
'verify' => false
35-
]);
36-
37-
}
38-
39-
if ($response->getStatusCode() != 200) {
40-
throw new RuntimeException('Response Code: ' . $response->getStatusCode());
41-
}
42-
43-
return json_decode($response->getBody());
44-
7+
class Components
8+
{
9+
protected $client = '';
10+
11+
public function __construct()
12+
{
13+
14+
$this->client = new Client();
4515
}
46-
47-
public function getRemoteAddr() {
16+
17+
public function request($data, $url, $type = "params")
18+
{
19+
20+
if ($type == "params") {
21+
$response = $this->client->request('POST', $url, [
22+
'form_params' => $data,
23+
'allow_redirects' => false,
24+
'connect_timeout' => 4,
25+
'verify' => false
26+
]);
27+
} else {
28+
$response = $this->client->request('POST', $url, [
29+
'body' => $data,
30+
'allow_redirects' => false,
31+
'connect_timeout' => 4,
32+
'verify' => false
33+
]);
34+
}
35+
36+
if ($response->getStatusCode() != 200) {
37+
throw new RuntimeException('Response Code: ' . $response->getStatusCode());
38+
}
39+
40+
return json_decode($response->getBody());
41+
}
42+
43+
public function getRemoteAddr()
44+
{
4845
return getenv('HTTP_CLIENT_IP') ?: getenv('HTTP_X_FORWARDED_FOR'[0]) ?: getenv('HTTP_X_FORWARDED') ?: getenv('HTTP_FORWARDED_FOR') ?: getenv('HTTP_FORWARDED') ?: getenv('REMOTE_ADDR');
4946
}
50-
51-
public function getIp() {
52-
$this->response = $this->request('', 'https://simpay.pl/api/get_ip', 'body');
53-
return $this->response;
54-
}
55-
56-
public function checkIp($ip) {
57-
return in_array($ip, $this->getIp()->respond->ips);
58-
}
59-
47+
48+
public function getIp()
49+
{
50+
$this->response = $this->request('', 'https://simpay.pl/api/get_ip', 'body');
51+
return $this->response;
52+
}
53+
54+
public function checkIp($ip)
55+
{
56+
return in_array($ip, $this->getIp()->respond->ips);
57+
}
6058
}

0 commit comments

Comments
 (0)