1
0
mirror of synced 2024-11-21 20:46:03 +03:00
This commit is contained in:
Alexey Chelnakov 2018-06-14 17:14:51 +03:00
parent ddcefab15a
commit 9233e287e4
26 changed files with 6881 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
./idea
/vendor

28
composer.json Normal file
View File

@ -0,0 +1,28 @@
{
"name": "intaro/atol-online-client",
"type": "library",
"license": "proprietary",
"description": "Api client for Atol Online",
"authors": [
{
"name": "retailCRM",
"email": "support@retailcrm.ru"
}
],
"require": {
"php": ">=7.1",
"ext-curl": "*",
"guzzlehttp/guzzle": "~6.0",
"jms/serializer-bundle": "~0.12",
"symfony/validator": "2.8.*"
},
"require-dev": {
"phpunit/phpunit": "7.1."
},
"support": {
"email": "support@retailcrm.ru"
},
"autoload": {
"psr-0": { "AtolOnlineClient\\": "src/" }
}
}

3888
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,290 @@
<?php
namespace AtolOnlineClient;
use AtolOnlineClient\Configuration\Connection;
use Doctrine\Common\Cache\CacheProvider;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\BadResponseException;
use GuzzleHttp\Psr7\Response;
use Psr\Log\LoggerInterface;
class AtolOnlineApi
{
const API_VERSION_V4 = 'v4';
const API_VERSION_V3 = 'v3';
const TOKEN_CACHE_KEY = 'crm_fiscal_atol_online_token';
const TOKEN_CACHE_TIME = 60 * 60 * 24;
// private $baseApiUrl = 'https://online.atol.ru/possystem';
private $baseApiUrl = 'https://testonline.atol.ru/possystem';
private $login;
private $pass;
private $groupCode;
private $debug;
/**
* @var LoggerInterface
*/
private $logger;
/**
* @var CacheProvider
*/
private $cache;
/**
* @var Client
*/
private $client;
/**
* @var int
*/
private $attempts;
/**
* @var int
*/
private $attemptsCheckStatus;
private $version;
/**
* @param Client $client
* @param Connection $connectionConfig
* @param bool $debug
*/
public function __construct(Client $client, Connection $connectionConfig, $debug = false)
{
$this->client = $client;
$this->login = $connectionConfig->login;
$this->pass = $connectionConfig->pass;
$this->groupCode = $connectionConfig->group;
$this->version = $connectionConfig->version;
$this->debug = $debug;
$this->attempts = 0;
}
/**
* Приход
*
* @param $paymentReceiptRequest
* @return string
*/
public function sell($paymentReceiptRequest)
{
if ($response = $this->sendOperationRequest('sell', $paymentReceiptRequest)) {
return $response->getBody()->__toString();
};
}
/**
* Возврат прихода
*
* @param $paymentReceiptRequest
* @return string
*/
public function sellRefund($paymentReceiptRequest)
{
if ($response = $this->sendOperationRequest('sell_refund', $paymentReceiptRequest)) {
return $response->getBody()->__toString();
};
}
/**
* Запрос для проверки статуса
*
* @param $uuid
* @return mixed
*/
public function checkStatus($uuid)
{
$token = $this->getToken();
$url = $this->buildUrl('report/'.$uuid, $token);
$request = $this->client->get($url);
$response = false;
try {
$this->attemptsCheckStatus++;
$response = $request->send();
} catch (BadResponseException $e) {
$this->cache->delete($this->getTokenCacheKey());
$body = json_decode($e->getResponse()->getBody());
if ($this->isTokenExpired($body) && $this->attemptsCheckStatus <= 1) {
return $this->checkStatus($uuid);
}
$this->logDebug($url, $uuid, $e->getResponse());
}
if ($response) {
return $response->getBody()->__toString();
}
return false;
}
/**
* @param $logger
*/
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
}
/**
* @param CacheProvider $cache
*/
public function setCache(CacheProvider $cache)
{
$this->cache = $cache;
}
/**
* @param mixed $version
*/
public function setVersion($version): void
{
$this->version = $version;
}
/**
* @return mixed
*/
protected function getToken()
{
$data = [
'login' => $this->login,
'pass' => $this->pass,
];
if ($token = $this->cache->fetch($this->getTokenCacheKey())) {
return $token;
}
$dataJson = json_encode((object)$data, JSON_UNESCAPED_UNICODE);
$url = $this->baseApiUrl
.'/'.$this->version
.'/getToken';
$request = $this->client->createRequest('POST', $url, null, $dataJson);
$response = false;
try {
$response = $this->client->send($request);
} catch (BadResponseException $e) {
if ($this->logger) {
$this->logger->error($e->getResponse()->getBody());
}
}
if ($response) {
$response = json_decode($response->getBody());
if ($this->version === self::API_VERSION_V4) {
if (!isset ($response->error)) {
$this->cache->save($this->getTokenCacheKey(), $response->token, self::TOKEN_CACHE_TIME);
return $response->token;
} else {
$this->logger->error($response->error->code . ' '. $response->error->text);
}
} else {
if (isset($response->code) && $response->code == 1 || $response->code == 0) {
$this->cache->save($this->getTokenCacheKey(), $response->token, self::TOKEN_CACHE_TIME);
return $response->token;
}
}
}
return false;
}
/**
* @return string
*/
protected function getTokenCacheKey()
{
return self::TOKEN_CACHE_KEY.'_'.md5($this->login.$this->pass).'_'.$this->version;
}
/**
* @param string $operation
* @param null $token
* @return string
*/
protected function buildUrl($operation, $token = null)
{
$url = $this->baseApiUrl
.'/'.$this->version
.'/'.$this->groupCode
.'/'.$operation;
if ($token) {
if ($this->version === self::API_VERSION_V4) {
$url .= '?token='.$token;
} elseif ($this->version === self::API_VERSION_V3) {
$url .= '?tokenid='.$token;
}
}
return $url;
}
/**
* @param string $operation
* @param string $data
* @return Response|bool
*/
protected function sendOperationRequest($operation, $data)
{
$token = $this->getToken();
$url = $this->buildUrl($operation, $token);
$request = $this->client->createRequest('POST', $url, null, $data);
$response = false;
try {
$this->attempts++;
$response = $this->client->send($request);
} catch (BadResponseException $e) {
$this->cache->delete($this->getTokenCacheKey());
$body = json_decode($e->getResponse()->getBody());
if ($this->isTokenExpired($body) && $this->attempts <= 1) {
return $this->sendOperationRequest($operation, $data);
}
$this->logDebug($url, $data, $e->getResponse());
}
if ($response) {
$this->logDebug($url, $data, $response);
}
return $response;
}
protected function logDebug($url, $data, Response $response)
{
if ($this->debug && $this->logger) {
$v = "* URL: ".$url;
$v .= "\n * POSTFILEDS: ".$data;
$v .= "\n * RESPONSE HEADERS: ".$response->getRawHeaders();
$v .= "\n * RESPONSE BODY: ".$response->getBody();
$v .= "\n * ATTEMPTS: ".$this->attempts;
$this->logger->debug($v);
}
}
protected function isTokenExpiredCode($code)
{
return in_array($code, [4, 5, 6, 12, 13, 14]);
}
private function isTokenExpired($body)
{
return isset($body->error) && $this->isTokenExpiredCode($body->error->code);
}
}

