Skip to content

Commit 681df97

Browse files
committed
Update EDS logic. Update Timestamp format. Added SystemID support. Added Parameter to BTF. Added HAC order type. Fix Upload orders Digests.
1 parent b12f61a commit 681df97

19 files changed

Lines changed: 243 additions & 60 deletions

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Setup PHP
3939
uses: shivammathur/setup-php@v2
4040
with:
41-
php-version: '7.4'
41+
php-version: '8.1'
4242
- name: Composer Install
4343
run: composer install --no-scripts --no-progress --ansi
4444
- name: Run phpstan
@@ -60,7 +60,7 @@ jobs:
6060
- name: Setup PHP
6161
uses: shivammathur/setup-php@v2
6262
with:
63-
php-version: '7.4'
63+
php-version: '8.1'
6464
- name: Composer Install
6565
run: composer install --no-scripts --no-progress --ansi
6666
- name: Run phpcs
@@ -82,7 +82,7 @@ jobs:
8282
- name: Setup PHP
8383
uses: shivammathur/setup-php@v2
8484
with:
85-
php-version: '7.4'
85+
php-version: '8.1'
8686
- name: Composer Install
8787
run: composer install --no-scripts --no-progress --ansi
8888
- name: Prepare data

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
* Updated custom keyring details.
44
* Dynamic Orders.
5+
* Updated EDS logic.
6+
* Updated `Timestamp` format.
7+
* Added `SystemID` support.
8+
* Added `Parameter` to BTF.
9+
* Added `HAC` order type.
10+
* Fix Upload orders Digest.
511

