Skip to content

Commit 92780a6

Browse files
committed
Add optional attributes to BTF and Static. Update Timestamp.
1 parent b12f61a commit 92780a6

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ abstract class BTFContext extends ServiceContext
1212
{
1313
private bool $signatureFlag = false;
1414
private bool $signatureFlagEds = false;
15+
private array $parameters = [];
1516

1617
public function setSignatureFlag(bool $signatureFlag): self
1718
{
@@ -36,4 +37,16 @@ public function getSignatureFlagEds(): bool
3637
{
3738
return $this->signatureFlagEds;
3839
}
40+
41+
public function setParameter(string $name, string $value): self
42+
{
43+
$this->parameters[$name] = $value;
44+
45+
return $this;
46+
}
47+
48+
public function getParameters(): array
49+
{
50+
return $this->parameters;
51+
}
3952
}

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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ private function buildRequest(): Request
120120
->addDataDigest(
121121
$this->context->getSignatureVersion(),
122122
$this->context->getDataDigest()
123-
)
124-
->addAdditionalOrderInfo();
123+
);
125124
});
126125
});
127126
})
@@ -171,5 +170,7 @@ private function addBTUOrderParams(OrderDetailsBuilder $orderDetailsBuilder): vo
171170
$xmlSignatureFlag->setAttribute('requestEDS', 'true');
172171
}
173172
}
173+
174+
$orderDetailsBuilder->addParameters($xmlBTUOrderParams, $this->btuContext->getParameters());
174175
}
175176
}

0 commit comments

Comments
 (0)