View File

@ -0,0 +1,290 @@
<?php
namespace AtolOnlineClient;
use Guzzle\Http\Client;
use Guzzle\Http\Exception\BadResponseException;
use Guzzle\Http\Message\Response;
use Intaro\CRMFiscalBundle\FiscalService\AtolOnline\Configuration\Connection;
use Intaro\TaggableCacheBundle\Doctrine\Cache\CacheProvider;
use Psr\Log\LoggerInterface;
class AtolOnlineApiV4
{
const API_VERSION_V4 = 'v4';
const API_VERSION_V3 = 'v3';
const TOKEN_CACHE_KEY = 'crm_fiscal_atol_online_token';
const TOKEN_CACHE_TIME = 60 * 60 * 24;
// private $baseApiUrl = 'https://online.atol.ru/possystem';
private $baseApiUrl = 'https://testonline.atol.ru/possystem';
private $login;
private $pass;
private $groupCode;
private $debug;
/**
* @var LoggerInterface
*/
private $logger;
/**
* @var CacheProvider
*/
private $cache;
/**
* @var Client
*/
private $client;
/**
* @var int
*/
private $attempts;
/**
* @var int
*/
private $attemptsCheckStatus;
private $version;
/**
* AtolOnlineApi constructor.
* @param Client $client
* @param Connection $connectionConfig
* @param bool $debug
*/
public function __construct(Client $client, Connection $connectionConfig)
{
$this->client = $client;
$this->login = $connectionConfig->login;
$this->pass = $connectionConfig->pass;
$this->groupCode = $connectionConfig->group;
$this->version = $connectionConfig->version;
$this->debug =
$this->attempts = 0;
}
/**
* Приход
*
* @param $paymentReceiptRequest
* @return string
*/
public function sell($paymentReceiptRequest)
{
if ($response = $this->sendOperationRequest('sell', $paymentReceiptRequest)) {
return $response->getBody()->__toString();
};
}
/**
* Возврат прихода
*
* @param $paymentReceiptRequest
* @return string
*/
public function sellRefund($paymentReceiptRequest)
{
if ($response = $this->sendOperationRequest('sell_refund', $paymentReceiptRequest)) {
return $response->getBody()->__toString();
};
}
/**
* Запрос для проверки статуса
*
* @param $uuid
* @return mixed
*/
public function checkStatus($uuid)
{
$token = $this->getToken();
$url = $this->buildUrl('report/'.$uuid, $token);
$request = $this->client->get($url);
$response = false;
try {
$this->attemptsCheckStatus++;
$response = $request->send();
} catch (BadResponseException $e) {
$this->cache->delete($this->getTokenCacheKey());
$body = json_decode($e->getResponse()->getBody());
if ($this->isTokenExpired($body) && $this->attemptsCheckStatus <= 1) {
return $this->checkStatus($uuid);
}
$this->logDebug($url, $uuid, $e->getResponse());
}
if ($response) {
return $response->getBody()->__toString();
}
return false;
}
/**
* @param $logger
*/
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
}
/**
* @param CacheProvider $cache
*/
public function setCache(CacheProvider $cache)
{
$this->cache = $cache;
}
/**
* @return mixed
*/
public function getVersion()
{
return $this->version;
}
/**
* @param mixed $version
*/
public function setVersion($version): void
{
$this->version = $version;
}
/**
* @return mixed
*/
protected function getToken()
{
$data = [
'login' => $this->login,
'pass' => $this->pass,
];
if ($token = $this->cache->fetch($this->getTokenCacheKey())) {
return $token;
}
$dataJson = json_encode((object)$data, JSON_UNESCAPED_UNICODE);
$url = $this->baseApiUrl
.'/'.$this->getVersion()
.'/getToken';
$request = $this->client->createRequest('POST', $url, null, $dataJson);
$response = false;
try {
$response = $this->client->send($request);
} catch (BadResponseException $e) {
if ($this->logger) {
$this->logger->error($e->getResponse()->getBody());
}
}
if ($response) {
$response = json_decode($response->getBody());
if (isset($response->code) && $response->code == 1 || $response->code == 0) {
$this->cache->save($this->getTokenCacheKey(), $response->token, self::TOKEN_CACHE_TIME);
return $response->token;
}
}
return false;
}
/**
* @param $data
* @return string
*/
protected function getTokenCacheKey()
{
return self::TOKEN_CACHE_KEY.'_'.md5($this->login.$this->pass);
}
/**
* @param string $operation
* @param null $token
* @return string
*/
protected function buildUrl($operation, $token = null)
{
$url = $this->baseApiUrl
.'/'.$this->version
.'/'.$this->groupCode
.'/'.$operation;
if ($token) {
if ($this->version === self::API_VERSION_V4) {
$url .= '?token='.$token;
} elseif ($this->version === self::API_VERSION_V3) {
$url .= '?tokenid='.$token;
}
}
return $url;
}
/**
* @param string $operation
* @param string $data
* @return Response|bool
*/
protected function sendOperationRequest($operation, $data)
{
$token = $this->getToken();
$url = $this->buildUrl($operation, $token);
$request = $this->client->createRequest('POST', $url, null, $data);
$response = false;
try {
$this->attempts++;
$response = $this->client->send($request);
} catch (BadResponseException $e) {
$this->cache->delete($this->getTokenCacheKey());
$body = json_decode($e->getResponse()->getBody());
if ($this->isTokenExpired($body) && $this->attempts <= 1) {
return $this->sendOperationRequest($operation, $data);
}
$this->logDebug($url, $data, $e->getResponse());
}
if ($response) {
$this->logDebug($url, $data, $response);
}
return $response;
}
protected function logDebug($url, $data, Response $response)
{
if ($this->debug && $this->logger) {
$v = "* URL: ".$url;
$v .= "\n * POSTFILEDS: ".$data;
$v .= "\n * RESPONSE HEADERS: ".$response->getRawHeaders();
$v .= "\n * RESPONSE BODY: ".$response->getBody();
$v .= "\n * ATTEMPTS: ".$this->attempts;
$this->logger->debug($v);
}
}
protected function isTokenExpiredCode($code)
{
return in_array($code, [4, 5, 6, 12, 13, 14]);
}
private function isTokenExpired($body)
{
return isset($body->error) && $this->isTokenExpiredCode($body->error->code);
}
}

