From cdfd969f9d8cc69f3e8e8bf86e99794b3da15765 Mon Sep 17 00:00:00 2001 From: Luca Gallinari Date: Thu, 5 Sep 2024 17:30:23 +0200 Subject: [PATCH] Add and map pec info --- src/Client/ValueObject/Order.php | 7 ++ src/Mapper/OrderMapper.php | 1 + src/ValueObject/CompanyInfo.php | 6 ++ .../src/Resolver/CompanyInfoResolver.php | 3 +- .../Resolver/DummyCompanyInfoResolver.php | 2 +- tests/Unit/Client/ValueObject/OrderTest.php | 66 +++++++++++++++++++ tests/Unit/Mapper/OrderMapperTest.php | 1 + 7 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 tests/Unit/Client/ValueObject/OrderTest.php diff --git a/src/Client/ValueObject/Order.php b/src/Client/ValueObject/Order.php index 76c5081..15cf832 100644 --- a/src/Client/ValueObject/Order.php +++ b/src/Client/ValueObject/Order.php @@ -22,6 +22,7 @@ public function __construct( private string $buyerInfoName, private string $buyerInfoVatNumber, private string $buyerInfoEmail, + private string $buyerInfoPec, private array $purchasedItems, ) { } @@ -76,6 +77,11 @@ public function getBuyerInfoEmail(): string return $this->buyerInfoEmail; } + public function getBuyerInfoPec(): string + { + return $this->buyerInfoPec; + } + /** * @return OrderItem[] */ @@ -104,6 +110,7 @@ public function toArray(): array 'name' => $this->buyerInfoName, 'vatCode' => $this->buyerInfoVatNumber, 'email' => $this->buyerInfoEmail, + 'pec' => $this->buyerInfoPec, ], 'items' => $items, 'allowSCTPayment' => true, // if PausePay is not available, allow to pay by classic instant Wire Bank? diff --git a/src/Mapper/OrderMapper.php b/src/Mapper/OrderMapper.php index 89d9997..99de9f9 100644 --- a/src/Mapper/OrderMapper.php +++ b/src/Mapper/OrderMapper.php @@ -66,6 +66,7 @@ public function mapFromSyliusPayment(PaymentInterface $payment, string $captureU $companyInfo->getName(), $companyInfo->getVatNumber(), $companyInfo->getEmail(), + $companyInfo->getPec(), $items, ); } diff --git a/src/ValueObject/CompanyInfo.php b/src/ValueObject/CompanyInfo.php index 8d314ce..f0cd48c 100644 --- a/src/ValueObject/CompanyInfo.php +++ b/src/ValueObject/CompanyInfo.php @@ -10,6 +10,7 @@ public function __construct( private string $name, private string $vatNumber, private string $email, + private string $pec, ) { } @@ -27,4 +28,9 @@ public function getEmail(): string { return $this->email; } + + public function getPec(): string + { + return $this->pec; + } } diff --git a/tests/Application/src/Resolver/CompanyInfoResolver.php b/tests/Application/src/Resolver/CompanyInfoResolver.php index 1cc8166..d13fd74 100644 --- a/tests/Application/src/Resolver/CompanyInfoResolver.php +++ b/tests/Application/src/Resolver/CompanyInfoResolver.php @@ -15,7 +15,8 @@ public function resolveFromOrder(OrderInterface $order): CompanyInfo return new CompanyInfo( 'Azienda A', 'IT73228252614', - 'whatever@example.com' + 'whatever@example.com', + 'whatever@example.com', ); } } diff --git a/tests/Service/Resolver/DummyCompanyInfoResolver.php b/tests/Service/Resolver/DummyCompanyInfoResolver.php index 1259e4e..cf1e4fd 100644 --- a/tests/Service/Resolver/DummyCompanyInfoResolver.php +++ b/tests/Service/Resolver/DummyCompanyInfoResolver.php @@ -12,6 +12,6 @@ final class DummyCompanyInfoResolver implements CompanyInfoResolverInterface { public function resolveFromOrder(OrderInterface $order): CompanyInfo { - return new CompanyInfo('Webgriffe SRL', '02277170359', 'support@webgriffe.com'); + return new CompanyInfo('Webgriffe SRL', '02277170359', 'support@webgriffe.com', 'pec@webgriffe.com'); } } diff --git a/tests/Unit/Client/ValueObject/OrderTest.php b/tests/Unit/Client/ValueObject/OrderTest.php new file mode 100644 index 0000000..1f0cb54 --- /dev/null +++ b/tests/Unit/Client/ValueObject/OrderTest.php @@ -0,0 +1,66 @@ + 100.0, + 'number' => '123', + 'issueDate' => '01/09/2024 12:23', + 'description' => 'Description', + 'remittance' => 'Remittance', + 'okRedirect' => 'http://ok.com', + 'koRedirect' => 'http://ko.com', + 'allowToEditRemittance' => false, + 'buyerInfo' => [ + 'name' => 'Buyer Name', + 'vatCode' => 'VAT123', + 'email' => 'support@webgriffe.com', + 'pec' => 'pec@webgriffe.com', + ], + 'items' => [ + [ + 'description' => 'Product 1', + 'quantity' => 1, + 'amount' => 10.0, + ], + [ + 'description' => 'Product 2', + 'quantity' => 2, + 'amount' => 20.0, + ], + ], + 'allowSCTPayment' => true, + ], + $order->toArray() + ); + } +} diff --git a/tests/Unit/Mapper/OrderMapperTest.php b/tests/Unit/Mapper/OrderMapperTest.php index 14611b0..cc81114 100644 --- a/tests/Unit/Mapper/OrderMapperTest.php +++ b/tests/Unit/Mapper/OrderMapperTest.php @@ -57,6 +57,7 @@ public function test_it_maps_sylius_payment_to_pausepay_order(): void self::assertSame('Webgriffe SRL', $pausePayOrder->getBuyerInfoName()); self::assertSame('02277170359', $pausePayOrder->getBuyerInfoVatNumber()); self::assertSame('support@webgriffe.com', $pausePayOrder->getBuyerInfoEmail()); + self::assertSame('pec@webgriffe.com', $pausePayOrder->getBuyerInfoPec()); $items = $pausePayOrder->getPurchasedItems(); self::assertCount(3, $items);