1 | <?php |
||
2 | |||
3 | namespace HopekellDev\Payvessel\Helpers; |
||
4 | |||
5 | use Illuminate\Support\Facades\Http; |
||
0 ignored issues
–
show
|
|||
6 | |||
7 | /** |
||
8 | * Payvessel Virtual Account Handler |
||
9 | * |
||
10 | * Handles virtual account operations with Payvessel API |
||
11 | * |
||
12 | * @author Hope Ezenwa |
||
13 | * @version 1.0.0 |
||
14 | */ |
||
15 | class VirtualAccount |
||
16 | { |
||
17 | protected string $apiKey; |
||
18 | protected string $apiSecret; |
||
19 | protected string $baseUrl; |
||
20 | protected string $businessId; |
||
21 | |||
22 | public function __construct(string $apiKey, string $apiSecret, string $baseUrl, string $businessId) |
||
23 | { |
||
24 | $this->apiKey = $apiKey; |
||
25 | $this->apiSecret = $apiSecret; |
||
26 | $this->baseUrl = rtrim($baseUrl, '/'); |
||
27 | $this->businessId = $businessId; |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * Returns the HTTP client with default headers |
||
32 | */ |
||
33 | protected function httpClient() |
||
34 | { |
||
35 | return Http::withHeaders([ |
||
36 | 'api-key' => $this->apiKey, |
||
37 | 'api-secret' => "Bearer {$this->apiSecret}", |
||
38 | 'Content-Type' => 'application/json', |
||
39 | ]); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Create a Virtual Bank Account |
||
44 | * |
||
45 | * @param array $payload |
||
46 | * @return array |
||
47 | * @throws \InvalidArgumentException |
||
48 | */ |
||
49 | public function createVirtualAccount(array $payload): array |
||
50 | { |
||
51 | if ((!isset($payload['bvn']) && !isset($payload['nin'])) || (isset($payload['bvn']) && isset($payload['nin']))) { |
||
52 | throw new \InvalidArgumentException('Either "bvn" or "nin" must be provided, but not both.'); |
||
53 | } |
||
54 | |||
55 | $response = $this->httpClient()->post( |
||
56 | "{$this->baseUrl}/pms/api/external/request/customerReservedAccount/", |
||
57 | array_merge($payload, [ |
||
58 | 'businessid' => $this->businessId, |
||
59 | ]) |
||
60 | ); |
||
61 | |||
62 | return $response->json(); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Get Single Virtual Account Details |
||
67 | * |
||
68 | * @param string|int $account |
||
69 | * @return array |
||
70 | */ |
||
71 | public function getSingleVirtualAccount(string|int $account): array |
||
72 | { |
||
73 | $response = $this->httpClient()->get( |
||
74 | "{$this->baseUrl}/pms/api/external/request/virtual-account/{$this->businessId}/{$account}/" |
||
75 | ); |
||
76 | |||
77 | return $response->json(); |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * Update Virtual Account BVN |
||
82 | * |
||
83 | * @param string|int $account |
||
84 | * @param string|int $bvn |
||
85 | * @return array |
||
86 | */ |
||
87 | public function accountBVNUpdate(string|int $account, string|int $bvn): array |
||
88 | { |
||
89 | $response = $this->httpClient()->post( |
||
90 | "{$this->baseUrl}/pms/api/external/request/virtual-account/{$this->businessId}/{$account}/", |
||
91 | ['bvn' => $bvn] |
||
92 | ); |
||
93 | |||
94 | return $response->json(); |
||
95 | } |
||
96 | } |
||
97 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths