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