-
Notifications
You must be signed in to change notification settings - Fork 16
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
Showing
67 changed files
with
2,754 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,4 @@ | ||
vendor/ | ||
composer.lock | ||
.phpunit.result.cache | ||
.idea |
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2021 Flowwow. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 |
---|---|---|
@@ -1 +1,5 @@ | ||
# cloudpayments-php-client | ||
|
||
### License | ||
|
||
MIT |
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,30 @@ | ||
{ | ||
"name": "flowwow/cloudpayments-php-client", | ||
"description": "cloudpayments api client", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Maksim Khramov", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"keywords": [ | ||
"cloudpayments api", | ||
"cloudpayments" | ||
], | ||
"require": { | ||
"php": ">=7.4", | ||
"guzzlehttp/guzzle": "^7.3" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^9.5" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Flowwow\\Cloudpayments\\": "src" | ||
} | ||
}, | ||
"scripts": { | ||
"test": "vendor/bin/phpunit -c phpunit.xml" | ||
} | ||
} |
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,12 @@ | ||
<phpunit bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
stopOnFailure="true"> | ||
<testsuites> | ||
<testsuite name="Unit Tests"> | ||
<directory>./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
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,46 @@ | ||
<?php | ||
|
||
namespace Flowwow\Cloudpayments; | ||
|
||
/** | ||
* Базовый класс моделей фондю | ||
* Class BaseModel | ||
* @package Flowwow\Cloudpayments | ||
* @property string $response_status | ||
*/ | ||
class BaseHook | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
protected array $request; | ||
|
||
/** | ||
* BaseHook constructor. | ||
* @param array $request | ||
*/ | ||
public function __construct(array $request) | ||
{ | ||
$this->request = $request; | ||
$this->fill(); | ||
} | ||
|
||
public function getRequest(): array | ||
{ | ||
return $this->request; | ||
} | ||
|
||
/** | ||
* Заливка полей | ||
*/ | ||
private function fill() | ||
{ | ||
$modelFields = get_object_vars($this); | ||
foreach ($modelFields as $key => $field) { | ||
$requestKey = ucfirst($key); | ||
if (isset($this->request[$requestKey])) { | ||
$this->$key = $this->request[$requestKey]; | ||
} | ||
} | ||
} | ||
} |
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,38 @@ | ||
<?php | ||
|
||
namespace Flowwow\Cloudpayments; | ||
|
||
use Flowwow\Cloudpayments\Enum\BoolField; | ||
|
||
/** | ||
* Базовый класс моделей фондю | ||
* Class BaseRequest | ||
* @package Flowwow\Cloudpayments | ||
*/ | ||
class BaseRequest | ||
{ | ||
/** | ||
* Данные в нужном для запроса формате | ||
* @return array | ||
*/ | ||
public function asArray(): array | ||
{ | ||
$data = []; | ||
$fields = get_object_vars($this); | ||
foreach ($fields as $field => $value) { | ||
//Подменим booleans | ||
if ($value === true) { | ||
$value = BoolField::TRUE; | ||
} elseif ($value === false) { | ||
$value = BoolField::FALSE; | ||
} | ||
//Пустые поля слать не будем | ||
if ($value !== null) { | ||
$data[ucfirst($field)] = $value; | ||
} | ||
} | ||
|
||
return $data; | ||
} | ||
|
||
} |
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,22 @@ | ||
<?php | ||
|
||
namespace Flowwow\Cloudpayments\Enum; | ||
|
||
/** | ||
* Bool-значения для клауда | ||
* https://developers.cloudkassir.ru/#agentsign | ||
*/ | ||
class BoolField | ||
{ | ||
/** | ||
* True | ||
* @var string | ||
*/ | ||
public const TRUE = 'true'; | ||
/** | ||
* False | ||
* @var string | ||
*/ | ||
public const FALSE = 'false'; | ||
|
||
} |
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,12 @@ | ||
<?php | ||
|
||
namespace Flowwow\Cloudpayments\Exceptions; | ||
|
||
/** | ||
* Class BadTypeException | ||
* @package Flowwow\Cloudpayments\Exceptions | ||
*/ | ||
class BadTypeException extends CloudpaymentsException | ||
{ | ||
|
||
} |
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,14 @@ | ||
<?php | ||
|
||
namespace Flowwow\Cloudpayments\Exceptions; | ||
|
||
use Exception; | ||
|
||
/** | ||
* Class CloudpaymentsException | ||
* @package Flowwow\Cloudpayments\Exceptions | ||
*/ | ||
class CloudpaymentsException extends Exception | ||
{ | ||
|
||
} |
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,25 @@ | ||
<?php | ||
|
||
namespace Flowwow\Cloudpayments\Hook; | ||
|
||
use Flowwow\Cloudpayments\BaseHook; | ||
|
||
/** | ||
* Class HookCancel | ||
* @link https://developers.cloudpayments.ru/#cancel | ||
*/ | ||
class HookCancel extends BaseHook | ||
{ | ||
// Required | ||
|
||
public ?int $transactionId = null; | ||
public ?float $amount = null; | ||
public ?string $dateTime = null; | ||
|
||
// Not required | ||
|
||
public ?string $invoiceId = null; | ||
public ?string $accountId = null; | ||
public ?string $email = null; | ||
public ?string $data = null; | ||
} |
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,51 @@ | ||
<?php | ||
|
||
namespace Flowwow\Cloudpayments\Hook; | ||
|
||
|
||
use Flowwow\Cloudpayments\BaseHook; | ||
|
||
/** | ||
* Class HookCheck | ||
* @link https://developers.cloudpayments.ru/#check | ||
*/ | ||
class HookCheck extends BaseHook | ||
{ | ||
// Required | ||
|
||
public ?int $transactionId = null; | ||
public ?float $amount = null; | ||
public ?string $currency = null; | ||
public ?string $dateTime = null; | ||
public ?string $cardFirstSix = null; | ||
public ?string $cardLastFour = null; | ||
public ?string $cardType = null; | ||
public ?string $cardExpDate = null; | ||
public ?int $testMode = null; | ||
public ?string $status = null; | ||
public ?string $operationType = null; | ||
|
||
// Not required | ||
|
||
public ?string $invoiceId = null; | ||
public ?string $accountId = null; | ||
public ?string $subscriptionId = null; | ||
public ?string $tokenRecipient = null; | ||
public ?string $name = null; | ||
public ?string $email = null; | ||
public ?string $ipAddress = null; | ||
public ?string $ipCountry = null; | ||
public ?string $ipCity = null; | ||
public ?string $ipRegion = null; | ||
public ?string $ipDistrict = null; | ||
public ?string $issuer = null; | ||
public ?string $issuerBankCountry = null; | ||
public ?string $description = null; | ||
public ?string $data = null; | ||
public ?string $paymentAmount = null; | ||
public ?string $paymentCurrency = null; | ||
public ?string $ipLatitude = null; | ||
public ?string $ipLongitude = null; | ||
public ?string $cardProduct = null; | ||
public ?string $paymentMethod = null; | ||
} |
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,44 @@ | ||
<?php | ||
|
||
namespace Flowwow\Cloudpayments\Hook; | ||
|
||
use Flowwow\Cloudpayments\BaseHook; | ||
|
||
/** | ||
* Class HookConfirm | ||
* @link https://developers.cloudpayments.ru/#confirm | ||
*/ | ||
class HookConfirm extends BaseHook | ||
{ | ||
// Required | ||
|
||
public ?int $transactionId = null; | ||
public ?float $amount = null; | ||
public ?string $currency = null; | ||
public ?string $dateTime = null; | ||
public ?string $cardFirstSix = null; | ||
public ?string $cardLastFour = null; | ||
public ?string $cardType = null; | ||
public ?string $cardExpDate = null; | ||
public ?int $testMode = null; | ||
public ?string $status = null; | ||
|
||
// Not required | ||
|
||
public ?string $invoiceId = null; | ||
public ?string $accountId = null; | ||
public ?string $subscriptionId = null; | ||
public ?string $name = null; | ||
public ?string $email = null; | ||
public ?string $ipAddress = null; | ||
public ?string $ipCountry = null; | ||
public ?string $ipCity = null; | ||
public ?string $ipRegion = null; | ||
public ?string $ipDistrict = null; | ||
public ?string $issuer = null; | ||
public ?string $issuerBankCountry = null; | ||
public ?string $description = null; | ||
public ?string $data = null; | ||
public ?string $token = null; | ||
public ?string $paymentMethod = null; | ||
} |
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,47 @@ | ||
<?php | ||
|
||
namespace Flowwow\Cloudpayments\Hook; | ||
|
||
use Flowwow\Cloudpayments\BaseHook; | ||
|
||
/** | ||
* Class HookFail | ||
* @link https://developers.cloudpayments.ru/#fail | ||
*/ | ||
class HookFail extends BaseHook | ||
{ | ||
// Required | ||
|
||
public ?int $transactionId = null; | ||
public ?float $amount = null; | ||
public ?string $currency = null; | ||
public ?string $dateTime = null; | ||
public ?string $cardFirstSix = null; | ||
public ?string $cardLastFour = null; | ||
public ?string $cardType = null; | ||
public ?string $cardExpDate = null; | ||
public ?int $testMode = null; | ||
public ?string $reason = null; | ||
public ?int $reasonCode = null; | ||
public ?string $operationType = null; | ||
|
||
// Not required | ||
|
||
public ?string $invoiceId = null; | ||
public ?string $accountId = null; | ||
public ?string $subscriptionId = null; | ||
public ?string $name = null; | ||
public ?string $email = null; | ||
public ?string $ipAddress = null; | ||
public ?string $ipCountry = null; | ||
public ?string $ipCity = null; | ||
public ?string $ipRegion = null; | ||
public ?string $ipDistrict = null; | ||
public ?string $issuer = null; | ||
public ?string $issuerBankCountry = null; | ||
public ?string $description = null; | ||
public ?string $data = null; | ||
public ?string $token = null; | ||
public ?string $paymentMethod = null; | ||
public ?int $fallBackScenarioDeclinedTransactionId = null; | ||
} |
Oops, something went wrong.