View File

@ -0,0 +1,146 @@
<?php
namespace AtolOnlineClient;
use AtolOnlineClient\Configuration\Connection;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Mapping\ClassMetadata;
class Configuration implements ConfigurationInterface
{
/** @var Connection[] */
public $connections;
/** @var boolean */
public $enabled;
/** @var bool */
public $debug;
/** @var bool */
public $sendEmail;
/** @var bool */
public $sendSms;
/**
* @param ClassMetadata $metadata
*/
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('connections', new Assert\NotBlank());
$metadata->addPropertyConstraint('connections', new Assert\Valid());
}
public function loadConnections($connections)
{
if (!$connections) {
return;
}
foreach ($connections as $connectionItem) {
$connection = new Connection();
$connection->login = $connectionItem['login'];
$connection->pass = $connectionItem['pass'];
$connection->group = $connectionItem['group'];
$connection->legalEntity = $connectionItem['legalEntity'];
$connection->sno = $connectionItem['sno'];
$connection->enabled = (bool) $connectionItem['enabled'];
$connection->paymentTypes = $connectionItem['paymentTypes'];
$connection->paymentStatuses = $connectionItem['paymentStatuses'];
$connection->ofd = $connectionItem['ofd'];
$connection->version = $connectionItem['version'];
$this->connections[] = $connection;
}
}
/**
* @param bool $enabled
*/
public function setEnabled($enabled)
{
$this->enabled = (bool) $enabled;
}
/**
* @param bool $sendEmail
*
* @return $this
*/
public function setSendEmail($sendEmail)
{
$this->sendEmail = (bool) $sendEmail;
return $this;
}
/**
* @param bool $sendSms
*
* @return $this
*/
public function setSendSms($sendSms)
{
$this->sendSms = (bool) $sendSms;
return $this;
}
/**
* @param mixed $debug
*/
public function setDebug($debug)
{
$this->debug = $debug;
}
/**
* @return bool
*/
public function isEnabled()
{
return (bool) $this->enabled;
}
/**
* @return bool
*/
public function isSendEmail()
{
return (bool) $this->sendEmail;
}
/**
* @return bool
*/
public function isSendSms()
{
return (bool) $this->sendSms;
}
/**
* @return mixed
*/
public function isDebug()
{
return $this->debug;
}
/**
* @param LegalEntity $legalentity
* @return bool|Connection
*/
public function getLegalEntityConnection(LegalEntity $legalentity)
{
if (!$this->connections || !$this->enabled) {
return false;
}
foreach ($this->connections as $connection) {
if ($connection->enabled && $connection->legalEntity == $legalentity->getId()) {
return $connection;
}
}
return false;
}
}

View File

@ -0,0 +1,160 @@
<?php
namespace AtolOnlineClient\Configuration;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Mapping\ClassMetadata;
class Connection
{
const SNO_GENERAL = 'osn';
const SNO_USN_INCOME = 'usn_income';
const SNO_USN_INCOME_OUTCOME = 'usn_income_outcome';
const SNO_ENVD = 'envd';
const SNO_ESN = 'esn';
const SNO_PATENT = 'patent';
const PLATFORMA_OFD = 'platforma_ofd';
const PERVIY_OFD = 'perviy_ofd';
const TAXCOM_OFD = 'taxcom_ofd';
const V3 = 'v3';
const V4 = 'v4';
const snoTypes = [
self::SNO_GENERAL,
self::SNO_USN_INCOME,
self::SNO_USN_INCOME_OUTCOME,
self::SNO_ENVD,
self::SNO_ESN,
self::SNO_PATENT,
];
const ofdList = [
self::PLATFORMA_OFD,
self::PERVIY_OFD,
self::TAXCOM_OFD,
];
const versions = [
self::V3,
self::V4,
];
protected $url;
/** @var bool */
protected $debug;
/** @var string */
public $login;
/** @var string */
public $pass;
/** @var string */
public $group;
/** @var int */
public $legalEntity;
/** @var array */
public $paymentTypes;
/** @var array */
public $paymentStatuses;
/** @var boolean */
public $enabled;
/** @var string */
public $sno;
/** @var string */
public $ofd;
/** @var string */
public $version;
/**
* @param mixed $url
*/
public function setUrl($url): void
{
$this->url = $url;
}
public function __construct()
{
$this->setUrl('');
}
/**
* @return bool
*/
public function isDebug(): bool
{
return $this->debug;
}
/**
* @param bool $debug
*/
public function setDebug(bool $debug): void
{
$this->debug = $debug;
}
/**
* @param ClassMetadata $metadata
*/
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('login', new Assert\NotBlank());
$metadata->addPropertyConstraint('pass', new Assert\NotBlank());
$metadata->addPropertyConstraint('group', new Assert\NotBlank());
$metadata->addPropertyConstraint('legalEntity', new Assert\NotBlank());
$metadata->addPropertyConstraints('sno', [
new Assert\Choice([
'choices' => self::snoTypes,
])
]);
$metadata->addPropertyConstraints('ofd', [
new Assert\Choice([
'choices' => self::ofdList,
])
]);
$metadata->addPropertyConstraints('version', [
new Assert\Choice([
'choices' => self::versions,
])
]);
$metadata->addPropertyConstraint('paymentTypes', new Assert\NotBlank());
$metadata->addPropertyConstraint('paymentStatuses', new Assert\NotBlank());
}
/**
* @return string
*/
public function getOfdAddress()
{
switch ($this->ofd) {
case self::PLATFORMA_OFD:
return 'platformaofd.ru';
case self::PERVIY_OFD:
return 'www.1-ofd.ru';
case self::TAXCOM_OFD:
return 'taxcom.ru/ofd/';
}
return null;
}
/**
* @return string
*/
public function getVersion()
{
return $this->version;
}
}

View File

@ -0,0 +1,10 @@
<?php
namespace AtolOnlineClient;
interface ConfigurationInterface
{
public function isEnabled();
public function isDebug();
}

View File

@ -0,0 +1,8 @@
<?php
namespace AtolOnlineClient\Exception;
class AtolException extends \Exception
{
}

View File

