Conditions | 3 |
Paths | 4 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
33 | 3 | public function handle(string $reference) : array |
|
34 | { |
||
35 | 3 | $link = $this->baseUrl . self::TRANSACTION_VERIFICATION . $reference; |
|
36 | |||
37 | 3 | $response = $this->verifyTransaction($link); |
|
38 | |||
39 | 3 | $this->verifyResponse($response); |
|
40 | |||
41 | 2 | $result = json_decode($response->getBody(), true); |
|
42 | |||
43 | 2 | $validated = false; |
|
44 | |||
45 | 2 | if (strcmp($result['message'], self::VERIFIED_TRANSACTION) === 0) { |
|
46 | 1 | $validated = true; |
|
47 | } |
||
48 | |||
49 | 2 | if (false === $validated) { |
|
50 | 1 | throw TransactionVerficationFailedException::createFromResponse($response); |
|
51 | } |
||
52 | |||
53 | 1 | return $result["data"]; |
|
54 | } |
||
55 | |||
66 |