| Conditions | 7 |
| Paths | 4 |
| Total Lines | 32 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types = 1); |
||
| 12 | public function send(ApiClient $apiClient, array $data): PaymentResponse |
||
| 13 | { |
||
| 14 | if (array_key_exists('resultCode', $data) && is_numeric($data['resultCode'])) { |
||
| 15 | $data['resultCode'] = (int) $data['resultCode']; |
||
| 16 | } |
||
| 17 | |||
| 18 | if (array_key_exists('paymentStatus', $data) && is_numeric($data['paymentStatus'])) { |
||
| 19 | $data['paymentStatus'] = (int) $data['paymentStatus']; |
||
| 20 | } |
||
| 21 | |||
| 22 | $response = $apiClient->createResponseByData($data, new SignatureDataFormatter([ |
||
| 23 | 'payId' => null, |
||
| 24 | 'dttm' => null, |
||
| 25 | 'resultCode' => null, |
||
| 26 | 'resultMessage' => null, |
||
| 27 | 'paymentStatus' => null, |
||
| 28 | 'authCode' => null, |
||
| 29 | 'merchantData' => null, |
||
| 30 | ])); |
||
| 31 | |||
| 32 | $data = $response->getData(); |
||
| 33 | |||
| 34 | return new PaymentResponse( |
||
| 35 | $data['payId'], |
||
| 36 | DateTimeImmutable::createFromFormat('YmdHis', $data['dttm']), |
||
| 37 | new ResultCode($data['resultCode']), |
||
| 38 | $data['resultMessage'], |
||
| 39 | isset($data['paymentStatus']) ? new PaymentStatus($data['paymentStatus']) : null, |
||
| 40 | $data['authCode'] ?? null, |
||
| 41 | isset($data['merchantData']) ? base64_decode($data['merchantData']) : null |
||
| 42 | ); |
||
| 43 | } |
||
| 44 | |||
| 46 |