Skip to content

Commit 3e68515

Browse files
author
Jelle van Oosterbosch
authored
Merge pull request #21 from superbrave/customer-address
[IMPROVEMENT] Added address information to the CreateTransactionRequest class
2 parents 6cbee44 + a089f6b commit 3e68515

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed

src/Message/AbstractRequest.php

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,4 +323,70 @@ public function setTimestamp(DateTimeInterface $timestamp): self
323323
{
324324
return $this->setParameter('timestamp', $timestamp);
325325
}
326+
327+
/**
328+
* Get the city.
329+
*
330+
* @return string
331+
*/
332+
public function getCity(): string
333+
{
334+
return $this->getParameter('city');
335+
}
336+
337+
/**
338+
* Sets the city.
339+
*
340+
* @param string $city
341+
*
342+
* @return self
343+
*/
344+
public function setCity(string $city): self
345+
{
346+
return $this->setParameter('city', $city);
347+
}
348+
349+
/**
350+
* Gets the postal code.
351+
*
352+
* @return string
353+
*/
354+
public function getPostalCode(): string
355+
{
356+
return $this->getParameter('postalCode');
357+
}
358+
359+
/**
360+
* Sets the postal code.
361+
*
362+
* @param string $postalCode
363+
*
364+
* @return self
365+
*/
366+
public function setPostalCode(string $postalCode): self
367+
{
368+
return $this->setParameter('postalCode', $postalCode);
369+
}
370+
371+
/**
372+
* Gets the street.
373+
*
374+
* @return string
375+
*/
376+
public function getStreet(): string
377+
{
378+
return $this->getParameter('street');
379+
}
380+
381+
/**
382+
* Sets the street.
383+
*
384+
* @param string $street
385+
*
386+
* @return self
387+
*/
388+
public function setStreet(string $street): self
389+
{
390+
return $this->setParameter('street', $street);
391+
}
326392
}

src/Message/CreateTransactionRequest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ public function getData(): array
4444
'IssuerCode' => $this->getIssuerCode(),
4545
'AmountInCents' => $this->getAmountInteger(),
4646
'CurrencyCode' => $this->getCurrencyCode(),
47+
'Consumer' => [
48+
'Address' => [
49+
'CareOf' => null,
50+
'City' => $this->getCity(),
51+
'CountryCode' => $this->getCountryCode(),
52+
'HouseNumber' => null,
53+
'PostalCode' => $this->getPostalCode(),
54+
'Street' => $this->getStreet(),
55+
],
56+
'Category' => 'Person',
57+
],
4758
'Timestamp' => $this->getTimestamp()->format(self::TIMESTAMP_FORMAT),
4859
'LanguageCode' => $this->getLanguageCode(),
4960
'CountryCode' => $this->getCountryCode(),

tests/Message/CreateTransactionRequestTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public function testGetData(): void
4949
$this->request->setLanguageCode('nl');
5050
$this->request->setCountryCode('NL');
5151
$this->request->setTimestamp(new DateTime('2019-03-09T12:00:00'));
52+
$this->request->setCity('Bree duh');
53+
$this->request->setStreet('Quite 18');
54+
$this->request->setPostalCode('4817 HX');
5255
$this->request->setDescription('2fad9b1b-a2d3-455c-bc29-b79516fd3257-random-uuid-hex');
5356

5457
$expectedData = [
@@ -78,6 +81,17 @@ public function testGetData(): void
7881
'IssuerCode' => 'ABNAMRO',
7982
'AmountInCents' => 1337,
8083
'CurrencyCode' => 'EUR',
84+
'Consumer' => [
85+
'Address' => [
86+
'CareOf' => null,
87+
'City' => 'Bree duh',
88+
'CountryCode' => 'NL',
89+
'HouseNumber' => null,
90+
'PostalCode' => '4817 HX',
91+
'Street' => 'Quite 18',
92+
],
93+
'Category' => 'Person',
94+
],
8195
'Timestamp' => '2019-03-09T12:00:00Z',
8296
'LanguageCode' => 'nl',
8397
'CountryCode' => 'NL',

0 commit comments

Comments
 (0)