Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof Grzelak committed Apr 22, 2020
2 parents 2bca586 + a56729a commit da8b7e8
Show file tree
Hide file tree
Showing 11 changed files with 979 additions and 883 deletions.
48 changes: 47 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,47 @@
# SimPay-API-php
# SimPay-API-php

## SMS XML
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.

[Przykłady Implementacji](https://github.com/SimPaypl/SimPay-API-php/tree/master/examples/smsXml)

## Direct Billing
Płatności Direct Billing

[Przykłady Implementacji](https://github.com/SimPaypl/SimPay-API-php/tree/master/examples/directbilling)

## SMS
Płatności SMS obsługiwane przez SimPay

[Przykłady Implementacji](https://github.com/SimPaypl/SimPay-API-php/tree/master/examples/sms)

## Dokumentacja
[Dokumentacji API](https://docs.simpay.pl/#wstep)

## Requirements
* PHP 7.0+

## Installation

The SimPay_PHP_SMS_Client can be installed using [Composer](https://packagist.org/packages/simpaypl/sms_xml_api).

### Composer

#### Automatic install
```composer require simpaypl/simpay```

#### Manual install
Inside of `composer.json` specify the following:

``` json
{
"require": {
"simpaypl/simpay": "dev-master"
}
}
```

# Kontakt
W razie jakicholwiek pytań w implementacji , problemów, próśb o dodanie funkcjonalności zachęcamy do kontaktu poprzez:

<[email protected]>
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"name": "kgrzelak/simpay",
"description": "Simpay",
"type": "library",
"version": "1.1",
"license": "MIT",
"minimum-stability": "stable",
"name": "simpaypl/simpay",
"description": "Official SimPay API",
"type": "library",
"version": "1.0",
"license": "MIT",
"minimum-stability": "stable",
"require": {
"php": ">=7.0",
"guzzlehttp/guzzle": "~6.0"
"guzzlehttp/guzzle": "~6.0"
},
"authors": [
{
"name": "Krzysztof Grzelak",
"email": "k.grzelak@systemy.net"
"email": "k.grzelak@simpay.pl"
}
],
"autoload": {
"psr-4": {
"psr-0": {
"simpay\\": "src"
}
}
}
}
}
6 changes: 1 addition & 5 deletions examples/directbilling/ipn/plain/mysql_query.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ function checkIp($ip)
$response = json_decode(curl_exec($curl));
curl_close($curl);

if (in_array($ip, $response->respond->ips)) {
return true;
} else {
return false;
}
return in_array($ip, $response->respond->ips);
}

if (!checkIp(getRemoteAddr())) {
Expand Down
6 changes: 1 addition & 5 deletions examples/directbilling/ipn/plain/mysqli.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ function checkIp($ip)
$response = json_decode(curl_exec($curl));
curl_close($curl);

if (in_array($ip, $response->respond->ips)) {
return true;
} else {
return false;
}
return in_array($ip, $response->respond->ips);
}

if (!checkIp(getRemoteAddr())) {
Expand Down
6 changes: 1 addition & 5 deletions examples/directbilling/ipn/plain/mysqli_ob.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ function checkIp($ip)
$response = json_decode(curl_exec($curl));
curl_close($curl);

if (in_array($ip, $response->respond->ips)) {
return true;
} else {
return false;
}
return in_array($ip, $response->respond->ips);
}

if (!checkIp(getRemoteAddr())) {
Expand Down
6 changes: 1 addition & 5 deletions examples/directbilling/ipn/plain/pdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ function checkIp($ip)
$response = json_decode(curl_exec($curl));
curl_close($curl);

if (in_array($ip, $response->respond->ips)) {
return true;
} else {
return false;
}
return in_array($ip, $response->respond->ips);
}

if (!checkIp(getRemoteAddr())) {
Expand Down
6 changes: 1 addition & 5 deletions examples/directbilling/ipn/plain/plain.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ function checkIp($ip)
$response = json_decode(curl_exec($curl));
curl_close($curl);

if (in_array($ip, $response->respond->ips)) {
return true;
} else {
return false;
}
return in_array($ip, $response->respond->ips);
}

if (!checkIp(getRemoteAddr())) {
Expand Down
98 changes: 48 additions & 50 deletions src/Components.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,55 @@
use GuzzleHttp\Client;
use GuzzleHttp\RequestOptions;

class Components {

protected $client = '';

public function __construct() {

$this->client = new Client();

}

public function request($data, $url, $type = "params") {

if ($type == "params") {

$response = $this->client->request('POST', $url, [
'form_params' => $data,
'allow_redirects' => false,
'connect_timeout' => 4,
'verify' => false
]);

} else {

$response = $this->client->request('POST', $url, [
'body' => $data,
'allow_redirects' => false,
'connect_timeout' => 4,
'verify' => false
]);

}

if ($response->getStatusCode() != 200) {
throw new RuntimeException('Response Code: ' . $response->getStatusCode());
}

return json_decode($response->getBody());

class Components
{
protected $client = '';

public function __construct()
{

$this->client = new Client();
}

public function getRemoteAddr() {

public function request($data, $url, $type = "params")
{

if ($type == "params") {
$response = $this->client->request('POST', $url, [
'form_params' => $data,
'allow_redirects' => false,
'connect_timeout' => 4,
'verify' => false
]);
} else {
$response = $this->client->request('POST', $url, [
'body' => $data,
'allow_redirects' => false,
'connect_timeout' => 4,
'verify' => false
]);
}

if ($response->getStatusCode() != 200) {
throw new RuntimeException('Response Code: ' . $response->getStatusCode());
}

return json_decode($response->getBody());
}

public function getRemoteAddr()
{
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');
}

public function getIp() {
$this->response = $this->request('', 'https://simpay.pl/api/get_ip', 'body');
return $this->response;
}

public function checkIp($ip) {
return in_array($ip, $this->getIp()->respond->ips);
}


public function getIp()
{
$this->response = $this->request('', 'https://simpay.pl/api/get_ip', 'body');
return $this->response;
}

public function checkIp($ip)
{
return in_array($ip, $this->getIp()->respond->ips);
}
}
Loading

0 comments on commit da8b7e8

Please sign in to comment.