diff --git a/CHANGELOG.md b/CHANGELOG.md index f289323..b89431d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Added support for EBICS version 2.4. * Added option to specify custom PDF Factory. * Changed pdf generator to FPDF. +* Add methods `XEK` order type for EBICS 3.0 ## 2.1 diff --git a/Makefile b/Makefile index 93c6067..001a3d3 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ endif docker-up u: cd docker && docker-compose -p ebics-client-php up -d; - @if [ "$(WIN_ETH_IP)" ]; then echo "OK" && cd docker && docker-compose -p ebics-client-php exec php-cli-ebics-client-php sh -c "echo '$(WIN_ETH_IP) host.docker.internal' >> /etc/hosts"; fi + @if [ "$(WIN_ETH_IP)" ]; then cd docker && docker-compose -p ebics-client-php exec php-cli-ebics-client-php sh -c "echo '$(WIN_ETH_IP) host.docker.internal' >> /etc/hosts"; fi docker-down d: cd docker && docker-compose -p ebics-client-php down diff --git a/README.md b/README.md index 11aa026..7e41f3e 100644 --- a/README.md +++ b/README.md @@ -189,6 +189,7 @@ try { | Z53 | Download the bank account statement in Camt.053 format (i.e Switzerland financial services). | | Z54 | Download the bank account statement in Camt.054 format (i.e available in Switzerland). | | ZSR | Download Order/Payment Status report. | +| XEK | Download account information as PDF-file. | | CCT | Upload initiation of the credit transfer per Single Euro Payments Area. | | CIP | Upload initiation of the instant credit transfer per Single Euro Payments Area. | | XE2 | Upload initiation of the Swiss credit transfer (i.e available in Switzerland). | diff --git a/src/Contracts/EbicsClientInterface.php b/src/Contracts/EbicsClientInterface.php index 4d16dcf..19e97df 100644 --- a/src/Contracts/EbicsClientInterface.php +++ b/src/Contracts/EbicsClientInterface.php @@ -306,6 +306,10 @@ public function Z54( * Download Order/Payment Status report. * OrderType:BTD, Service Name:PSR, Scope:BIL, Container:ZIP, MsgName:pain.002 * + * @param DateTimeInterface|null $dateTime + * @param DateTimeInterface|null $startDateTime + * @param DateTimeInterface|null $endDateTime + * * @return DownloadOrderResult */ public function ZSR( @@ -314,6 +318,20 @@ public function ZSR( DateTimeInterface $endDateTime = null ): DownloadOrderResult; + /** + * Download account information as PDF-file. + * @param DateTimeInterface|null $dateTime + * @param DateTimeInterface|null $startDateTime + * @param DateTimeInterface|null $endDateTime + * + * @return DownloadOrderResult + */ + public function XEK( + DateTimeInterface $dateTime = null, + DateTimeInterface $startDateTime = null, + DateTimeInterface $endDateTime = null + ): DownloadOrderResult; + /** * Download subscriber's customer and subscriber information. * diff --git a/src/EbicsClient.php b/src/EbicsClient.php index dfbb8ec..1461b5a 100644 --- a/src/EbicsClient.php +++ b/src/EbicsClient.php @@ -686,6 +686,34 @@ function ($segmentNumber, $isLastSegment) use ($dateTime, $startDateTime, $endDa return $this->createDownloadOrderResult($transaction, self::FILE_PARSER_FORMAT_ZIP_FILES); } + /** + * @inheritDoc + * @throws Exceptions\EbicsException + */ + public function XEK( + DateTimeInterface $dateTime = null, + DateTimeInterface $startDateTime = null, + DateTimeInterface $endDateTime = null + ): DownloadOrderResult { + if (null === $dateTime) { + $dateTime = new DateTime(); + } + + $transaction = $this->downloadTransaction( + function ($segmentNumber, $isLastSegment) use ($dateTime, $startDateTime, $endDateTime) { + return $this->requestFactory->createXEK( + $dateTime, + $startDateTime, + $endDateTime, + $segmentNumber, + $isLastSegment + ); + } + ); + + return $this->createDownloadOrderResult($transaction, self::FILE_PARSER_FORMAT_ZIP_FILES); + } + /** * @inheritDoc * @throws Exceptions\EbicsException diff --git a/src/Factories/RequestFactory.php b/src/Factories/RequestFactory.php index f43d4b6..4bad9f8 100644 --- a/src/Factories/RequestFactory.php +++ b/src/Factories/RequestFactory.php @@ -856,6 +856,14 @@ abstract public function createZSR( bool $isLastSegment = null ): Request; + abstract public function createXEK( + DateTimeInterface $dateTime, + DateTimeInterface $startDateTime = null, + DateTimeInterface $endDateTime = null, + int $segmentNumber = null, + bool $isLastSegment = null + ): Request; + abstract public function createCCT( DateTimeInterface $dateTime, UploadTransaction $transaction, diff --git a/src/Factories/RequestFactoryV24.php b/src/Factories/RequestFactoryV24.php index 2d108dd..362236e 100644 --- a/src/Factories/RequestFactoryV24.php +++ b/src/Factories/RequestFactoryV24.php @@ -158,6 +158,16 @@ public function createZSR( throw new LogicException('Method not implemented yet for EBICS 2.4'); } + public function createXEK( + DateTimeInterface $dateTime, + DateTimeInterface $startDateTime = null, + DateTimeInterface $endDateTime = null, + int $segmentNumber = null, + bool $isLastSegment = null + ): Request { + throw new LogicException('Method not implemented yet for EBICS 2.4'); + } + public function createCCT(DateTimeInterface $dateTime, UploadTransaction $transaction, bool $withES): Request { throw new LogicException('Method not implemented yet for EBICS 2.4'); diff --git a/src/Factories/RequestFactoryV25.php b/src/Factories/RequestFactoryV25.php index 731b35e..f3f8453 100644 --- a/src/Factories/RequestFactoryV25.php +++ b/src/Factories/RequestFactoryV25.php @@ -557,6 +557,16 @@ public function createZSR( throw new LogicException('Method not implemented yet for EBICS 2.5'); } + public function createXEK( + DateTimeInterface $dateTime, + DateTimeInterface $startDateTime = null, + DateTimeInterface $endDateTime = null, + int $segmentNumber = null, + bool $isLastSegment = null + ): Request { + throw new LogicException('Method not implemented yet for EBICS 2.5'); + } + /** * @throws EbicsException */ diff --git a/src/Factories/RequestFactoryV3.php b/src/Factories/RequestFactoryV3.php index bd97e0e..a606830 100644 --- a/src/Factories/RequestFactoryV3.php +++ b/src/Factories/RequestFactoryV3.php @@ -317,6 +317,25 @@ public function createZSR( return $this->createBTD($dateTime, $btfContext, $startDateTime, $endDateTime, $segmentNumber, $isLastSegment); } + /** + * @throws EbicsException + */ + public function createXEK( + DateTimeInterface $dateTime, + DateTimeInterface $startDateTime = null, + DateTimeInterface $endDateTime = null, + int $segmentNumber = null, + bool $isLastSegment = null + ): Request { + $btfContext = new BTDContext(); + $btfContext->setServiceName('EOP'); + $btfContext->setScope('AT'); + $btfContext->setMsgName('pdf'); + $btfContext->setContainerType('ZIP'); + + return $this->createBTD($dateTime, $btfContext, $startDateTime, $endDateTime, $segmentNumber, $isLastSegment); + } + public function createCCT(DateTimeInterface $dateTime, UploadTransaction $transaction, bool $withES): Request { throw new LogicException('Method not implemented yet for EBICS 3.0'); diff --git a/tests/EbicsClientV3Test.php b/tests/EbicsClientV3Test.php index 1506bf3..f31d7d0 100644 --- a/tests/EbicsClientV3Test.php +++ b/tests/EbicsClientV3Test.php @@ -405,6 +405,37 @@ public function testZSR(int $credentialsId, array $codes, X509GeneratorInterface $this->assertResponseDone($code, $reportText); } + /** + * @dataProvider serversDataProvider + * + * @group XEK + * @group V3 + * @group XEK-V3 + * + * @param int $credentialsId + * @param array $codes + * @param X509GeneratorInterface|null $x509Generator + * + * @covers + */ + public function testXEK(int $credentialsId, array $codes, X509GeneratorInterface $x509Generator = null) + { + $client = $this->setupClientV3($credentialsId, $x509Generator, $codes['XEK']['fake']); + + $this->assertExceptionCode($codes['XEK']['code']); + $xek = $client->XEK(null, new DateTime('2020-03-21'), new DateTime('2020-04-21')); + + $responseHandler = $client->getResponseHandler(); + $code = $responseHandler->retrieveH00XReturnCode($xek->getTransaction()->getLastSegment()->getResponse()); + $reportText = $responseHandler->retrieveH00XReportText($xek->getTransaction()->getLastSegment()->getResponse()); + $this->assertResponseOk($code, $reportText); + + $code = $responseHandler->retrieveH00XReturnCode($xek->getTransaction()->getReceipt()); + $reportText = $responseHandler->retrieveH00XReportText($xek->getTransaction()->getReceipt()); + + $this->assertResponseDone($code, $reportText); + } + /** * @dataProvider serversDataProvider * @@ -733,6 +764,7 @@ public function serversDataProvider() 'PTK' => ['code' => null, 'fake' => false], 'Z54' => ['code' => '091005', 'fake' => false], 'ZSR' => ['code' => '091005', 'fake' => false], + 'XEK' => ['code' => '091005', 'fake' => false], 'BTU' => ['code' => null, 'fake' => false], 'XE3' => ['code' => null, 'fake' => false], 'YCT' => ['code' => '091005', 'fake' => false], @@ -758,6 +790,7 @@ public function serversDataProvider() 'PTK' => ['code' => null, 'fake' => false], 'Z54' => ['code' => '090005', 'fake' => false], 'ZSR' => ['code' => '091005', 'fake' => false], + 'XEK' => ['code' => '091005', 'fake' => false], 'BTU' => ['code' => null, 'fake' => false], 'XE3' => ['code' => null, 'fake' => false], 'YCT' => ['code' => '091005', 'fake' => false],