diff --git a/README.md b/README.md index b92c9ff..ba3a669 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Platron Atol SDK ## Установка Проект предполагает установку с использованием composer -
composer require payprocessing/atol-sdk-api-v4
+
composer require payprocessing/atol-sdk-api-v5
## Тесты Для работы тестов необходим PHPUnit, для его установки необходимо выполнить команду diff --git a/composer.json b/composer.json index 52582e5..8fed044 100644 --- a/composer.json +++ b/composer.json @@ -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", @@ -13,8 +13,8 @@ }, "autoload": { "psr-4": { - "Platron\\AtolV4\\": "src", - "Platron\\AtolV4\\tests\\": "tests" + "Platron\\AtolV5\\": "src", + "Platron\\AtolV5\\tests\\": "tests" } } } diff --git a/src/SdkException.php b/src/SdkException.php index 2be790c..f17d8da 100644 --- a/src/SdkException.php +++ b/src/SdkException.php @@ -1,6 +1,6 @@ name = (string)$name; + } + + /** + * @param string $value + */ + public function addValue($value) + { + $this->value = (string)$value; + } + +} diff --git a/src/data_objects/AgentInfo.php b/src/data_objects/AgentInfo.php index 9bebdbb..9a1abff 100644 --- a/src/data_objects/AgentInfo.php +++ b/src/data_objects/AgentInfo.php @@ -1,8 +1,8 @@ type = $type->getValue(); diff --git a/src/data_objects/BaseDataObject.php b/src/data_objects/BaseDataObject.php index a98fa27..5ec1879 100644 --- a/src/data_objects/BaseDataObject.php +++ b/src/data_objects/BaseDataObject.php @@ -1,6 +1,6 @@ phone = '+'.(string)$phone; + $this->phone = '+' . (string)$phone; } /** @@ -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; + } + + } \ No newline at end of file diff --git a/src/data_objects/Company.php b/src/data_objects/Company.php index 8d88ad5..241ab4c 100644 --- a/src/data_objects/Company.php +++ b/src/data_objects/Company.php @@ -1,8 +1,8 @@ email = (string)$email; diff --git a/src/data_objects/Correction.php b/src/data_objects/Correction.php index aebd162..d9801ae 100644 --- a/src/data_objects/Correction.php +++ b/src/data_objects/Correction.php @@ -1,8 +1,8 @@ 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(); } /** @@ -53,7 +67,8 @@ public function addVat(Vat $vat) /** * @return string */ - public function getOperationType(){ + public function getOperationType() + { return $this->operationType; } @@ -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; } } \ No newline at end of file diff --git a/src/data_objects/CorrectionInfo.php b/src/data_objects/CorrectionInfo.php index 24dc6e8..efd0b0b 100644 --- a/src/data_objects/CorrectionInfo.php +++ b/src/data_objects/CorrectionInfo.php @@ -1,8 +1,8 @@ type = $type->getValue(); $this->base_date = $baseDate->format('d.m.Y'); $this->base_number = (string)$baseNumber; - $this->base_name = (string)$baseName; } } \ No newline at end of file diff --git a/src/data_objects/Item.php b/src/data_objects/Item.php index 95e77b8..1156cb8 100644 --- a/src/data_objects/Item.php +++ b/src/data_objects/Item.php @@ -1,9 +1,10 @@ measurement_unit = (string)$measuringUnit; + $this->measure = (int)$measure; } /** @@ -101,6 +111,14 @@ public function addAgentInfo(AgentInfo $agentInfo) $this->supplier_info = $agentInfo->getSupplierInfo(); } + /** + * @param MarkQuantity $markQuantity + */ + public function addMarkQuantity(MarkQuantity $markQuantity) + { + $this->mark_quantity = $markQuantity; + } + /** * @param string $userData */ @@ -120,28 +138,60 @@ public function addNomenclatureCode($nomenclatureCode) /** * @param float $excise */ - public function addExcise($excise) { - $this->excise = $excise; + $this->excise = $excise; } /** * @param string $countryCode */ - public function addCountryCode($countryCode) { - $this->country_code = (string)$countryCode; + $this->country_code = (string)$countryCode; } /** * @param string $declarationNumber */ + public function addDeclarationNumber($declarationNumber) + { + $this->declaration_number = (string)$declarationNumber; + } - public function addDeclarationNumber($declarationNumber) + /** + * @param string $markProcessingMode + */ + public function addMarkProcessingMode($markProcessingMode) { - $this->declaration_number = (string)$declarationNumber; + $this->mark_processing_mode = (string)$markProcessingMode; } + /** + * @param MarkCode $markCode + */ + public function addMarkCode(MarkCode $markCode) + { + $this->mark_code = $markCode; + } + + /** + * @param SectoralItemProps[] $sectoralItemProps + */ + public function addSectoralItemProps($sectoralItemProps) + { + $this->sectoralItemProps = $sectoralItemProps; + } + + public function getParameters() + { + $params = parent::getParameters(); + if ($this->sectoralItemProps) { + foreach ($this->sectoralItemProps as $sectoralItemProp) { + $params['sectoral_item_props'][] = $sectoralItemProp->getParameters(); + } + } + + return $params; + } } diff --git a/src/data_objects/MarkCode.php b/src/data_objects/MarkCode.php new file mode 100644 index 0000000..2990ac4 --- /dev/null +++ b/src/data_objects/MarkCode.php @@ -0,0 +1,33 @@ +type = $markCodeType->getValue(); + $this->value = (string)$value; + } + + public function getParameters() + { + $field = []; + $field[$this->type] = $this->value; + return $field; + } + +} + diff --git a/src/data_objects/MarkQuantity.php b/src/data_objects/MarkQuantity.php new file mode 100644 index 0000000..233c1d4 --- /dev/null +++ b/src/data_objects/MarkQuantity.php @@ -0,0 +1,31 @@ +numerator = (int)$numerator; + } + + /** + * @param int $denominator + */ + public function addDenominator($denominator) + { + $this->denominator = (int)$denominator; + } + +} diff --git a/src/data_objects/MoneyTransferOperator.php b/src/data_objects/MoneyTransferOperator.php index 22379ec..a8e1e0c 100644 --- a/src/data_objects/MoneyTransferOperator.php +++ b/src/data_objects/MoneyTransferOperator.php @@ -1,6 +1,6 @@ name = (string)$name; + } + + /** + * @param string $value + */ + public function addValue($value) + { + $this->value = (string)$value; + } + + /** + * @param string $value + */ + public function addTimestamp($timestamp) + { + $this->timestamp = (string)$timestamp; + } +} diff --git a/src/data_objects/PayingAgent.php b/src/data_objects/PayingAgent.php index 37d9721..779bc86 100644 --- a/src/data_objects/PayingAgent.php +++ b/src/data_objects/PayingAgent.php @@ -1,6 +1,6 @@ client = $client; $this->company = $company; - foreach($items as $item) { + foreach ($items as $item) { $this->addItem($item); } $this->addPayment($payment); @@ -69,10 +75,49 @@ private function getItemsAmount() /** * @return string */ - public function getOperationType(){ + public function getOperationType() + { return $this->operationType; } + /** + * @param string $additionalCheckProps + */ + public function setAdditionalCheckProps($additionalCheckProps) + { + if (!is_string($additionalCheckProps)) { + throw new \InvalidArgumentException('Parameter additionalCheckProps should be string'); + } + if (strlen($additionalCheckProps) > 16) { + throw new \LengthException('Parameter additionalCheckProps should has length less than or equal 16'); + } + $this->additionalCheckProps = $additionalCheckProps; + } + + /** + * @param OperatingCheckProps $operatingCheckProps + */ + public function addOperatingCheckProps(OperatingCheckProps $operatingCheckProps) + { + $this->operating_check_props = $operatingCheckProps; + } + + /** + * @param AdditionalUserProps $additionalUserProps + */ + public function addAdditionalUserProps(AdditionalUserProps $additionalUserProps) + { + $this->additional_user_props = $additionalUserProps; + } + + /** + * @param SectoralCheckProps[] $sectoralCheckProps + */ + public function addSectoralCheckProps($sectoralCheckProps) + { + $this->sectoralCheckProps = $sectoralCheckProps; + } + /** * @return array */ @@ -80,33 +125,25 @@ public function getParameters() { $params = parent::getParameters(); - foreach($this->items as $item) { + foreach ($this->items as $item) { $params['items'][] = $item->getParameters(); } - foreach($this->payments as $payment) { + foreach ($this->payments as $payment) { $params['payments'][] = $payment->getParameters(); } $params['total'] = (double)$this->getItemsAmount(); if (!empty($this->additionalCheckProps)) { - $params['additional_check_props'] = $this->additionalCheckProps; - } + $params['additional_check_props'] = $this->additionalCheckProps; + } + + if ($this->sectoralCheckProps) { + foreach ($this->sectoralCheckProps as $sectoralCheckProp) { + $params['sectoral_check_props'][] = $sectoralCheckProp->getParameters(); + } + } return $params; } - - /** - * @param string $additionalCheckProps - */ - public function setAdditionalCheckProps($additionalCheckProps) - { - if (!is_string($additionalCheckProps)) { - throw new \InvalidArgumentException('Parameter additionalCheckProps should be string'); - } - if (strlen($additionalCheckProps) > 16) { - throw new \LengthException('Parameter additionalCheckProps should has length less than or equal 16'); - } - $this->additionalCheckProps = $additionalCheckProps; - } } \ No newline at end of file diff --git a/src/data_objects/ReceivePaymentsOperator.php b/src/data_objects/ReceivePaymentsOperator.php index 5ac20a2..d7b494d 100644 --- a/src/data_objects/ReceivePaymentsOperator.php +++ b/src/data_objects/ReceivePaymentsOperator.php @@ -1,6 +1,6 @@ federal_id = (string)$federalID; + } + + /** + * @param string $date + */ + public function addDate($date) + { + $this->date = (string)$date; + } + + /** + * @param string $number + */ + public function addNumber($number) + { + $this->number = (string)$number; + } + + /** + * @param string $date + */ + public function addValue($value) + { + $this->value = (string)$value; + } + + +} diff --git a/src/data_objects/SectoralCheckProps.php b/src/data_objects/SectoralCheckProps.php new file mode 100644 index 0000000..b09a7c3 --- /dev/null +++ b/src/data_objects/SectoralCheckProps.php @@ -0,0 +1,9 @@ +callbackUrl = (string)$callbackUrl; diff --git a/src/data_objects/Supplier.php b/src/data_objects/Supplier.php index 35ad095..7638269 100644 --- a/src/data_objects/Supplier.php +++ b/src/data_objects/Supplier.php @@ -1,11 +1,11 @@ type = $type->getValue(); diff --git a/src/handbooks/AgentTypes.php b/src/handbooks/AgentTypes.php index 6a5de05..4284b71 100644 --- a/src/handbooks/AgentTypes.php +++ b/src/handbooks/AgentTypes.php @@ -1,6 +1,6 @@ hasStandardError($response)) { @@ -41,9 +45,9 @@ private function hasStandardError(stdClass $response) private function setStandardError(stdClass $response) { $this->errorCode = $response->error->code; - $this->errorDescription = 'Error type '.$response->error->type.' error code '.$response->error->code.' '.$response->error->text; - if(!empty($response->error->error_id)){ - $this->errorDescription .= '. Error id '.$response->error->error_id; + $this->errorDescription = 'Error type ' . $response->error->type . ' error code ' . $response->error->code . ' ' . $response->error->text; + if (!empty($response->error->error_id)) { + $this->errorDescription .= '. Error id ' . $response->error->error_id; } } diff --git a/src/services/CreateCorrectionRequest.php b/src/services/CreateCorrectionRequest.php index 3d02188..1347235 100644 --- a/src/services/CreateCorrectionRequest.php +++ b/src/services/CreateCorrectionRequest.php @@ -1,9 +1,9 @@ getBaseUrl() . $this->groupCode . '/'.$this->correction->getOperationType(); + return $this->getBaseUrl() . $this->groupCode . '/' . $this->correction->getOperationType(); } /** diff --git a/src/services/CreateCorrectionResponse.php b/src/services/CreateCorrectionResponse.php index 45bba6c..1837b71 100644 --- a/src/services/CreateCorrectionResponse.php +++ b/src/services/CreateCorrectionResponse.php @@ -1,6 +1,6 @@ getBaseUrl() . $this->groupCode . '/'.$this->receipt->getOperationType(); + return $this->getBaseUrl() . $this->groupCode . '/' . $this->receipt->getOperationType(); } /** diff --git a/src/services/CreateReceiptResponse.php b/src/services/CreateReceiptResponse.php index 5423901..6f998f6 100644 --- a/src/services/CreateReceiptResponse.php +++ b/src/services/CreateReceiptResponse.php @@ -1,6 +1,6 @@ createGetStatusRequest($createReceiptResponse, $tokenResponse); - if(!$this->checkCorrectionStatus($client, $getStatusRequest)){ + if (!$this->checkCorrectionStatus($client, $getStatusRequest)) { $this->fail('Correction don`t change status'); } } @@ -102,8 +115,7 @@ private function createCorrectionInfo() $correctionInfo = new CorrectionInfo( new CorrectionTypes(CorrectionTypes::SELF), new \DateTime(), - 'Test base number', - 'Test base name' + 'Test base number' ); return $correctionInfo; } @@ -126,10 +138,132 @@ private function createPayment() private function createVat() { $vat = new Vat(new Vates(Vates::VAT10)); - $vat->addSum(10); + $vat->addSum(100); return $vat; } + /** + * @return Item + */ + private function createItem() + { + $vat = $this->createVat(); + $item = new Item( + 'Test Product', + 100, + 1, + $vat + ); + $agentInfo = $this->createAgentInfo(); + $item->addAgentInfo($agentInfo); + $item->getPositionSum(100); + $item->addMeasure(0); + $item->addMarkProcessingMode(0); + $markQuantity = $this->createMarkQuantity(); + $item->addMarkQuantity($markQuantity); + $code = "MDEwNDYwNzQyODY3OTA5MDIxNmVKSWpvV0g1NERkVSA5MWZmZDAgOTJzejZrU1BpckFwZk1CZnR2TGJvRTFkbFdDLzU4aEV4UVVxdjdCQmtabWs0PQ=="; + $markCode = new MarkCode( + new MarkCodeTypes(MarkCodeTypes::GS1M), + $code); + $item->addMarkCode($markCode); + $sectoral_item_props = $this->createSectoralItemProps(); + $item->addSectoralItemProps([$sectoral_item_props]); + $item->addPaymentMethod(new PaymentMethods(PaymentMethods::FULL_PAYMENT)); + $item->addPaymentObject(new PaymentObjects(PaymentObjects::EXCISE_WITH_MARK)); + $item->addUserData('Test user data'); + $item->addExcise(5.64); + $item->addCountryCode("643"); + $item->addDeclarationNumber("10702020/060520/0013422"); + return $item; + } + + /** + * @return SectoralItemProps + */ + private function createSectoralItemProps() + { + $sectoral_item_props = new SectoralItemProps("003"); + $sectoral_item_props->addDate("12.05.2020"); + $sectoral_item_props->addNumber("123/43"); + $sectoral_item_props->addValue("id1=val1&id2=val2&id3=val3"); + return $sectoral_item_props; + } + + /** + * @return AgentInfo + */ + private function createAgentInfo() + { + $supplier = $this->createSupplier(); + $agentInfo = new AgentInfo( + new AgentTypes(AgentTypes::PAYING_AGENT), + $supplier + ); + $payingAgent = $this->createPayingAgent(); + $agentInfo->addPayingAgent($payingAgent); + $moneyTransferOperator = $this->createMoneyTransferOperator(); + $receivePaymentOperator = $this->createReceivePaymentOperator(); + $agentInfo->addMoneyTransferOperator($moneyTransferOperator); + $agentInfo->addReceivePaymentsOperator($receivePaymentOperator); + return $agentInfo; + } + + /** + * @return PayingAgent + */ + private function createPayingAgent() + { + $payingAgent = new PayingAgent('Operation name'); + $payingAgent->addPhone('79050000003'); + $payingAgent->addPhone('79050000004'); + return $payingAgent; + } + + /** + * @return MarkQuantity + */ + private function createMarkQuantity() + { + $markQuantity = new MarkQuantity(); + $markQuantity->addNumerator(4); + $markQuantity->addDenominator(7); + return $markQuantity; + } + + /** + * @return Supplier + */ + private function createSupplier() + { + $supplier = new Supplier('Supplier name'); + $supplier->addInn($this->inn); + $supplier->addPhone('79050000001'); + $supplier->addPhone('79050000002'); + return $supplier; + } + + /** + * @return MoneyTransferOperator + */ + private function createMoneyTransferOperator() + { + $moneyTransferOperator = new MoneyTransferOperator('Test moneyTransfer operator'); + $moneyTransferOperator->addInn($this->inn); + $moneyTransferOperator->addPhone('79050000005'); + $moneyTransferOperator->addAddress('site.ru'); + return $moneyTransferOperator; + } + + /** + * @return ReceivePaymentsOperator + */ + private function createReceivePaymentOperator() + { + $receivePaymentOperator = new ReceivePaymentsOperator('79050000006'); + $receivePaymentOperator->addPhone('79050000007'); + return $receivePaymentOperator; + } + /** * @return Correction */ @@ -139,13 +273,14 @@ private function createCorrection() $correctionInfo = $this->createCorrectionInfo(); $payment = $this->createPayment(); $vat = $this->createVat(); - + $item = $this->createItem(); $correction = new Correction( new CorrectionOperationTypes(CorrectionOperationTypes::BUY_CORRECTION), $company, $correctionInfo, $payment, - $vat + $vat, + [$item] ); return $correction; } @@ -158,7 +293,7 @@ private function createCorrection() */ private function checkCorrectionStatus(PostClient $client, GetStatusRequest $getStatusRequest) { - for ($second = 0; $second <= 10; $second++) { + for ($second = 0; $second <= 20; $second++) { $getStatusResponse = new GetStatusResponse($client->sendRequest($getStatusRequest)); if ($getStatusResponse->isReceiptReady()) { $this->assertTrue($getStatusResponse->isValid()); diff --git a/tests/integration/CreateReceiptTest.php b/tests/integration/CreateReceiptTest.php index e2f8ced..78594c0 100644 --- a/tests/integration/CreateReceiptTest.php +++ b/tests/integration/CreateReceiptTest.php @@ -1,33 +1,41 @@ assertTrue($createReceiptResponse->isValid()); $getStatusRequest = $this->createGetStatusRequest($createReceiptResponse, $tokenResponse); - if(!$this->checkReceiptStatus($client, $getStatusRequest)){ + if (!$this->checkReceiptStatus($client, $getStatusRequest)) { $this->fail('Receipt don`t change status'); } } @@ -60,6 +68,11 @@ private function createCustomer() $customer = new Client(); $customer->addEmail('test@test.ru'); $customer->addPhone('79050000000'); + $customer->addBirthdate("18.11.1990"); + $customer->addCitizenship("643"); + $customer->addDocumentCode("21"); + $customer->addDocumentData("4507 443564"); + $customer->addAddress("г.Москва, Ленинский проспект д.1 кв 43"); return $customer; } @@ -83,7 +96,7 @@ private function createCompany() private function createVat() { $vat = new Vat(new Vates(Vates::VAT10)); - $vat->addSum(20); + $vat->addSum(10); return $vat; } @@ -163,15 +176,33 @@ private function createItem() $item = new Item( 'Test Product', 10, - 2, + 1, $vat ); $agentInfo = $this->createAgentInfo(); $item->addAgentInfo($agentInfo); - $item->getPositionSum(20); - $item->addMeasurementUnit('pounds'); + $item->getPositionSum(10); + + $item->addMeasure(0); + + $item->addMarkProcessingMode(0); + + $markQuantity = $this->createMarkQuantity(); + $item->addMarkQuantity($markQuantity); + + $code = "MDEwNDYwNzQyODY3OTA5MDIxNmVKSWpvV0g1NERkVSA5MWZmZDAgOTJzejZrU1BpckFwZk1CZnR2TGJvRTFkbFdDLzU4aEV4UVVxdjdCQmtabWs0PQ=="; + + $markCode = new MarkCode( + new MarkCodeTypes(MarkCodeTypes::GS1M), + $code); + + $item->addMarkCode($markCode); + + $sectoral_item_props = $this->createSectoralItemProps(); + $item->addSectoralItemProps($sectoral_item_props->getParameters()); + $item->addPaymentMethod(new PaymentMethods(PaymentMethods::FULL_PAYMENT)); - $item->addPaymentObject(new PaymentObjects(PaymentObjects::COMMODITY)); + $item->addPaymentObject(new PaymentObjects(PaymentObjects::EXCISE_WITH_MARK)); $item->addUserData('Test user data'); $item->addExcise(5.64); $item->addCountryCode("643"); @@ -179,6 +210,65 @@ private function createItem() return $item; } + /** + * @return MarkQuantity + */ + private function createMarkQuantity() + { + $markQuantity = new MarkQuantity(); + $markQuantity->addNumerator(4); + $markQuantity->addDenominator(7); + return $markQuantity; + } + + /** + * @return SectoralItemProps + */ + private function createSectoralItemProps() + { + $sectoral_item_props = new SectoralItemProps("003"); + $sectoral_item_props->addDate("12.05.2020"); + $sectoral_item_props->addNumber("123/43"); + $sectoral_item_props->addValue("id1=val1&id2=val2&id3=val3"); + return $sectoral_item_props; + } + + /** + * @return SectoralBase + */ + private function createSectoralCheckProps() + { + $sectoral_check_props = new SectoralCheckProps("004"); + $sectoral_check_props->addDate("15.08.2020"); + $sectoral_check_props->addNumber("123/43"); + $sectoral_check_props->addValue("id1=val1&id2=val2&id3=val3"); + return $sectoral_check_props; + } + + /** + * @return OperatingCheckProps + */ + + private function createOperatingCheckProps() + { + $operating_check_props = new OperatingCheckProps("0"); + $operating_check_props->addValue("Operating check props value"); + $operating_check_props->addTimestamp("12.10.2020 17:20:55"); + return $operating_check_props; + } + + /** + * @return AdditionalUserProps + */ + + private function createAdditionalUserProps() + { + $additional_user_props = new AdditionalUserProps(); + $additional_user_props->addName("Additional user props name"); + $additional_user_props->addValue("Additional user props value"); + return $additional_user_props; + } + /** * @return Payment */ @@ -186,7 +276,7 @@ private function createPayment() { $payment = new Payment( new PaymentTypes(PaymentTypes::ELECTRON), - 20 + 10 ); return $payment; } @@ -201,6 +291,16 @@ private function createReceipt() $customer = $this->createCustomer(); $company = $this->createCompany(); $receipt = new Receipt($customer, $company, [$item], $payment, new ReceiptOperationTypes(ReceiptOperationTypes::BUY)); + + $sectoral_check_props = $this->createSectoralCheckProps(); + $receipt->addSectoralCheckProps([$sectoral_check_props]); + + $operating_check_props = $this->createOperatingCheckProps(); + $receipt->addOperatingCheckProps($operating_check_props); + + $additional_user_props = $this->createAdditionalUserProps(); + $receipt->addAdditionalUserProps($additional_user_props); + return $receipt; } @@ -252,7 +352,7 @@ private function createGetStatusRequest($createReceiptResponse, $tokenResponse) */ private function checkReceiptStatus(PostClient $client, GetStatusRequest $getStatusRequest) { - for ($second = 0; $second <= 10; $second++) { + for ($second = 0; $second <= 20; $second++) { $getStatusResponse = new GetStatusResponse($client->sendRequest($getStatusRequest)); if ($getStatusResponse->isReceiptReady()) { $this->assertTrue($getStatusResponse->isValid()); diff --git a/tests/integration/IntegrationTestBase.php b/tests/integration/IntegrationTestBase.php index 1649623..d5cf6c6 100644 --- a/tests/integration/IntegrationTestBase.php +++ b/tests/integration/IntegrationTestBase.php @@ -1,6 +1,6 @@ logToFile($message); } + public function alert($message, array $context = array()) { $this->logToFile($message); } + public function critical($message, array $context = array()) { $this->logToFile($message); } + public function error($message, array $context = array()) { $this->logToFile($message); } + public function warning($message, array $context = array()) { $this->logToFile($message); } + public function notice($message, array $context = array()) { $this->logToFile($message); } + public function info($message, array $context = array()) { $this->logToFile($message); } + public function debug($message, array $context = array()) { $this->logToFile($message); } + public function log($level, $message, array $context = array()) { $this->logToFile($message); } + private function logToFile($message) { - $preparedString = date('Y-m-d H:i:s').'; '.$message.PHP_EOL; - file_put_contents(__DIR__ . '/logs/' .date('Y-m-d').'.log', $preparedString, FILE_APPEND); + $preparedString = date('Y-m-d H:i:s') . '; ' . $message . PHP_EOL; + file_put_contents(__DIR__ . '/logs/' . date('Y-m-d') . '.log', $preparedString, FILE_APPEND); } } \ No newline at end of file diff --git a/tests/unit/data_objects/ReceiptTest.php b/tests/unit/data_objects/ReceiptTest.php index ddc16ac..9ba8ad6 100644 --- a/tests/unit/data_objects/ReceiptTest.php +++ b/tests/unit/data_objects/ReceiptTest.php @@ -1,57 +1,57 @@ createReceipt(); + public function test_getParameters_withoutAdditionalCheckProps_resultHasNoKey() + { + $receipt = $this->createReceipt(); - $this->assertArrayNotHasKey('additional_check_props', $receipt->getParameters()); - } + $this->assertArrayNotHasKey('additional_check_props', $receipt->getParameters()); + } - public function test_getParameters_withAdditionalCheckProps_resultHasAppropriateValue() - { - $receipt = $this->createReceipt(); + public function test_getParameters_withAdditionalCheckProps_resultHasAppropriateValue() + { + $receipt = $this->createReceipt(); - $receipt->setAdditionalCheckProps('additional'); + $receipt->setAdditionalCheckProps('additional'); - $this->assertEquals($receipt->getParameters()['additional_check_props'], 'additional'); - } + $this->assertEquals($receipt->getParameters()['additional_check_props'], 'additional'); + } - public function test_setAdditionalCheckProps_notString_expectInvalidArgumentException() - { - $receipt = $this->createReceipt(); + public function test_setAdditionalCheckProps_notString_expectInvalidArgumentException() + { + $receipt = $this->createReceipt(); - $this->expectException(\InvalidArgumentException::class); + $this->expectException(\InvalidArgumentException::class); - $receipt->setAdditionalCheckProps(123); - } + $receipt->setAdditionalCheckProps(123); + } - public function test_setAdditionalCheckProps_longString_expectLengthException() - { - $receipt = $this->createReceipt(); + public function test_setAdditionalCheckProps_longString_expectLengthException() + { + $receipt = $this->createReceipt(); - $this->expectException(\LengthException::class); + $this->expectException(\LengthException::class); - $receipt->setAdditionalCheckProps('12345678901234567'); - } + $receipt->setAdditionalCheckProps('12345678901234567'); + } - /** - * @return Receipt - */ - private function createReceipt() - { - return new Receipt($this->createMock(Client::class), $this->createMock(Company::class), - [$this->createMock(Item::class)], $this->createMock(Payment::class), - $this->createMock(ReceiptOperationTypes::class)); - } + /** + * @return Receipt + */ + private function createReceipt() + { + return new Receipt($this->createMock(Client::class), $this->createMock(Company::class), + [$this->createMock(Item::class)], $this->createMock(Payment::class), + $this->createMock(ReceiptOperationTypes::class)); + } }