From 8bb9fff203ed05b88ddb30bb1c773e7192bbc858 Mon Sep 17 00:00:00 2001 From: Matus Lucenic Date: Wed, 31 Jul 2024 10:14:39 +0200 Subject: [PATCH] Added full name as mandatory data --- src/Request/CreatePayment.php | 29 +++++++++++++++++++++++++++-- test/ClientTest.php | 4 ++-- test/CreatePaymentTest.php | 3 +++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/Request/CreatePayment.php b/src/Request/CreatePayment.php index 997c29b..5aa9ec8 100644 --- a/src/Request/CreatePayment.php +++ b/src/Request/CreatePayment.php @@ -24,6 +24,11 @@ class CreatePayment implements RequestInterface { */ private $email; + /** + * @var string + */ + private $fullName; + /** * @var string */ @@ -108,16 +113,18 @@ class CreatePayment implements RequestInterface { * @param int $price (price in heller so for 10 CZK you must set 1000) * @param string $refId (for example orderId) * @param string $email (email of client to send confirmation) + * @param string $fullName (full name of client to send confirmation) * @param string $label (label of product 1-16 chars) * @param string $method (method of payment to show to customer) * @param string $curr * * @throws LabelTooLongException */ - public function __construct(int $price, string $refId, string $email, string $label, string $method = Method::ALL, string $curr = 'CZK') { + public function __construct(int $price, string $refId, string $email, string $fullName, string $label, string $method = Method::ALL, string $curr = 'CZK') { $this->price = $price; $this->refId = $refId; $this->email = $email; + $this->fullName = $fullName; $this->method = $method; $this->curr = $curr; @@ -188,6 +195,23 @@ public function setEmail(string $email): CreatePayment { } + public function getFullName(): string + { + return $this->fullName; + } + + + /** + * @param string $fullName + * @return CreatePayment + */ + public function setFullName(string $fullName): CreatePayment + { + $this->fullName = $fullName; + + return $this; + } + /** * @return string */ @@ -516,6 +540,7 @@ public function getData() { 'price' => $this->getPrice(), 'refId' => $this->getRefId(), 'email' => $this->getEmail(), + 'fullName' => $this->getFullName(), 'label' => $this->getLabel(), 'method' => $this->getMethod(), 'curr' => $this->getCurr(), @@ -581,4 +606,4 @@ public function getResponseClass() { return CreatePaymentResponse::class; } -} \ No newline at end of file +} diff --git a/test/ClientTest.php b/test/ClientTest.php index b02a77d..c44d7a9 100644 --- a/test/ClientTest.php +++ b/test/ClientTest.php @@ -37,7 +37,7 @@ public function testSend() $guzzleClient = new \GuzzleHttp\Client(['handler' => $handler]); $client->setClient($guzzleClient); - $createPayment = new CreatePayment(1000, '10001', 'test@test.cz', 'Product'); + $createPayment = new CreatePayment(1000, '10001', 'test@test.cz', 'Janko Hrasko', 'Product'); $response = $client->send($createPayment); @@ -62,7 +62,7 @@ public function testSendTooSmallPrice() $guzzleClient = new \GuzzleHttp\Client(['handler' => $handler]); $client->setClient($guzzleClient); - $createPayment = new CreatePayment(1, '10001', 'test@test.cz', 'Product'); + $createPayment = new CreatePayment(1, '10001', 'test@test.cz', 'Janko Hrasko', 'Product'); $this->expectException(ErrorCodeException::class); $this->expectExceptionCode(1107); diff --git a/test/CreatePaymentTest.php b/test/CreatePaymentTest.php index 5c3b688..5e1549a 100644 --- a/test/CreatePaymentTest.php +++ b/test/CreatePaymentTest.php @@ -12,6 +12,7 @@ class CreatePaymentTest extends TestCase const TEST_PRICE = 100; const TEST_REF_ID = '1'; const TEST_EMAIL = 'test@test.cz'; + const FULL_NAME = 'Janko Hrasko'; const TEST_LABEL = 'test'; const TEST_METHOD = 'ALL'; const TEST_CURRENCY = 'CZK'; @@ -26,6 +27,7 @@ private function create() self::TEST_PRICE, self::TEST_REF_ID, self::TEST_EMAIL, + self::FULL_NAME, self::TEST_LABEL, self::TEST_METHOD, self::TEST_CURRENCY @@ -54,6 +56,7 @@ public function test__constructLabelError() self::TEST_PRICE, self::TEST_REF_ID, self::TEST_EMAIL, + self::FULL_NAME, 'soooooooooo-long-text-really-looooooong', self::TEST_METHOD, self::TEST_CURRENCY