@ -0,0 +1,129 @@
<?php
namespace AtolOnlineClient\Request\V3;
use JMS\Serializer\Annotation as Serializer;
class PaymentReceiptRequest
{
/**
* @var string
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("timestamp")
* @Serializer\Type("string")
*/
private $timestamp;
/**
* @var string
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("external_id")
* @Serializer\Type("string")
*/
private $externalId;
/**
* @var ServiceRequest
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("service")
* @Serializer\Type("AtolOnlineClient\Request\ServiceRequest")
*/
private $service;
/**
* @var ReceiptRequest
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("receipt")
* @Serializer\Type("AtolOnlineClient\Request\ReceiptRequest")
*/
private $receipt;
public function __construct()
{
$this->timestamp = (new \DateTime())->format('d.m.Y H:i:s');
}
/**
* @return string
*/
public function getTimestamp()
{
return $this->timestamp;
}
/**
* @param string $timestamp
*
* @return $this
*/
public function setTimestamp($timestamp)
{
$this->timestamp = $timestamp;
return $this;
}
/**
* @return string
*/
public function getExternalId()
{
return $this->externalId;
}
/**
* @param string $externalId
*
* @return $this
*/
public function setExternalId($externalId)
{
$this->externalId = $externalId;
return $this;
}
/**
* @return \AtolOnlineClient\Request\V3\ServiceRequest
*/
public function getService()
{
return $this->service;
}
/**
* @param \AtolOnlineClient\Request\V3\ServiceRequest $service
*
* @return $this
*/
public function setService($service)
{
$this->service = $service;
return $this;
}
/**
* @return ReceiptRequest
*/
public function getReceipt()
{
return $this->receipt;
}
/**
* @param ReceiptRequest $receipt
*
* @return $this
*/
public function setReceipt($receipt)
{
$this->receipt = $receipt;
return $this;
}
}

View File

@ -0,0 +1,98 @@
<?php
namespace AtolOnlineClient\Request\V3;
use JMS\Serializer\Annotation as Serializer;
class ReceiptAttributesRequest
{
/**
* @var string
*
* "enum": [
* "osn",
* "usn_income",
* "usn_income_outcome",
* "envd",
* "esn",
* "patent"
* ]
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("sno")
* @Serializer\Type("string")
*/
private $sno;
/**
* @var string
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("email")
* @Serializer\Type("string")
*/
private $email;
/**
* @var string
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("phone")
* @Serializer\Type("string")
*/
private $phone;
/**
* ReceiptAttributesRequest constructor.
* @param string $email
* @param string $phone
*/
public function __construct($email, $phone)
{
$this->email = $email;
if ($email == null) {
$this->email = '';
}
$this->phone = $phone;
if ($phone == null) {
$this->phone = '';
}
}
/**
* @return string
*/
public function getSno()
{
return $this->sno;
}
/**
* @param string $sno
*
* @return $this
*/
public function setSno($sno)
{
$this->sno = $sno;
return $this;
}
/**
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* @return string
*/
public function getPhone()
{
return $this->phone;
}
}

View File

@ -0,0 +1,163 @@
<?php
namespace AtolOnlineClient\Request\V3;
use JMS\Serializer\Annotation as Serializer;
class ReceiptItemRequest
{
/**
* @var string
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("name")
* @Serializer\Type("string")
*/
private $name;
/**
* @var float
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("price")
* @Serializer\Type("float")
*/
private $price;
/**
* @var integer
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("quantity")
* @Serializer\Type("integer")
*/
private $quantity;
/**
* @var float
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("sum")
* @Serializer\Type("float")
*/
private $sum;
/**
* @var string
*
* "enum": [
* "none",
* "vat0",
* "vat10",
* "vat18",
* "vat110",
* "vat118"
* ]
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("tax")
* @Serializer\Type("string")
*/
private $tax;
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $name
*
* @return $this
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* @return float
*/
public function getPrice()
{
return $this->price;
}
/**
* @param float $price
*
* @return $this
*/
public function setPrice($price)
{
$this->price = $price;
return $this;
}
/**
* @return integer
*/
public function getQuantity()
{
return $this->quantity;
}
/**
* @param int $quantity
*
* @return $this
*/
public function setQuantity($quantity)
{
$this->quantity = $quantity;
return $this;
}
/**
* @return float
*/
public function getSum()
{
return $this->sum;
}
/**
* @param float $sum
*
* @return $this
*/
public function setSum($sum)
{
$this->sum = $sum;
return $this;
}
/**
* @return string
*/
public function getTax()
{
return $this->tax;
}
/**
* @param string $tax
*
* @return $this
*/
public function setTax($tax)
{
$this->tax = $tax;
return $this;
}
}

View File

@ -0,0 +1,59 @@
<?php
namespace AtolOnlineClient\Request\V3;
use JMS\Serializer\Annotation as Serializer;
class ReceiptPaymentRequest
{
const TYPE_ELECTRON = 1;
const TYPE_PREPAY = 2;
const TYPE_CREDIT = 3;
const TYPE_OTHER = 4;
/**
* @var int
* "enum": 0..9
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("type")
* @Serializer\Type("integer")
*/
private $type;
/**
* @var float
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("sum")
* @Serializer\Type("float")
*/
private $sum;
/**
* @param int $type
* @param float $sum
*/
public function __construct($type, $sum)
{
$this->type = $type;
$this->sum = $sum;
}
/**
* @return int
*/
public function getType()
{
return $this->type;
}
/**
* @return float
*/
public function getSum()
{
return $this->sum;
}
}

View File

@ -0,0 +1,127 @@
<?php
namespace AtolOnlineClient\Request\V3;
use JMS\Serializer\Annotation as Serializer;
class ReceiptRequest
{
/**
* @var ReceiptAttributesRequest
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("attributes")
* @Serializer\Type("AtolOnlineClient\Request\ReceiptAttributesRequest")
*/
private $attributes;
/**
* @var ReceiptItemRequest[]
* "minItems": 1, "maxItems": 100,
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("items")
* @Serializer\Type("array<AtolOnlineClient\Request\ReceiptItemRequest>")
*/
private $items;
/**
* @var float
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("total")
* @Serializer\Type("float")
*/
private $total;
/**
* @var \AtolOnlineClient\Request\V3\ReceiptPaymentRequest[]
* "minItems": 1, "maxItems": 10,
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("payments")
* @Serializer\Type("array<AtolOnlineClient\Request\ReceiptPaymentRequest>")
*/
private $payments;
/**
* @return ReceiptAttributesRequest
*/
public function getAttributes()
{
return $this->attributes;
}
/**
* @param ReceiptAttributesRequest $attributes
*
* @return $this
*/
public function setAttributes($attributes)
{
$this->attributes = $attributes;
return $this;
}
/**
* @return ReceiptItemRequest[]
*/
public function getItems()
{
return $this->items;
}
/**
* @param ReceiptItemRequest[] $items
*
* @return $this
*/
public function setItems($items)
{
$this->items = $items;
return $this;
}
/**
* @return float
*/
public function getTotal()
{
return $this->total;
}
/**
* @param float $total
*
* @return $this
*/
public function setTotal($total)
{
$this->total = $total;
return $this;
}
/**
* @return \AtolOnlineClient\Request\V3\ReceiptPaymentRequest[]
*/
public function getPayments()
{
return $this->payments;
}
/**
* @param \AtolOnlineClient\Request\V3\ReceiptPaymentRequest[] $payments
*
* @return $this
*/
public function setPayments($payments)
{
$this->payments = $payments;
return $this;
}
}

