1
0
Fork 0
mirror of synced 2025-04-19 08:50:57 +00:00

Compare commits

..

No commits in common. "master" and "3.0.2" have entirely different histories.

13 changed files with 37 additions and 68 deletions

1
.gitignore vendored
View file

@ -2,4 +2,3 @@
/vendor
composer.lock
.phpunit.result.cache
.env

View file

@ -1,16 +1,10 @@
language: php
php:
- 7.1
- 7.2
- 7.3
- 7.4
env:
- JMS=0.12
- JMS=1.0
- JMS=2.0
- JMS=3.0
before_install:
- composer selfupdate
- composer require jms/serializer=^$JMS --no-interaction --prefer-dist
- composer install --dev --no-interaction --prefer-dist

View file

@ -1,6 +0,0 @@
ARG PHP_IMAGE_TAG
FROM php:${PHP_IMAGE_TAG}-cli-alpine
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
WORKDIR /opt/test

View file

@ -1,16 +0,0 @@
ifneq (,$(shell (type docker-compose 2>&1 >/dev/null && echo 1) || true))
PHP=docker-compose run --rm --no-deps php
else
PHP=php
endif
PHP_CONSOLE_DEPS=vendor
vendor: composer.json
@$(PHP) composer install -o -n --no-ansi
@touch vendor || true
phpunit: $(PHP_CONSOLE_DEPS)
@$(PHP) vendor/bin/phpunit --color=always
check: phpunit

View file

