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