View File

@ -0,0 +1,106 @@
<?php
namespace AtolOnlineClient\Request\V3;
use JMS\Serializer\Annotation as Serializer;
class ServiceRequest
{
/**
* @var string
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("inn")
* @Serializer\Type("string")
*/
private $inn;
/**
* @var string
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("callback_url")
* @Serializer\Type("string")
*/
private $callbackUrl;
/**
* @var string
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("payment_address")
* @Serializer\Type("string")
*/
private $paymentAddress;
/**
* Service constructor.
* @param string $inn
* @param string $paymentAddress
*/
public function __construct($inn, $paymentAddress)
{
$this->inn = $inn;
$this->paymentAddress = $paymentAddress;
}
/**
* @return string
*/
public function getCallbackUrl()
{
return $this->callbackUrl;
}
/**
* @param string $callbackUrl
*
* @return $this
*/
public function setCallbackUrl($callbackUrl)
{
$this->callbackUrl = $callbackUrl;
return $this;
}
/**
* @return string
*/
public function getInn()
{
return $this->inn;
}
/**
* @param string $inn
*
* @return $this
*/
public function setInn($inn)
{
$this->inn = $inn;
return $this;
}
/**
* @return string
*/
public function getPaymentAddress()
{
return $this->paymentAddress;
}
/**
* @param string $paymentAddress
*
* @return $this
*/
public function setPaymentAddress($paymentAddress)
{
$this->paymentAddress = $paymentAddress;
return $this;
}
}

View File

@ -0,0 +1,53 @@
<?php
namespace AtolOnlineClient\Request\V4;
use JMS\Serializer\Annotation as Serializer;
/**
* В запросе обязательно должно быть заполнено хотя бы одно из полей: email или phone.
* Если заполнены оба поля, ОФД отправит электронный чек только на email.
*/
class ClientReceiptRequest
{
/**
* @var string
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("email")
* @Serializer\Type("string")
*/
private $email;
/**
* @var string
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("phone")
* @Serializer\Type("string")
*/
private $phone;
public function __construct($email, $phone)
{
$this->email = $email;
$this->phone = $phone;
}
/**
* @return string
*/
public function getEmail(): string
{
return $this->email;
}
/**
* @return string
*/
public function getPhone(): string
{
return $this->phone;
}
}

View File

@ -0,0 +1,108 @@
<?php
namespace AtolOnlineClient\Request\V4;
use JMS\Serializer\Annotation as Serializer;
class CompanyReceiptRequest
{
/**
* @var string
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("email")
* @Serializer\Type("string")
*/
private $email;
/**
* @var string
* Поле необязательно, если у организации один тип налогообложения
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("phone")
* @Serializer\Type("string")
*/
private $sno;
/**
* @var string
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("inn")
* @Serializer\Type("string")
*/
private $inn;
/**
* @var string
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("payment_address")
* @Serializer\Type("string")
*/
private $paymentAddress;
/**
* @return string
*/
public function getEmail(): string
{
return $this->email;
}
/**
* @param string $email
*/
public function setEmail(string $email): void
{
$this->email = $email;
}
/**
* @return string
*/
public function getSno(): string
{
return $this->sno;
}
/**
* @param string $sno
*/
public function setSno(string $sno): void
{
$this->sno = $sno;
}
/**
* @return string
*/
public function getInn(): string
{
return $this->inn;
}
/**
* @param string $inn
*/
public function setInn(string $inn): void
{
$this->inn = $inn;
}
/**
* @return string
*/
public function getPaymentAddress(): string
{
return $this->paymentAddress;
}
/**
* @param string $paymentAddress
*/
public function setPaymentAddress(string $paymentAddress): void
{
$this->paymentAddress = $paymentAddress;
}
}

View File

@ -0,0 +1,108 @@
<?php
namespace AtolOnlineClient\Request\V4;
use JMS\Serializer\Annotation as Serializer;
class PaymentReceiptRequest
{
/**
* @var string
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("external_id")
* @Serializer\Type("string")
*/
private $externalId;
/**
* @var ReceiptRequest
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("receipt")
* @Serializer\Type("AtolOnlineClient\Request\V4\ReceiptRequest")
*/
private $receipt;
/**
* @var string
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("timestamp")
* @Serializer\Type("string")
*/
private $timestamp;
/**
* @var ServiceRequest
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("service")
* @Serializer\Type("AtolOnlineClient\Request\V4\ServiceRequest")
*/
private $service;
public function __construct()
{
$this->timestamp = (new \DateTime())->format('d.m.Y H:i:s');
}
/**
* @return string
*/
public function getExternalId(): string
{
return $this->externalId;
}
/**
* @param string $externalId
*/
public function setExternalId(string $externalId): void
{
$this->externalId = $externalId;
}
/**
* @return ReceiptRequest
*/
public function getReceipt(): ReceiptRequest
{
return $this->receipt;
}
/**
* @param ReceiptRequest $receipt
*/
public function setReceipt(ReceiptRequest $receipt): void
{
$this->receipt = $receipt;
}
/**
* @return string
*/
public function getTimestamp(): string
{
return $this->timestamp;
}
/**
* @return ServiceRequest
*/
public function getService(): ServiceRequest
{
return $this->service;
}
/**
* @param ServiceRequest $service
*/
public function setService(ServiceRequest $service): void
{
$this->service = $service;
}
}

View File

