Skip to content

Commit

Permalink
Merge pull request #5 from matuslucenic/add_new_parameters
Browse files Browse the repository at this point in the history
Added full name as mandatory data
  • Loading branch information
renat-magadiev authored Jul 31, 2024
2 parents 88b6194 + 8bb9fff commit 01c1f39
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
29 changes: 27 additions & 2 deletions src/Request/CreatePayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class CreatePayment implements RequestInterface {
*/
private $email;

/**
* @var string
*/
private $fullName;

/**
* @var string
*/
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -581,4 +606,4 @@ public function getResponseClass() {
return CreatePaymentResponse::class;
}

}
}
4 changes: 2 additions & 2 deletions test/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testSend()
$guzzleClient = new \GuzzleHttp\Client(['handler' => $handler]);
$client->setClient($guzzleClient);

$createPayment = new CreatePayment(1000, '10001', '[email protected]', 'Product');
$createPayment = new CreatePayment(1000, '10001', '[email protected]', 'Janko Hrasko', 'Product');

$response = $client->send($createPayment);

Expand All @@ -62,7 +62,7 @@ public function testSendTooSmallPrice()
$guzzleClient = new \GuzzleHttp\Client(['handler' => $handler]);
$client->setClient($guzzleClient);

$createPayment = new CreatePayment(1, '10001', '[email protected]', 'Product');
$createPayment = new CreatePayment(1, '10001', '[email protected]', 'Janko Hrasko', 'Product');

$this->expectException(ErrorCodeException::class);
$this->expectExceptionCode(1107);
Expand Down
3 changes: 3 additions & 0 deletions test/CreatePaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class CreatePaymentTest extends TestCase
const TEST_PRICE = 100;
const TEST_REF_ID = '1';
const TEST_EMAIL = '[email protected]';
const FULL_NAME = 'Janko Hrasko';
const TEST_LABEL = 'test';
const TEST_METHOD = 'ALL';
const TEST_CURRENCY = 'CZK';
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 01c1f39

Please sign in to comment.