Skip to content

Commit

Permalink
Merge pull request #21 from superbrave/customer-address
Browse files Browse the repository at this point in the history
[IMPROVEMENT] Added address information to the CreateTransactionRequest class
  • Loading branch information
Jelle van Oosterbosch authored Jan 3, 2022
2 parents 6cbee44 + a089f6b commit 3e68515
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
66 changes: 66 additions & 0 deletions src/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,70 @@ public function setTimestamp(DateTimeInterface $timestamp): self
{
return $this->setParameter('timestamp', $timestamp);
}

/**
* Get the city.
*
* @return string
*/
public function getCity(): string
{
return $this->getParameter('city');
}

/**
* Sets the city.
*
* @param string $city
*
* @return self
*/
public function setCity(string $city): self
{
return $this->setParameter('city', $city);
}

/**
* Gets the postal code.
*
* @return string
*/
public function getPostalCode(): string
{
return $this->getParameter('postalCode');
}

/**
* Sets the postal code.
*
* @param string $postalCode
*
* @return self
*/
public function setPostalCode(string $postalCode): self
{
return $this->setParameter('postalCode', $postalCode);
}

/**
* Gets the street.
*
* @return string
*/
public function getStreet(): string
{
return $this->getParameter('street');
}

/**
* Sets the street.
*
* @param string $street
*
* @return self
*/
public function setStreet(string $street): self
{
return $this->setParameter('street', $street);
}
}
11 changes: 11 additions & 0 deletions src/Message/CreateTransactionRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ public function getData(): array
'IssuerCode' => $this->getIssuerCode(),
'AmountInCents' => $this->getAmountInteger(),
'CurrencyCode' => $this->getCurrencyCode(),
'Consumer' => [
'Address' => [
'CareOf' => null,
'City' => $this->getCity(),
'CountryCode' => $this->getCountryCode(),
'HouseNumber' => null,
'PostalCode' => $this->getPostalCode(),
'Street' => $this->getStreet(),
],
'Category' => 'Person',
],
'Timestamp' => $this->getTimestamp()->format(self::TIMESTAMP_FORMAT),
'LanguageCode' => $this->getLanguageCode(),
'CountryCode' => $this->getCountryCode(),
Expand Down
14 changes: 14 additions & 0 deletions tests/Message/CreateTransactionRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public function testGetData(): void
$this->request->setLanguageCode('nl');
$this->request->setCountryCode('NL');
$this->request->setTimestamp(new DateTime('2019-03-09T12:00:00'));
$this->request->setCity('Bree duh');
$this->request->setStreet('Quite 18');
$this->request->setPostalCode('4817 HX');
$this->request->setDescription('2fad9b1b-a2d3-455c-bc29-b79516fd3257-random-uuid-hex');

$expectedData = [
Expand Down Expand Up @@ -78,6 +81,17 @@ public function testGetData(): void
'IssuerCode' => 'ABNAMRO',
'AmountInCents' => 1337,
'CurrencyCode' => 'EUR',
'Consumer' => [
'Address' => [
'CareOf' => null,
'City' => 'Bree duh',
'CountryCode' => 'NL',
'HouseNumber' => null,
'PostalCode' => '4817 HX',
'Street' => 'Quite 18',
],
'Category' => 'Person',
],
'Timestamp' => '2019-03-09T12:00:00Z',
'LanguageCode' => 'nl',
'CountryCode' => 'NL',
Expand Down

0 comments on commit 3e68515

Please sign in to comment.