Skip to content

Commit

Permalink
Изменение версии протокола на 5. Добавление новых полей. Исправление …
Browse files Browse the repository at this point in the history
…тестов.
  • Loading branch information
Alexander Koterin committed Apr 7, 2022
1 parent 8065eee commit 1bfefce
Show file tree
Hide file tree
Showing 55 changed files with 949 additions and 241 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Platron Atol SDK
## Установка

Проект предполагает установку с использованием composer
<pre><code>composer require payprocessing/atol-sdk-api-v4</pre></code>
<pre><code>composer require payprocessing/atol-sdk-api-v5</pre></code>

## Тесты
Для работы тестов необходим PHPUnit, для его установки необходимо выполнить команду
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "payprocessing/atol-sdk-api-v4",
"description": "Atol.online SDK Version 4",
"name": "payprocessing/atol-sdk-api-v5",
"description": "Atol.online SDK Version 5",
"require": {
"php": ">=5.5",
"psr/log": "^1.0.2",
Expand All @@ -13,8 +13,8 @@
},
"autoload": {
"psr-4": {
"Platron\\AtolV4\\": "src",
"Platron\\AtolV4\\tests\\": "tests"
"Platron\\AtolV5\\": "src",
"Platron\\AtolV5\\tests\\": "tests"
}
}
}
2 changes: 1 addition & 1 deletion src/SdkException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Platron\AtolV4;
namespace Platron\AtolV5;

