@@ -6,10 +6,10 @@ |
||
6 | 6 | |
7 | 7 | class PaystackFacade extends Facade { |
8 | 8 | /** |
9 | - * Get the registered name of the component. |
|
10 | - * |
|
11 | - * @return string |
|
12 | - */ |
|
9 | + * Get the registered name of the component. |
|
10 | + * |
|
11 | + * @return string |
|
12 | + */ |
|
13 | 13 | protected static function getFacadeAccessor() |
14 | 14 | { |
15 | 15 | return 'laravel-paystack'; |
@@ -20,9 +20,9 @@ |
||
20 | 20 | * @param string $type |
21 | 21 | * @return string |
22 | 22 | */ |
23 | - private static function getPool( $type = 'alnum') |
|
23 | + private static function getPool($type = 'alnum') |
|
24 | 24 | { |
25 | - switch ( $type ) { |
|
25 | + switch ($type) { |
|
26 | 26 | case 'alnum': |
27 | 27 | $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
28 | 28 | break; |
@@ -113,6 +113,10 @@ |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | |
116 | + /** |
|
117 | + * @param string $relativeUrl |
|
118 | + * @param string $method |
|
119 | + */ |
|
116 | 120 | private function setHttpResponse($relativeUrl, $method, $body = []){ |
117 | 121 | |
118 | 122 | if(is_null($method)){ |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | private function setRequestOptions() |
88 | 88 | { |
89 | - $authBearer = 'Bearer '. $this->secretKey; |
|
89 | + $authBearer = 'Bearer '.$this->secretKey; |
|
90 | 90 | |
91 | 91 | $this->client = new Client(['base_uri' => $this->baseUrl, |
92 | 92 | 'headers' => [ |
@@ -115,11 +115,11 @@ discard block |
||
115 | 115 | |
116 | 116 | private function setHttpResponse($relativeUrl, $method, $body = []) |
117 | 117 | { |
118 | - if(is_null($method)){ |
|
118 | + if (is_null($method)) { |
|
119 | 119 | throw new isNullException("Empty method not allowed"); |
120 | 120 | } |
121 | 121 | |
122 | - $this->response = $this->client->{strtolower($method)}($this->baseUrl . $relativeUrl, ["body" => json_encode($body)]); |
|
122 | + $this->response = $this->client->{strtolower($method)}($this->baseUrl.$relativeUrl, ["body" => json_encode($body)]); |
|
123 | 123 | return $this; |
124 | 124 | } |
125 | 125 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | $relativeUrl = "/transaction/verify/{$transactionRef}"; |
147 | 147 | |
148 | - $this->response = $this->client->get($this->baseUrl . $relativeUrl, []); |
|
148 | + $this->response = $this->client->get($this->baseUrl.$relativeUrl, []); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | /** |
269 | 269 | * Create a plan |
270 | 270 | */ |
271 | - public function createPlan(){ |
|
271 | + public function createPlan() { |
|
272 | 272 | |
273 | 273 | $data = [ |
274 | 274 | "name" => request()->name, |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | * @param $plan_code |
292 | 292 | * @return array |
293 | 293 | */ |
294 | - public function fetchPlan($plan_code){ |
|
294 | + public function fetchPlan($plan_code) { |
|
295 | 295 | $this->setRequestOptions(); |
296 | - return $this->setHttpResponse('/plan/' . $plan_code, 'GET', [])->getResponse(); |
|
296 | + return $this->setHttpResponse('/plan/'.$plan_code, 'GET', [])->getResponse(); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @param $plan_code |
302 | 302 | * @return array |
303 | 303 | */ |
304 | - public function updatePlan($plan_code){ |
|
304 | + public function updatePlan($plan_code) { |
|
305 | 305 | $data = [ |
306 | 306 | "name" => request()->name, |
307 | 307 | "description" => request()->desc, |
@@ -313,14 +313,14 @@ discard block |
||
313 | 313 | ]; |
314 | 314 | |
315 | 315 | $this->setRequestOptions(); |
316 | - return $this->setHttpResponse('/plan/' . $plan_code, 'PUT', $data)->getResponse(); |
|
316 | + return $this->setHttpResponse('/plan/'.$plan_code, 'PUT', $data)->getResponse(); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
320 | 320 | * Create a customer |
321 | 321 | * @return array |
322 | 322 | */ |
323 | - public function createCustomer(){ |
|
323 | + public function createCustomer() { |
|
324 | 324 | $data = [ |
325 | 325 | "email" => request()->email, |
326 | 326 | "first_name" => request()->fname, |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | public function fetchCustomer($customer_id) |
343 | 343 | { |
344 | 344 | $this->setRequestOptions(); |
345 | - return $this->setHttpResponse('/customer/'. $customer_id, 'GET', [])->getResponse(); |
|
345 | + return $this->setHttpResponse('/customer/'.$customer_id, 'GET', [])->getResponse(); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * @param $customer_id |
351 | 351 | * @return array |
352 | 352 | */ |
353 | - public function updateCustomer($customer_id){ |
|
353 | + public function updateCustomer($customer_id) { |
|
354 | 354 | $data = [ |
355 | 355 | "email" => request()->email, |
356 | 356 | "first_name" => request()->fname, |
@@ -361,14 +361,14 @@ discard block |
||
361 | 361 | ]; |
362 | 362 | |
363 | 363 | $this->setRequestOptions(); |
364 | - return $this->setHttpResponse('/customer/'. $customer_id, 'PUT', $data)->getResponse(); |
|
364 | + return $this->setHttpResponse('/customer/'.$customer_id, 'PUT', $data)->getResponse(); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | /** |
368 | 368 | * Export tranactions in .CSV |
369 | 369 | * @return array |
370 | 370 | */ |
371 | - public function exportTransactions(){ |
|
371 | + public function exportTransactions() { |
|
372 | 372 | $data = [ |
373 | 373 | "from" => request()->from, |
374 | 374 | "to" => request()->to, |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * Create a subscription to a plan from a customer. |
384 | 384 | * @return array |
385 | 385 | */ |
386 | - public function createSubscription(){ |
|
386 | + public function createSubscription() { |
|
387 | 387 | $data = [ |
388 | 388 | "customer" => request()->customer, //Customer email or code |
389 | 389 | "plan" => request()->plan, |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | * Enable a subscription using the subscription code and token |
399 | 399 | * @return array |
400 | 400 | */ |
401 | - public function enableSubscription(){ |
|
401 | + public function enableSubscription() { |
|
402 | 402 | $data = [ |
403 | 403 | "code" => request()->code, |
404 | 404 | "token" => request()->token, |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | * Disable a subscription using the subscription code and token |
413 | 413 | * @return array |
414 | 414 | */ |
415 | - public function disableSubscription(){ |
|
415 | + public function disableSubscription() { |
|
416 | 416 | $data = [ |
417 | 417 | "code" => request()->code, |
418 | 418 | "token" => request()->token, |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | * Create pages you can share with users using the returned slug |
438 | 438 | * @return array |
439 | 439 | */ |
440 | - public function createPage(){ |
|
440 | + public function createPage() { |
|
441 | 441 | $data = [ |
442 | 442 | "name" => request()->name, |
443 | 443 | "description" => request()->description, |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | * @param $page_id |
475 | 475 | * @return array |
476 | 476 | */ |
477 | - public function updatePage($page_id){ |
|
477 | + public function updatePage($page_id) { |
|
478 | 478 | $data = [ |
479 | 479 | "name" => request()->name, |
480 | 480 | "description" => request()->description, |