slevomat /
csob-gateway
| 1 | <?php declare(strict_types = 1); |
||
| 2 | |||
| 3 | namespace SlevomatCsobGateway\Call; |
||
| 4 | |||
| 5 | use DateTimeImmutable; |
||
| 6 | use SlevomatCsobGateway\Api\ApiClient; |
||
| 7 | use SlevomatCsobGateway\Crypto\SignatureDataFormatter; |
||
| 8 | |||
| 9 | class EchoRequest |
||
| 10 | { |
||
| 11 | |||
| 12 | /** @var string */ |
||
| 13 | private $merchantId; |
||
| 14 | |||
| 15 | 2 | public function __construct(string $merchantId) |
|
| 16 | { |
||
| 17 | 2 | $this->merchantId = $merchantId; |
|
| 18 | 2 | } |
|
| 19 | |||
| 20 | 1 | public function send(ApiClient $apiClient): EchoResponse |
|
| 21 | { |
||
| 22 | 1 | $response = $apiClient->get( |
|
| 23 | 1 | 'echo/{merchantId}/{dttm}/{signature}', |
|
| 24 | [ |
||
| 25 | 1 | 'merchantId' => $this->merchantId, |
|
| 26 | ], |
||
| 27 | 1 | new SignatureDataFormatter([ |
|
| 28 | 1 | 'merchantId' => null, |
|
| 29 | 'dttm' => null, |
||
| 30 | ]), |
||
| 31 | 1 | new SignatureDataFormatter([ |
|
| 32 | 1 | 'dttm' => null, |
|
| 33 | 'resultCode' => null, |
||
| 34 | 'resultMessage' => null, |
||
| 35 | ]) |
||
| 36 | ); |
||
| 37 | |||
| 38 | 1 | $data = $response->getData(); |
|
| 39 | |||
| 40 | 1 | return new EchoResponse( |
|
| 41 | 1 | DateTimeImmutable::createFromFormat('YmdHis', $data['dttm']), |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 42 | 1 | ResultCode::get($data['resultCode']), |
|
| 43 | 1 | $data['resultMessage'] |
|
| 44 | ); |
||
| 45 | } |
||
| 46 | |||
| 47 | } |
||
| 48 |