@ -1,13 +1,13 @@
[![Build Status](https://app.travis-ci.com/retailcrm/atol-online-client.svg?branch=master)](https://app.travis-ci.com/retailcrm/atol-online-client)
[![Build Status](https://img.shields.io/travis/retailcrm/atol-online-client/master.svg?style=flat-square)](https://travis-ci.org/retailcrm/atol-online-client)
[![Latest stable](https://img.shields.io/packagist/v/retailcrm/atol-online-client.svg?style=flat-square)](https://packagist.org/packages/retailcrm/atol-online-client)
# API-клиент для АТОЛ.Онлайн
API-клиент на PHP для сервиса онлайн-фискализации платежей АТОЛ.Онлайн
API-клиент на PHP для сервиса онлайн-фискализации платежей АТОЛ.Онлайн.
## Требования
* PHP 7.2 и выше
* PHP 7.1 и выше
* PHP extension cURL
## Пример использования

View file

@ -10,17 +10,17 @@
}
],
"require": {
"php": ">=7.2",
"php": ">=7.1",
"ext-curl": "*",
"ext-json": "*",
"guzzlehttp/guzzle": "~6.3|^7.0",
"jms/serializer": "^0.12|^1.0|^2.0|^3.0",
"symfony/validator": "~2.8|~3.0|~4.0|^5.0|^6.0",
"guzzlehttp/guzzle": "~6.3",
"jms/serializer": "~0.12 || ~1.4.2",
"symfony/validator": "~2.8|~3.0|~4.0",
"doctrine/cache": "~1.6",
"psr/log": "~1.0|^2.0|^3.0"
"psr/log": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "~8.0"
"phpunit/phpunit": "~7.0"
},
"support": {
"email": "support@retailcrm.ru"

View file

@ -1,11 +0,0 @@
version: '3.4'
services:
php:
build:
context: .
args:
PHP_IMAGE_TAG: ${PHP_IMAGE_TAG:-7.4}
volumes:
- "./:/opt/test"

View file

@ -8,7 +8,6 @@
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
convertDeprecationsToExceptions="true"
processIsolation="false"
stopOnFailure="false">

View file

@ -53,11 +53,11 @@ class ReceiptItemRequest
private $price;
/**
* @var float
* @var integer
* required
* @Serializer\Groups({"set", "get"})
* @Serializer\SerializedName("quantity")
* @Serializer\Type("float")
* @Serializer\Type("integer")
*/
private $quantity;
@ -175,17 +175,17 @@ class ReceiptItemRequest
}
/**
* @return float
* @return int
*/
public function getQuantity(): float
public function getQuantity(): int
{
return $this->quantity;
}
/**
* @param float $quantity
* @param int $quantity
*/
public function setQuantity(float $quantity): void
public function setQuantity(int $quantity): void
{
$this->quantity = $quantity;
}

View file

@ -143,7 +143,7 @@ class AtolOnlineApiTest extends TestCase
*/
public function testGetTokenBadResponse(): void
{
$api = $this->getApi([new BadResponseException('', new Request('GET', 'test'), new Response())]);
$api = $this->getApi([new BadResponseException('', new Request('GET', 'test'))]);
$this->assertFalse($this->callMethod($api, 'getToken'));
}

View file

@ -160,7 +160,7 @@ class AtolOnlineTest extends TestCase
$request->setTimestamp('17.07.2019 10:14:22');
$this->assertEquals(
'{"external_id":"test","receipt":{"client":{"email":"test@test.local"},"company":{"email":"test@test.local","inn":"11111111","payment_address":"address"},"items":[{"name":"test item","price":100.1,"quantity":1.1,"sum":100.1,"measurement_unit":"kg","payment_method":"advance","payment_object":"agent_commission","vat":{"type":"vat20","sum":20.2},"nomenclature_code":"00"}],"payments":[{"type":0,"sum":100.1}],"vats":[{"type":"vat20","sum":20.2}],"total":100.1},"timestamp":"17.07.2019 10:14:22","service":{"callback_url":"test.local"}}',
'{"external_id":"test","receipt":{"client":{"email":"test@test.local"},"company":{"email":"test@test.local","inn":"11111111","payment_address":"address"},"items":[{"name":"test item","price":100,"quantity":1,"sum":100,"measurement_unit":"kg","payment_method":"advance","payment_object":"agent_commission","vat":{"type":"vat20","sum":20},"nomenclature_code":"00"}],"payments":[{"type":0,"sum":100}],"vats":[{"type":"vat20","sum":20}],"total":100},"timestamp":"17.07.2019 10:14:22","service":{"callback_url":"test.local"}}',
$this->atol->serializeOperationRequest($request)
);
}

View file

@ -30,22 +30,22 @@ trait PaymentReceiptRequestTrait
$item = new ReceiptItemRequest();
$item->setName('test item');
$item->setPrice(100.1);
$item->setQuantity(1.1);
$item->setSum(100.1);
$item->setPrice(100);
$item->setQuantity(1);
$item->setSum(100);
$item->setMeasurementUnit('kg');
$item->setPaymentMethod(ReceiptItemRequest::PAYMENT_METHOD_ADVANCE);
$item->setPaymentObject(ReceiptItemRequest::PAYMENT_OBJECT_AGENT_COMMISSION);
$item->setVat(new VatReceiptRequest('vat20', 20.2));
$item->setVat(new VatReceiptRequest('vat20', 20));
$item->setNomenclatureCode('00');
$receipt = new ReceiptRequest();
$receipt->setTotal(100.1);
$receipt->setTotal('100');
$receipt->setClient($client);
$receipt->setCompany($company);
$receipt->setItems([$item]);
$receipt->setPayments([new ReceiptPaymentRequest(0, 100.1)]);
$receipt->setVats([new VatReceiptRequest('vat20', 20.2)]);
$receipt->setPayments([new ReceiptPaymentRequest(0, 100)]);
$receipt->setVats([new VatReceiptRequest('vat20', 20)]);
/** @var PaymentReceiptRequest $request */
$request = new PaymentReceiptRequest();

View file

@ -1,3 +1,13 @@
<?php
return require __DIR__.'/../vendor/autoload.php';
use Composer\Autoload\ClassLoader;
use Doctrine\Common\Annotations\AnnotationRegistry;
/**
* @var ClassLoader $loader
*/
$loader = require __DIR__.'/../vendor/autoload.php';
AnnotationRegistry::registerLoader('class_exists');
return $loader;