612
## 2.5
713

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ try {
157157
| HKD | Download customer's customer and subscriber information. |
158158
| HTD | Download subscriber's customer and subscriber information. |
159159
| HAA | Download Bank available order types. |
160-
| PTK | Download transaction status. |
160+
| PTK | Download transaction status (Plain text). |
161+
| HAC | Download transaction status (XML). |
161162
| FDL | Download the files from the bank. |
162163
| FUL | Upload the files to the bank. |
163164
| BTD | Download request files of any BTF structure. |

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
],
2222
"license": "MIT",
2323
"require": {
24-
"php": "^7.4 || ^8",
24+
"php": "^8.1",
2525
"ext-bcmath": "*",
2626
"ext-curl": "*",
2727
"ext-dom": "*",
@@ -34,13 +34,13 @@
3434
"require-dev": {
3535
"ebics-api/cfonb-php": "^1.0",
3636
"ebics-api/mt942-php": "^1.0",
37-
"phpseclib/phpseclib": "~2.0.35",
38-
"phpstan/phpstan": "~1.9.17",
39-
"phpunit/phpunit": "~9.6.3",
37+
"phpseclib/phpseclib": "~2.0.48",
38+
"phpstan/phpstan": "~1.9.18",
39+
"phpunit/phpunit": "~9.6.24",
4040
"psr/http-client": "^1.0",
4141
"psr/http-factory": "^1.0",
4242
"setasign/fpdf": "^1.8",
43-
"squizlabs/php_codesniffer": "~3.7.1"
43+
"squizlabs/php_codesniffer": "~3.7.2"
4444
},
4545
"autoload": {
4646
"psr-4": {

src/Builders/Request/DataEncryptionInfoBuilder.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,15 @@ public function addEncryptionPubKeyDigest(Keyring $keyring, string $algorithm =
5151
if (!($signatureE = $keyring->getBankSignatureE())) {
5252
throw new SignatureEbicsException('Bank Certificate E is empty.');
5353
}
54-
$certificateEDigest = $this->cryptService->calculateDigest($signatureE, $algorithm);
54+
55+
if ($signatureE->getCertificateContent()) {
56+
$certificateEDigest = $this->cryptService->calculateCertificateFingerprint(
57+
$signatureE->getCertificateContent(),
58+
$algorithm
59+
);
60+
} else {
61+
$certificateEDigest = $this->cryptService->calculatePublicKeyDigest($signatureE, $algorithm);
62+
}
5563
$encryptionPubKeyDigestNodeValue = base64_encode($certificateEDigest);
5664

5765
$this->appendElementTo('EncryptionPubKeyDigest', $encryptionPubKeyDigestNodeValue, $this->instance, [

src/Builders/Request/StaticBuilder.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ public function addRandomNonce(): StaticBuilder
5151

5252
public function addTimestamp(DateTimeInterface $dateTime): StaticBuilder
5353
{
54-
$this->appendElementTo('Timestamp', $dateTime->format('Y-m-d\TH:i:s\Z'), $this->instance);
54+
$milliseconds = (int)($dateTime->format('u') / 1000);
55+
56+
$formatted = $dateTime->format('Y-m-d\TH:i:s') . sprintf('.%03dZ', $milliseconds);
57+
58+
$this->appendElementTo('Timestamp', $formatted, $this->instance);
5559

5660
return $this;
5761
}
@@ -70,6 +74,13 @@ public function addUserId(string $userId): StaticBuilder
7074
return $this;
7175
}
7276

77+
public function addSystemId(string $systemId): StaticBuilder
78+
{
79+
$this->appendElementTo('SystemID', $systemId, $this->instance);
80+
81+
return $this;
82+
}
83+
7384
public function addProduct(string $product, string $language): StaticBuilder
7485
{
7586
$this->appendElementTo('Product', $product, $this->instance, ['Language' => $language]);

src/Contexts/BTFContext.php

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,17 @@
1010
*/
1111
abstract class BTFContext extends ServiceContext
1212
{
13-
private bool $signatureFlag = false;
14-
private bool $signatureFlagEds = false;
13+
private array $parameters = [];
1514

16-
public function setSignatureFlag(bool $signatureFlag): self
15+
public function setParameter(string $name, string $value): self
1716
{
18-
$this->signatureFlag = $signatureFlag;
17+
$this->parameters[$name] = $value;
1918

2019
return $this;
2120
}
2221

23-
public function getSignatureFlag(): bool
22+
public function getParameters(): array
2423
{
25-
return $this->signatureFlag;
26-
}
27-
28-
public function setSignatureFlagEds(bool $signatureFlagEds): self
29-
{
30-
$this->signatureFlagEds = $signatureFlagEds;
31-
32-
return $this;
33-
}
34-
35-
public function getSignatureFlagEds(): bool
36-
{
37-
return $this->signatureFlagEds;
24+
return $this->parameters;
3825
}
3926
}

src/Handlers/OrderDataHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ abstract public function retrieveAuthenticationSignature(XmlDocument $document):
148148
*/
149149
abstract public function retrieveEncryptionSignature(XmlDocument $document): SignatureInterface;
150150

151-
public function hash(XmlData $xml): string
151+
public function hash(string $content): string
152152
{
153-
return $this->cryptService->hash($xml->getContent());
153+
return $this->cryptService->hash($content);
154154
}
155155
}

src/Orders/BTD.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,5 +168,7 @@ private function addBTDOrderParams(
168168
);
169169
$xmlBTDOrderParams->appendChild($xmlDateRange);
170170
}
171+
172+
$orderDetailsBuilder->addParameters($xmlBTDOrderParams, $this->btdContext->getParameters());
171173
}
172174
}

src/Orders/BTU.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ private function buildRequest(): Request
5959
$this->userSignatureHandler->handle($signatureData, $this->transaction->getDigest());
6060

6161
$signatureVersion = $this->context->getKeyring()->getUserSignatureAVersion();
62-
$dataDigest = $this->requestFactory->userSignA(
63-
$this->transaction->getDigest()
64-
);
62+
$dataDigest = $this->orderDataHandler->hash($this->orderData->getContent());
6563

6664
$this->context
6765
->setOrderType('BTU')
@@ -117,11 +115,7 @@ private function buildRequest(): Request
117115
);
118116
})
119117
->addSignatureData($this->context->getSignatureData(), $this->context->getTransactionKey())
120-
->addDataDigest(
121-
$this->context->getSignatureVersion(),
122-
$this->context->getDataDigest()
123-
)
124-
->addAdditionalOrderInfo();
118+
->addDataDigest($this->context->getSignatureVersion(), $this->context->getDataDigest());
125119
});
126120
});
127121
})
@@ -164,12 +158,12 @@ private function addBTUOrderParams(OrderDetailsBuilder $orderDetailsBuilder): vo
164158
$xmlMsgName->setAttribute('format', $this->btuContext->getMsgNameFormat());
165159
}
166160

167-
if (true === $this->btuContext->getSignatureFlag()) {
161+
if ($this->context->getWithES()) {
168162
$xmlSignatureFlag = $orderDetailsBuilder->appendEmptyElementTo('SignatureFlag', $xmlBTUOrderParams);
169163

170-
if (true === $this->btuContext->getSignatureFlagEds()) {
171-
$xmlSignatureFlag->setAttribute('requestEDS', 'true');
172-
}
164+
$xmlSignatureFlag->setAttribute('requestEDS', 'true');
173165
}
166+
167+
$orderDetailsBuilder->addParameters($xmlBTUOrderParams, $this->btuContext->getParameters());
174168
}
175169
}

0 commit comments

Comments
 (0)