class SdkException extends \Exception
{
Expand Down
7 changes: 4 additions & 3 deletions src/clients/PostClient.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

namespace Platron\AtolV4\clients;
namespace Platron\AtolV5\clients;

use Platron\AtolV4\SdkException;
use Platron\AtolV4\services\BaseServiceRequest;
use Platron\AtolV5\SdkException;
use Platron\AtolV5\services\BaseServiceRequest;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use stdClass;

class PostClient implements iClient
{
Expand Down
5 changes: 3 additions & 2 deletions src/clients/iClient.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace Platron\AtolV4\clients;
namespace Platron\AtolV5\clients;

use Platron\AtolV4\services\BaseServiceRequest;
use Platron\AtolV5\services\BaseServiceRequest;
use stdClass;

interface iClient
{
Expand Down
30 changes: 30 additions & 0 deletions src/data_objects/AdditionalUserProps.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Platron\AtolV5\data_objects;

class AdditionalUserProps extends BaseDataObject
{

/** @var string */
protected $name;

/** @var string */
protected $value;

/**
* @param string $name
*/
public function addName($name)
{
$this->name = (string)$name;
}

/**
* @param string $value
*/
public function addValue($value)
{
$this->value = (string)$value;
}

}
9 changes: 7 additions & 2 deletions src/data_objects/AgentInfo.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Platron\AtolV4\data_objects;
namespace Platron\AtolV5\data_objects;

use Platron\AtolV4\handbooks\AgentTypes;
use Platron\AtolV5\handbooks\AgentTypes;

class AgentInfo extends BaseDataObject
{
Expand All @@ -17,6 +17,11 @@ class AgentInfo extends BaseDataObject
/** @var MoneyTransferOperator */
protected $money_transfer_operator;

/**
* AgentInfo constructor
* @param AgentTypes $type
* @param Supplier $supplier
*/
public function __construct(AgentTypes $type, Supplier $supplier)
{
$this->type = $type->getValue();
Expand Down
2 changes: 1 addition & 1 deletion src/data_objects/BaseDataObject.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Platron\AtolV4\data_objects;
namespace Platron\AtolV5\data_objects;

abstract class BaseDataObject
{
Expand Down
62 changes: 59 additions & 3 deletions src/data_objects/Client.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
<?php

namespace Platron\AtolV4\data_objects;
namespace Platron\AtolV5\data_objects;

class Client extends BaseDataObject
{
/** @var int $phone */
protected $phone;
/** @var string $email */
protected $email;
/** @var string $name */
protected $name;
/** @var string $inn */
protected $inn;
/** @var string $birthdate */
protected $birthdate;
/** @var string $citizenship */
protected $citizenship;
/** @var string $document_code */
protected $document_code;
/** @var string $document_data */
protected $document_data;
/** @var string $address */
protected $address;

/**
* @param string $email
Expand All @@ -22,7 +36,7 @@ public function addEmail($email)
*/
public function addPhone($phone)
{
$this->phone = '+'.(string)$phone;
$this->phone = '+' . (string)$phone;
}

/**
Expand All @@ -34,10 +48,52 @@ public function addName($name)
}

/**
* @param int $inn
* @param string $inn
*/
public function addInn($inn)
{
$this->inn = (string)$inn;
}

/**
* @param string $birthdate
*/
public function addBirthdate($birthdate)
{
$this->birthdate = (string)$birthdate;
}

/**
* @param string $citizenship
*/
public function addCitizenship($citizenship)
{
$this->citizenship = (string)$citizenship;
}

/**
* @param string $documentCode
*/
public function addDocumentCode($documentCode)
{
$this->document_code = (string)$documentCode;
}

/**
* @param string $documentData
*/
public function addDocumentData($documentData)
{
$this->document_data = (string)$documentData;
}

/**
* @param string $address
*/
public function addAddress($address)
{
$this->address = (string)$address;
}


}
11 changes: 9 additions & 2 deletions src/data_objects/Company.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Platron\AtolV4\data_objects;
namespace Platron\AtolV5\data_objects;

use Platron\AtolV4\handbooks\SnoTypes;
use Platron\AtolV5\handbooks\SnoTypes;

class Company extends BaseDataObject
{
Expand All @@ -15,6 +15,13 @@ class Company extends BaseDataObject
/** @var string */
protected $payment_address;

/**
* Company constructor
* @param string $email
* @param SnoTypes $sno
* @param string $inn
* @param string $paymentAddress
*/
public function __construct($email, SnoTypes $sno, $inn, $paymentAddress)
{
$this->email = (string)$email;
Expand Down
33 changes: 25 additions & 8 deletions src/data_objects/Correction.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Platron\AtolV4\data_objects;
namespace Platron\AtolV5\data_objects;

use Platron\AtolV4\handbooks\CorrectionOperationTypes;
use Platron\AtolV5\handbooks\CorrectionOperationTypes;

class Correction extends BaseDataObject
{
Expand All @@ -12,10 +12,12 @@ class Correction extends BaseDataObject
protected $correction_info;
/** @var Payment[] */
private $payments;
/** @var Vat */
/** @var Vat[] */
private $vats;
/** @var CorrectionOperationTypes */
private $operationType;
/** @var Item[] */
protected $items;

/**
* Correction constructor.
Expand All @@ -24,14 +26,26 @@ class Correction extends BaseDataObject
* @param CorrectionInfo $correctionInfo
* @param Payment $payment
* @param Vat $vat
* @param Item[] $items
*/
public function __construct(CorrectionOperationTypes $operationType, Company $company, CorrectionInfo $correctionInfo, Payment $payment, Vat $vat)
public function __construct(CorrectionOperationTypes $operationType, Company $company, CorrectionInfo $correctionInfo, Payment $payment, Vat $vat, $items)
{
$this->operationType = $operationType->getValue();
$this->company = $company;
$this->correction_info = $correctionInfo;
$this->addPayment($payment);
$this->addVat($vat);
foreach ($items as $item) {
$this->addItem($item);
}
}

/**
* @param Item $item
*/
private function addItem(Item $item)
{
$this->items[] = $item->getParameters();
}

/**
Expand All @@ -53,7 +67,8 @@ public function addVat(Vat $vat)
/**
* @return string
*/
public function getOperationType(){
public function getOperationType()
{
return $this->operationType;
}

Expand All @@ -63,13 +78,15 @@ public function getOperationType(){
public function getParameters()
{
$parameters = parent::getParameters();
foreach($this->payments as $payment){
$total = 0;
foreach ($this->payments as $payment) {
$parameters['payments'][] = $payment->getParameters();
$total += $payment->getParameters()['sum'];
}
foreach($this->vats as $vat){
foreach ($this->vats as $vat) {
$parameters['vats'][] = $vat->getParameters();
}

$parameters['total'] = $total;
return $parameters;
}
}
15 changes: 9 additions & 6 deletions src/data_objects/CorrectionInfo.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Platron\AtolV4\data_objects;
namespace Platron\AtolV5\data_objects;

use Platron\AtolV4\handbooks\CorrectionTypes;
use Platron\AtolV5\handbooks\CorrectionTypes;

class CorrectionInfo extends BaseDataObject
{
Expand All @@ -12,14 +12,17 @@ class CorrectionInfo extends BaseDataObject
protected $base_date;
/** @var string */
protected $base_number;
/** @var string */
protected $base_name;

public function __construct(CorrectionTypes $type, \DateTime $baseDate, $baseNumber, $baseName)
/**
* CorrectionInfo constructor
* @param CorrectionTypes $type
* @param \DateTime $baseDate
* @param string $baseNumber
*/
public function __construct(CorrectionTypes $type, \DateTime $baseDate, $baseNumber)
{
$this->type = $type->getValue();
$this->base_date = $baseDate->format('d.m.Y');
$this->base_number = (string)$baseNumber;
$this->base_name = (string)$baseName;
}
}
Loading

0 comments on commit 1bfefce

Please sign in to comment.