Skip to content

Commit

Permalink
Add order type XEK.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-svirin committed Oct 2, 2024
1 parent f00f4aa commit ffea861
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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). |
Expand Down
18 changes: 18 additions & 0 deletions src/Contracts/EbicsClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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.
*
Expand Down
28 changes: 28 additions & 0 deletions src/EbicsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/Factories/RequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions src/Factories/RequestFactoryV24.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
10 changes: 10 additions & 0 deletions src/Factories/RequestFactoryV25.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
19 changes: 19 additions & 0 deletions src/Factories/RequestFactoryV3.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
33 changes: 33 additions & 0 deletions tests/EbicsClientV3Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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],
Expand All @@ -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],
Expand Down

0 comments on commit ffea861

Please sign in to comment.