@ -0,0 +1,261 @@
<?php
namespace AtolOnlineClient\Request\V4;
use JMS\Serializer\Annotation as Serializer;
class ReceiptItemRequest
{
const PAYMENT_METHOD_FULL_PREPAYMENT = 'full_prepayment';
const PAYMENT_METHOD_PREPAYMENT = 'prepayment';
const PAYMENT_METHOD_ADVANCE = 'advance';
const PAYMENT_METHOD_FULL_PAYMENT = 'full_payment';
const PAYMENT_METHOD_partial_payment = 'partial_payment';
const PAYMENT_METHOD_CREDIT = 'credit';
const PAYMENT_METHOD_CREDIT_PAYMENT = 'credit_payment';
const PAYMENT_OBJECT_COMMODITY = 'commodity';
const PAYMENT_OBJECT_EXCISE = 'excise';
const PAYMENT_OBJECT_JOB = 'job';
const PAYMENT_OBJECT_SERVICE = 'service';
const PAYMENT_OBJECT_GAMBLING_BET = 'gambling_bet';
const PAYMENT_OBJECT_GAMBLING_PRIZE = 'gambling_prize';
const PAYMENT_OBJECT_LOTTERY = 'lottery';
const PAYMENT_OBJECT_LOTTERY_PRIZE = 'lottery_prize';
const PAYMENT_OBJECT_INTELLECTUAL_ACTIVITY = 'intellectual_activity';
const PAYMENT_OBJECT_PAYMENT = 'payment';
const PAYMENT_OBJECT_AGENT_COMMISSION = 'agent_commission';
const PAYMENT_OBJECT_COMPOSITE = 'composite';
const PAYMENT_OBJECT_ANOTHER = 'another';
/**
* @var string
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("name")
* @Serializer\Type("string")
*/
private $name;
/**
* @var float
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("price")
* @Serializer\Type("float")
*/
private $price;
/**
* @var integer
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("quantity")
* @Serializer\Type("integer")
*/
private $quantity;
/**
* @var float
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("sum")
* @Serializer\Type("float")
*/
private $sum;
/**
* @var string
*
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("measurement_unit")
* @Serializer\Type("string")
*/
private $measurementUnit;
/**
* required
* Признак способа расчёта. Возможные значения:
* «full_prepayment» предоплата 100%. Полная предварительная оплата до момента передачи предмета расчета.
* «prepayment» предоплата. Частичная предварительная оплата до момента передачи предмета расчета.
* «advance» аванс.
* «full_payment» полный расчет. Полная оплата, в том числе с учетом аванса (предварительной оплаты) в момент передачи предмета расчета.
* «partial_payment» частичный расчет и кредит. Частичная оплата предмета расчета в момент его передачи с последующей оплатой в кредит.
* «credit» передача в кредит. Передача предмета расчета без его оплаты в момент его передачи с последующей оплатой в кредит.
* «credit_payment» оплата кредита. Оплата предмета расчета после его передачи с оплатой в кредит (оплата кредита).
* @var string
*
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("payment_method")
* @Serializer\Type("string")
*/
private $paymentMethod;
/**
* Признак предмета расчёта:
* «commodity» товар. О реализуемом товаре, за исключением подакцизного товара (наименование и иные сведения, описывающие товар).
* «excise» подакцизный товар. О реализуемом подакцизном товаре (наименование и иные сведения, описывающие товар).
* «job» работа. О выполняемой работе (наименование и иные сведения, описывающие работу).
* «service» услуга. Об оказываемой услуге (наименование и иные сведения, описывающие услугу).
* «gambling_bet» ставка азартной игры. О приеме ставок при осуществлении деятельности по проведению азартных игр.
* «gambling_prize» выигрыш азартной игры. О выплате денежных средств в виде выигрыша при осуществлении деятельности по проведению азартных игр.
* «lottery» лотерейный билет. О приеме денежных средств при реализации лотерейных билетов, электронных лотерейных билетов, приеме лотерейных ставок при осуществлении деятельности по проведению лотерей.
* «lottery_prize» выигрыш лотереи. О выплате денежных средств в виде выигрыша при осуществлении деятельности по проведению лотерей.
* «intellectual_activity» предоставление результатов интеллектуальной деятельности. О предоставлении прав на использование результатов интеллектуальной деятельности или средств индивидуализации.
* «payment» платеж. Об авансе, задатке, предоплате, кредите, взносе в счет оплаты, пени, штрафе, вознаграждении, бонусе и ином аналогичном предмете расчета.
* «agent_commission» агентское вознаграждение. О вознаграждении пользователя, являющегося платежным агентом (субагентом), банковским платежным агентом (субагентом), комиссионером, поверенным или иным агентом.
* «composite» составной предмет расчета. О предмете расчета, состоящем из предметов, каждому из которых может быть присвоено значение выше перечисленных признаков.
* «another» иной предмет расчета. О предмете расчета, не относящемуся к выше перечисленным предметам расчета
*
* @var string
*
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("payment_object")
* @Serializer\Type("string")
*/
private $paymentObject;
/**
* @var VatReceiptRequest
*
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("vat")
* @Serializer\Type("AtolOnlineClient\Request\V4\VatReceiptRequest")
*/
private $vat;
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @param string $name
*/
public function setName(string $name): void
{
$this->name = $name;
}
/**
* @return float
*/
public function getPrice(): float
{
return $this->price;
}
/**
* @param float $price
*/
public function setPrice(float $price): void
{
$this->price = $price;
}
/**
* @return int
*/
public function getQuantity(): int
{
return $this->quantity;
}
/**
* @param int $quantity
*/
public function setQuantity(int $quantity): void
{
$this->quantity = $quantity;
}
/**
* @return float
*/
public function getSum(): float
{
return $this->sum;
}
/**
* @param float $sum
*/
public function setSum(float $sum): void
{
$this->sum = $sum;
}
/**
* @return string
*/
public function getMeasurementUnit(): string
{
return $this->measurementUnit;
}
/**
* @param string $measurementUnit
*/
public function setMeasurementUnit(string $measurementUnit): void
{
$this->measurementUnit = $measurementUnit;
}
/**
* @return string
*/
public function getPaymentMethod(): string
{
return $this->paymentMethod;
}
/**
* @param string $paymentMethod
*/
public function setPaymentMethod(string $paymentMethod): void
{
$this->paymentMethod = $paymentMethod;
}
/**
* @return string
*/
public function getPaymentObject(): string
{
return $this->paymentObject;
}
/**
* @param string $paymentObject
*/
public function setPaymentObject(string $paymentObject): void
{
$this->paymentObject = $paymentObject;
}
/**
* @return VatReceiptRequest
*/
public function getVat(): VatReceiptRequest
{
return $this->vat;
}
/**
* @param VatReceiptRequest $vat
*/
public function setVat(VatReceiptRequest $vat): void
{
$this->vat = $vat;
}
}

View File

