Conditions | 3 |
Paths | 2 |
Total Lines | 39 |
Code Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Tests | 19 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types = 1); |
||
35 | 1 | public function send(ApiClient $apiClient): PaymentResponse |
|
36 | { |
||
37 | $data = [ |
||
38 | 1 | 'merchantId' => $this->merchantId, |
|
39 | 1 | 'payId' => $this->payId, |
|
40 | ]; |
||
41 | |||
42 | 1 | if ($this->totalAmount !== null) { |
|
43 | 1 | $data['totalAmount'] = $this->totalAmount; |
|
44 | } |
||
45 | |||
46 | 1 | $response = $apiClient->put( |
|
47 | 1 | 'payment/close', |
|
48 | $data, |
||
49 | 1 | new SignatureDataFormatter([ |
|
50 | 1 | 'merchantId' => null, |
|
51 | 'payId' => null, |
||
52 | 'dttm' => null, |
||
53 | 'totalAmount' => null, |
||
54 | ]), |
||
55 | 1 | new SignatureDataFormatter([ |
|
56 | 1 | 'payId' => null, |
|
57 | 'dttm' => null, |
||
58 | 'resultCode' => null, |
||
59 | 'resultMessage' => null, |
||
60 | 'paymentStatus' => null, |
||
61 | 'authCode' => null, |
||
62 | ]) |
||
63 | ); |
||
64 | |||
65 | 1 | $data = $response->getData(); |
|
66 | |||
67 | 1 | return new PaymentResponse( |
|
68 | 1 | $data['payId'], |
|
69 | 1 | DateTimeImmutable::createFromFormat('YmdHis', $data['dttm']), |
|
|
|||
70 | 1 | ResultCode::get($data['resultCode']), |
|
71 | 1 | $data['resultMessage'], |
|
72 | 1 | isset($data['paymentStatus']) ? PaymentStatus::get($data['paymentStatus']) : null, |
|
73 | 1 | $data['authCode'] ?? null |
|
74 | ); |
||
78 |