-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
253 additions
and
377 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea | ||
vendor | ||
tools | ||
test.php | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
parameters: | ||
ignoreErrors: [] | ||
ignoreErrors: | ||
- | ||
message: "#^Property IPay\\\\Builders\\\\TransactionBuilder\\:\\:\\$resolver is never written, only read\\.$#" | ||
count: 1 | ||
path: src/Builders/TransactionBuilder.php |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace IPay\Builders; | ||
|
||
use IPay\Encryption\Encryptor; | ||
use Nette\Utils\Json; | ||
use Nette\Utils\Random; | ||
|
||
/** | ||
* @psalm-type ValueType = string|int | ||
* @psalm-type ParametersType = array<string, ValueType> | ||
*/ | ||
final class BodyBuilder implements \Stringable, \JsonSerializable | ||
{ | ||
/** | ||
* @param ParametersType $parameters | ||
*/ | ||
public function __construct( | ||
private array $parameters = [], | ||
) { | ||
} | ||
|
||
public function setSessionId(string $value): void | ||
{ | ||
$this->parameters['sessionId'] = $value; | ||
} | ||
|
||
/** | ||
* @param ParametersType $parameters | ||
*/ | ||
public function build(array $parameters = []): self | ||
{ | ||
$data = array_merge([ | ||
'lang' => 'en', | ||
'requestId' => Random::generate(12, '0-9A-Z').'|'.time(), | ||
], $this->parameters, $parameters); | ||
ksort($data); | ||
$data['signature'] = md5(http_build_query($data)); | ||
|
||
return new self($data); | ||
} | ||
|
||
public function encrypt(): string | ||
{ | ||
return new self(['encrypted' => Encryptor::encrypt($this)]); | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return Json::encode($this->parameters); | ||
} | ||
|
||
#[\ReturnTypeWillChange] | ||
public function jsonSerialize() | ||
{ | ||
return $this->parameters; | ||
} | ||
} |
Oops, something went wrong.