@ -0,0 +1,59 @@
<?php
namespace AtolOnlineClient\Request\V4;
use JMS\Serializer\Annotation as Serializer;
class ReceiptPaymentRequest
{
const TYPE_ELECTRON = 1;
//аванс
const TYPE_PREPAY = 2;
const TYPE_CREDIT = 3;
const TYPE_OTHER = 4;
/**
* @var int
* "enum": 0..9
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("type")
* @Serializer\Type("integer")
*/
private $type;
/**
* @var float
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("sum")
* @Serializer\Type("float")
*/
private $sum;
/**
* @param int $type
* @param float $sum
*/
public function __construct($type, $sum)
{
$this->type = $type;
$this->sum = $sum;
}
/**
* @return int
*/
public function getType()
{
return $this->type;
}
/**
* @return float
*/
public function getSum()
{
return $this->sum;
}
}

View File

@ -0,0 +1,163 @@
<?php
namespace AtolOnlineClient\Request\V4;
use JMS\Serializer\Annotation as Serializer;
class ReceiptRequest
{
/**
* @var ClientReceiptRequest
*
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("client")
* @Serializer\Type("AtolOnlineClient\Request\V4\ClientReceiptRequest")
*
*/
private $client;
/**
* @var CompanyReceiptRequest
*
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("company")
* @Serializer\Type("AtolOnlineClient\Request\V4\CompanyReceiptRequest")
*/
private $company;
/**
* @var ReceiptItemRequest[]
* "minItems": 1, "maxItems": 100,
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("items")
* @Serializer\Type("array<AtolOnlineClient\Request\V4\ReceiptItemRequest>")
*/
private $items;
/**
* @var \AtolOnlineClient\Request\V4\ReceiptPaymentRequest[]
* "minItems": 1, "maxItems": 10,
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("payments")
* @Serializer\Type("array<AtolOnlineClient\Request\V4\ReceiptPaymentRequest>")
*/
private $payments;
/**
* @var \AtolOnlineClient\Request\V4\VatReceiptRequest[]
* "minItems": 1, "maxItems": 6,
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("vats")
* @Serializer\Type("array<AtolOnlineClient\Request\V4\VatReceiptRequest>")
*/
private $vats;
/**
* @var float
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("total")
* @Serializer\Type("float")
*/
private $total;
/**
* @return ClientReceiptRequest
*/
public function getClient(): ClientReceiptRequest
{
return $this->client;
}
/**
* @param ClientReceiptRequest $client
*/
public function setClient(ClientReceiptRequest $client): void
{
$this->client = $client;
}
/**
* @return CompanyReceiptRequest
*/
public function getCompany(): CompanyReceiptRequest
{
return $this->company;
}
/**
* @param CompanyReceiptRequest $company
*/
public function setCompany(CompanyReceiptRequest $company): void
{
$this->company = $company;
}
/**
* @return ReceiptItemRequest[]
*/
public function getItems(): array
{
return $this->items;
}
/**
* @param ReceiptItemRequest[] $items
*/
public function setItems(array $items): void
{
$this->items = $items;
}
/**
* @return ReceiptPaymentRequest[]
*/
public function getPayments(): array
{
return $this->payments;
}
/**
* @param ReceiptPaymentRequest[] $payments
*/
public function setPayments(array $payments): void
{
$this->payments = $payments;
}
/**
* @return VatReceiptRequest[]
*/
public function getVats(): array
{
return $this->vats;
}
/**
* @param VatReceiptRequest[] $vats
*/
public function setVats(array $vats): void
{
$this->vats = $vats;
}
/**
* @return float
*/
public function getTotal(): float
{
return $this->total;
}
/**
* @param float $total
*/
public function setTotal(float $total): void
{
$this->total = $total;
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace AtolOnlineClient\Request\V4;
use JMS\Serializer\Annotation as Serializer;
class ServiceRequest
{
/**
* @var string
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("callback_url")
* @Serializer\Type("string")
*/
private $callbackUrl;
/**
* @return string
*/
public function getCallbackUrl(): string
{
return $this->callbackUrl;
}
/**
* @param string $callbackUrl
*/
public function setCallbackUrl(string $callbackUrl): void
{
$this->callbackUrl = $callbackUrl;
}
}

View File

@ -0,0 +1,63 @@
<?php
namespace AtolOnlineClient\Request\V4;
use JMS\Serializer\Annotation as Serializer;
class VatReceiptRequest
{
/**
*
* "enum": [
* "none",
* "vat0",
* "vat10",
* "vat18",
* "vat110",
* "vat118"
* ]
*
* @var string
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("type")
* @Serializer\Type("string")
*/
private $type;
/**
* @var float
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("sum")
* @Serializer\Type("float")
*/
private $sum;
/**
* VatReceiptRequest constructor.
* @param string $type
* @param float $sum
*/
public function __construct(string $type, string $sum)
{
$this->type = $type;
$this->sum = $sum;
}
/**
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* @return float
*/
public function getSum(): string
{
return $this->sum;
}
}

View File

@ -0,0 +1,96 @@
<?php
namespace AtolOnlineClient\Response;
use JMS\Serializer\Annotation as Serializer;
class Error
{
/**
* @var integer
*
* @Serializer\Groups({"post", "get"})
* @Serializer\SerializedName("code")
* @Serializer\Type("integer")
*/
private $code;
/**
* @var string
* @Serializer\Groups({"post", "get"})
* @Serializer\SerializedName("text")
* @Serializer\Type("string")
*/
private $text;
/**
* @var string
* "enum": ["none", "unknown", "system", "driver", "timeout"]
*
* @Serializer\Groups({"post", "get"})
* @Serializer\SerializedName("type")
* @Serializer\Type("string")
*/
private $type;
/**
* @return int
*/
public function getCode()
{
return $this->code;
}
/**
* @param int $code
*
* @return $this
*/
public function setCode($code)
{
$this->code = $code;
return $this;
}
/**
* @return string
*/
public function getText()
{
return $this->text;
}
/**
* @param string $text
*
* @return $this
*/
public function setText($text)
{
$this->text = $text;
return $this;
}
/**
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* @param string $type
*
* @return $this
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
}

View File

@ -0,0 +1,185 @@
<?php
namespace AtolOnlineClient\Response;
use JMS\Serializer\Annotation as Serializer;
class OperationResponse
{
/**
* @var string
*
* @Serializer\Groups({"post", "get"})
* @Serializer\SerializedName("uuid")
* @Serializer\Type("string")
*/
private $uuid;
/**
* @var string
*
* @Serializer\Groups({"post", "get"})
* @Serializer\SerializedName("timestamp")
* @Serializer\Type("string")
*/
private $timestamp;
/**
* @var string
*
* "enum": ["wait", "done", "fail"]
*
* @Serializer\Groups({"post", "get"})
* @Serializer\SerializedName("status")
* @Serializer\Type("string")
*/
private $status;
/**
* @var string
*
* @Serializer\Groups({"get"})
* @Serializer\SerializedName("callback_url")
* @Serializer\Type("string")
*/
private $callbackUrl;
/**
* @var Payload
*
* @Serializer\Groups({"get"})
* @Serializer\SerializedName("payload")
* @Serializer\Type("Intaro\CRMFiscalBundle\FiscalService\AtolOnline\Response\Payload")
*/
private $payload;
/**
* @var Error
*
* @Serializer\Groups({"post", "get"})
* @Serializer\SerializedName("error")
* @Serializer\Type("Intaro\CRMFiscalBundle\FiscalService\AtolOnline\Response\Error")
*/
private $error;
/**
* @return string
*/
public function getUuid()
{
return $this->uuid;
}
/**
* @param string $uuid
*
* @return $this
*/
public function setUuid($uuid)
{
$this->uuid = $uuid;
return $this;
}
/**
* @return string
*/
public function getTimestamp()
{
return $this->timestamp;
}
/**
* @param string $timestamp
*
* @return $this
*/
public function setTimestamp($timestamp)
{
$this->timestamp = $timestamp;
return $this;
}
/**
* @return string
*/
public function getStatus()
{
return $this->status;
}
/**
* @param string $status
*
* @return $this
*/
public function setStatus($status)
{
$this->status = $status;
return $this;
}
/**
* @return Error
*/
public function getError()
{
return $this->error;
}
/**
* @param Error $error
*
* @return $this
*/
public function setError($error)
{
$this->error = $error;
return $this;
}
/**
* @return string
*/
public function getCallbackUrl()
{
return $this->callbackUrl;
}
/**
* @param string $callbackUrl
*
* @return $this
*/
public function setCallbackUrl($callbackUrl)
{
$this->callbackUrl = $callbackUrl;
return $this;
}
/**
* @return Payload
*/
public function getPayload()
{
return $this->payload;
}
/**
* @param Payload $payload
*
* @return $this
*/
public function setPayload($payload)
{
$this->payload = $payload;
return $this;
}
}

View File

@ -0,0 +1,248 @@
<?php
namespace AtolOnlineClientResponse;
use JMS\Serializer\Annotation as Serializer;
class Payload
{
/**
* Номер чека в смене
* @var "integer"
*
* @Serializer\Groups({"get"})
* @Serializer\SerializedName("fiscal_receipt_number")
* @Serializer\Type("integer")
*/
private $fiscalReceiptNumber;
/**
* Номер смены
* @var "integer"
*
* @Serializer\Groups({"get"})
* @Serializer\SerializedName("shift_number")
* @Serializer\Type("integer")
*/
private $shiftNumber;
/**
* Дата и время документа из ФН
* @var string
*
* @Serializer\Groups({"get"})
* @Serializer\SerializedName("receipt_datetime")
* @Serializer\Type("string")
*/
private $receiptDatetime;
/**
* Итоговая сумма документа
* @var float
*
* @Serializer\Groups({"get"})
* @Serializer\SerializedName("total")
* @Serializer\Type("float")
*/
private $total;
/**
* Номер ФН
* @var string
*
* @Serializer\Groups({"get"})
* @Serializer\SerializedName("fn_number")
* @Serializer\Type("string")
*/
private $fnNumber;
/**
* Регистрационный номер ККМ
* @var string
*
* @Serializer\Groups({"get"})
* @Serializer\SerializedName("ecr_registration_number")
* @Serializer\Type("string")
*/
private $ecrRegistrationNumber;
/**
* Фискальный номер документа
* @var integer
*
* @Serializer\Groups({"get"})
* @Serializer\SerializedName("fiscal_document_number")
* @Serializer\Type("integer")
*/
private $fiscalDocumentNumber;
/**
* Фискальный признак документа
* @var integer
*
* @Serializer\Groups({"get"})
* @Serializer\SerializedName("fiscal_document_attribute")
* @Serializer\Type("integer")
*/
private $fiscalDocumentAttribute;
/**
* @return mixed
*/
public function getFiscalReceiptNumber()
{
return $this->fiscalReceiptNumber;
}
/**
* @param mixed $fiscalReceiptNumber
*
* @return $this
*/
public function setFiscalReceiptNumber($fiscalReceiptNumber)
{
$this->fiscalReceiptNumber = $fiscalReceiptNumber;
return $this;
}
/**
* @return mixed
*/
public function getShiftNumber()
{
return $this->shiftNumber;
}
/**
* @param mixed $shiftNumber
*
* @return $this
*/
public function setShiftNumber($shiftNumber)
{
$this->shiftNumber = $shiftNumber;
return $this;
}
/**
* @return string
*/
public function getReceiptDatetime()
{
return $this->receiptDatetime;
}
/**
* @param string $receiptDatetime
*
* @return $this
*/
public function setReceiptDatetime($receiptDatetime)
{
$this->receiptDatetime = $receiptDatetime;
return $this;
}
/**
* @return float
*/
public function getTotal()
{
return $this->total;
}
/**
* @param float $total
*
* @return $this
*/
public function setTotal($total)
{
$this->total = $total;
return $this;
}
/**
* @return string
*/
public function getFnNumber()
{
return $this->fnNumber;
}
/**
* @param string $fnNumber
*
* @return $this
*/
public function setFnNumber($fnNumber)
{
$this->fnNumber = $fnNumber;
return $this;
}
/**
* @return string
*/
public function getEcrRegistrationNumber()
{
return $this->ecrRegistrationNumber;
}
/**
* @param string $ecrRegistrationNumber
*
* @return $this
*/
public function setEcrRegistrationNumber($ecrRegistrationNumber)
{
$this->ecrRegistrationNumber = $ecrRegistrationNumber;
return $this;
}
/**
* @return int
*/
public function getFiscalDocumentNumber()
{
return $this->fiscalDocumentNumber;
}
/**
* @param int $fiscalDocumentNumber
*
* @return $this
*/
public function setFiscalDocumentNumber($fiscalDocumentNumber)
{
$this->fiscalDocumentNumber = $fiscalDocumentNumber;
return $this;
}
/**
* @return int
*/
public function getFiscalDocumentAttribute()
{
return $this->fiscalDocumentAttribute;
}
/**
* @param int $fiscalDocumentAttribute
*
* @return $this
*/
public function setFiscalDocumentAttribute($fiscalDocumentAttribute)
{
$this->fiscalDocumentAttribute = $fiscalDocumentAttribute;
return $this;
}
}