Skip to content

Commit

Permalink
Fill project
Browse files Browse the repository at this point in the history
  • Loading branch information
Msik committed May 27, 2021
1 parent 8980b14 commit db1d89b
Show file tree
Hide file tree
Showing 67 changed files with 2,754 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vendor/
composer.lock
.phpunit.result.cache
.idea
21 changes: 21 additions & 0 deletions LICENSE
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.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# cloudpayments-php-client

### License

MIT
30 changes: 30 additions & 0 deletions composer.json
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"
}
}
12 changes: 12 additions & 0 deletions phpunit.xml
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>
46 changes: 46 additions & 0 deletions src/BaseHook.php
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];
}
}
}
}
38 changes: 38 additions & 0 deletions src/BaseRequest.php
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;
}

}
22 changes: 22 additions & 0 deletions src/Enum/BoolField.php
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';

}
12 changes: 12 additions & 0 deletions src/Exceptions/BadTypeException.php
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
{

}
14 changes: 14 additions & 0 deletions src/Exceptions/CloudpaymentsException.php
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
{

}
25 changes: 25 additions & 0 deletions src/Hook/HookCancel.php
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;
}
51 changes: 51 additions & 0 deletions src/Hook/HookCheck.php
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;
}
44 changes: 44 additions & 0 deletions src/Hook/HookConfirm.php
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;
}
47 changes: 47 additions & 0 deletions src/Hook/HookFail.php
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;
}
Loading

0 comments on commit db1d89b

Please sign in to comment.