-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
avorontsov
committed
Feb 11, 2020
0 parents
commit 3273eeb
Showing
6 changed files
with
254 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "sch-group/ips-payment", | ||
"keywords": ["IPS-payment", "payment", "gateway", "ips", "php"], | ||
"homepage": "https://github.com/sch-group/ips-payment", | ||
"description": "Package to connect IPS-PAYMENT gateway", | ||
"type": "library", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Anton Vorontsov", | ||
"email": "[email protected]", | ||
"role": "Creator" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.2", | ||
"guzzlehttp/guzzle": "^6.2" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^6.3" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"SchGroup\\IpsPayment\\" : "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"SchGroup\\IpsPayment\\Tests\\": "tests/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace SchGroup\IpsPayment; | ||
|
||
class Customer | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
public $customerName; | ||
/** | ||
* @var string | ||
*/ | ||
public $customerEmail; | ||
/** | ||
* @var string | ||
*/ | ||
public $customerPhone; | ||
|
||
/** | ||
* Customer constructor. | ||
* @param string $customerName | ||
* @param string|null $customerEmail | ||
* @param string|null $customerPhone | ||
*/ | ||
public function __construct( | ||
string $customerName, | ||
?string $customerEmail = null, | ||
?string $customerPhone = null | ||
) { | ||
$this->customerName = $customerName; | ||
$this->customerEmail = $customerEmail; | ||
$this->customerPhone = $customerPhone; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SchGroup\IpsPayment; | ||
|
||
use GuzzleHttp\Exception\GuzzleException; | ||
use Psr\Log\{NullLogger, LoggerInterface}; | ||
use GuzzleHttp\ClientInterface; | ||
|
||
class IpsPayment | ||
{ | ||
/** | ||
* @var NullLogger | ||
*/ | ||
private $logger; | ||
|
||
const API_URL = "https://wws.ips-payment.com"; | ||
/** | ||
* @var string | ||
*/ | ||
private $apiKey; | ||
/** | ||
* @var ClientInterface | ||
*/ | ||
private $client; | ||
|
||
/** | ||
* IpsPayment constructor. | ||
* @param string $apiKey | ||
* @param ClientInterface $client | ||
*/ | ||
public function __construct(string $apiKey, ClientInterface $client, LoggerInterface $logger) | ||
{ | ||
$this->apiKey = $apiKey; | ||
$this->client = $client; | ||
$this->logger = $logger; | ||
} | ||
|
||
|
||
/** | ||
* @param Transaction $transaction | ||
* @return string | ||
*/ | ||
public function buildLink(Transaction $transaction): string | ||
{ | ||
return self::API_URL .'?'. http_build_query($transaction->toArray()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace SchGroup\IpsPayment; | ||
|
||
class Order | ||
{ | ||
/** | ||
* @var float | ||
*/ | ||
public $amount; | ||
/** | ||
* @var string | ||
*/ | ||
public $Subscribe_Period; | ||
/** | ||
* @var string | ||
*/ | ||
public $RefOrder; | ||
/** | ||
* @var string | ||
*/ | ||
public $Subscribe; | ||
|
||
/** | ||
* Order constructor. | ||
* @param string $RefOrder | ||
* @param float $amount | ||
* @param string|null $Subscribe | ||
* @param string|null $Subscribe_Period | ||
*/ | ||
public function __construct( | ||
string $RefOrder, | ||
float $amount, | ||
?string $Subscribe = null, | ||
?string $Subscribe_Period = null | ||
) { | ||
$this->RefOrder = $RefOrder; | ||
$this->Subscribe = $Subscribe; | ||
$this->Subscribe_Period = $Subscribe_Period; | ||
$this->amount = $amount; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace SchGroup\IpsPayment; | ||
|
||
class ShopSettings | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
public $urlIPN; | ||
/** | ||
* @var string | ||
*/ | ||
public $Integrated; | ||
/** | ||
* @var string | ||
*/ | ||
public $urlOK; | ||
/** | ||
* @var string | ||
*/ | ||
public $lang; | ||
|
||
/** | ||
* ShopSettings constructor. | ||
* @param string $urlIPN | ||
* @param string $urlOK | ||
* @param string|null $Integrated | ||
* @param string $lang | ||
*/ | ||
public function __construct( | ||
string $urlIPN, | ||
string $urlOK, | ||
?string $Integrated = null, | ||
string $lang = 'en' | ||
) { | ||
$this->urlIPN = $urlIPN; | ||
$this->urlOK = $urlOK; | ||
$this->Integrated = $Integrated; | ||
|
||
$this->lang = $lang; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace SchGroup\IpsPayment; | ||
|
||
class Transaction | ||
{ | ||
/** | ||
* @var Customer | ||
*/ | ||
private $customer; | ||
/** | ||
* @var Order | ||
*/ | ||
private $order; | ||
/** | ||
* @var ShopSettings | ||
*/ | ||
private $shopSettings; | ||
|
||
/** | ||
* Transaction constructor. | ||
* @param Order $order | ||
* @param Customer $customer | ||
* @param ShopSettings $shopSettings | ||
*/ | ||
public function __construct( | ||
Order $order, | ||
Customer $customer, | ||
ShopSettings $shopSettings | ||
) { | ||
$this->customer = $customer; | ||
$this->order = $order; | ||
$this->shopSettings = $shopSettings; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function toArray(): array | ||
{ | ||
return [ | ||
"MerchantKey"=> '8545e3aa27ba62e0API5e3aa27ba62e1', | ||
"RefOrder" => $this->order->RefOrder, | ||
"amount" => $this->order->amount, | ||
"Customer_Name" => $this->customer->customerName, | ||
"Customer_Email" => $this->customer->customerEmail, | ||
"Customer_Phone" => $this->customer->customerPhone, | ||
"Integrated" => $this->shopSettings->Integrated, | ||
"lang" => $this->shopSettings->lang | ||
]; | ||
} | ||
} |