@@ -156,13 +156,13 @@ |
||
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
| 159 | - * Send a DELETE request to a Paystack API endpoint. |
|
| 160 | - * |
|
| 161 | - * @param string $endpoint |
|
| 162 | - * @return Response |
|
| 163 | - * |
|
| 164 | - * @throws PaystackRequestException |
|
| 165 | - */ |
|
| 159 | + * Send a DELETE request to a Paystack API endpoint. |
|
| 160 | + * |
|
| 161 | + * @param string $endpoint |
|
| 162 | + * @return Response |
|
| 163 | + * |
|
| 164 | + * @throws PaystackRequestException |
|
| 165 | + */ |
|
| 166 | 166 | public function delete(string $endpoint): Response |
| 167 | 167 | { |
| 168 | 168 | return $this->request(self::METHOD_DELETE, $endpoint); |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | config('paystack.retry_delay', 150) |
| 51 | 51 | ) |
| 52 | 52 | ->withHeaders([ |
| 53 | - 'Authorization' => 'Bearer ' . $this->secretKey, |
|
| 53 | + 'Authorization' => 'Bearer '.$this->secretKey, |
|
| 54 | 54 | 'Accept' => 'application/json', |
| 55 | 55 | 'Content-Type' => 'application/json', |
| 56 | 56 | ]) |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | protected function handleErrors(Response $response): Response |
| 74 | 74 | { |
| 75 | - if (! $response->successful()) { |
|
| 75 | + if (!$response->successful()) { |
|
| 76 | 76 | $message = $response->json('message') ?? 'Paystack request failed.'; |
| 77 | 77 | Log::error('Paystack API error', ['response' => $response->body()]); |
| 78 | 78 | throw new PaystackRequestException($message, $response); |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | $allowedMethods = [self::METHOD_GET, self::METHOD_POST, self::METHOD_PUT, self::METHOD_DELETE]; |
| 98 | 98 | $method = strtolower($method); |
| 99 | 99 | |
| 100 | - if (! in_array($method, $allowedMethods, true)) { |
|
| 100 | + if (!in_array($method, $allowedMethods, true)) { |
|
| 101 | 101 | throw new \InvalidArgumentException("Unsupported HTTP method: {$method}"); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - $url = $this->baseUrl . '/' . ltrim($endpoint, '/'); |
|
| 104 | + $url = $this->baseUrl.'/'.ltrim($endpoint, '/'); |
|
| 105 | 105 | // $response = $this->client()->{$method}($url, $data); |
| 106 | 106 | |
| 107 | 107 | $client = $this->client(); |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * Create a new Paystack instance. |
| 38 | 38 | * |
| 39 | 39 | * @param PaystackClient $client |
| 40 | - */ |
|
| 40 | + */ |
|
| 41 | 41 | public function __construct(PaystackClient $client) |
| 42 | 42 | { |
| 43 | 43 | $this->client = $client; |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * Get the TransactionService instance. |
| 48 | 48 | * |
| 49 | 49 | * @return TransactionService |
| 50 | - */ |
|
| 50 | + */ |
|
| 51 | 51 | public function transaction(): TransactionService |
| 52 | 52 | { |
| 53 | 53 | return new TransactionService($this->client); |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * Get the CustomerService instance. |
| 58 | 58 | * |
| 59 | 59 | * @return CustomerService |
| 60 | - */ |
|
| 60 | + */ |
|
| 61 | 61 | public function customer(): CustomerService |
| 62 | 62 | { |
| 63 | 63 | return new CustomerService($this->client); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * Get the PlanService instance. |
| 68 | 68 | * |
| 69 | 69 | * @return PlanService |
| 70 | - */ |
|
| 70 | + */ |
|
| 71 | 71 | public function plan(): PlanService |
| 72 | 72 | { |
| 73 | 73 | return new PlanService($this->client); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * Get the SubscriptionService instance. |
| 78 | 78 | * |
| 79 | 79 | * @return SubscriptionService |
| 80 | - */ |
|
| 80 | + */ |
|
| 81 | 81 | public function subscription(): SubscriptionService |
| 82 | 82 | { |
| 83 | 83 | return new SubscriptionService($this->client); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * Get the PageService instance. |
| 88 | 88 | * |
| 89 | 89 | * @return PageService |
| 90 | - */ |
|
| 90 | + */ |
|
| 91 | 91 | public function page(): PageService |
| 92 | 92 | { |
| 93 | 93 | return new PageService($this->client); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * Get the SubAccountService instance. |
| 98 | 98 | * |
| 99 | 99 | * @return SubAccountService |
| 100 | - */ |
|
| 100 | + */ |
|
| 101 | 101 | public function subAccount(): SubAccountService |
| 102 | 102 | { |
| 103 | 103 | return new SubAccountService($this->client); |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * Get the BankService instance. |
| 108 | 108 | * |
| 109 | 109 | * @return BankService |
| 110 | - */ |
|
| 110 | + */ |
|
| 111 | 111 | public function bank(): BankService |
| 112 | 112 | { |
| 113 | 113 | return new BankService($this->client); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | * Generate a unique transaction reference. |
| 118 | 118 | * |
| 119 | 119 | * @return string |
| 120 | - */ |
|
| 120 | + */ |
|
| 121 | 121 | public function transRef(): string |
| 122 | 122 | { |
| 123 | 123 | return TransRef::generate(); |
@@ -26,9 +26,9 @@ discard block |
||
| 26 | 26 | class PaystackServiceProvider extends ServiceProvider |
| 27 | 27 | { |
| 28 | 28 | /** |
| 29 | - * Publishes all the config file this package needs to function |
|
| 30 | - * @return void |
|
| 31 | - */ |
|
| 29 | + * Publishes all the config file this package needs to function |
|
| 30 | + * @return void |
|
| 31 | + */ |
|
| 32 | 32 | public function boot(): void |
| 33 | 33 | { |
| 34 | 34 | $this->bootConfig(); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * and merges the package's config file with the application's config. |
| 44 | 44 | * |
| 45 | 45 | * @return void |
| 46 | - */ |
|
| 46 | + */ |
|
| 47 | 47 | public function register(): void |
| 48 | 48 | { |
| 49 | 49 | $this->mergeConfigFrom(__DIR__ . '/../config/paystack.php', 'paystack'); |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | - * Get the services provided by the provider |
|
| 74 | - * @return array<int, class-string> |
|
| 75 | - */ |
|
| 73 | + * Get the services provided by the provider |
|
| 74 | + * @return array<int, class-string> |
|
| 75 | + */ |
|
| 76 | 76 | public function provides(): array |
| 77 | 77 | { |
| 78 | 78 | return [ |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * by running: php artisan vendor:publish --tag=paystack-config |
| 96 | 96 | * |
| 97 | 97 | * @return void |
| 98 | - */ |
|
| 98 | + */ |
|
| 99 | 99 | protected function bootConfig() |
| 100 | 100 | { |
| 101 | 101 | $this->publishes([ |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * customize them by running: php artisan vendor:publish --tag=paystack-views |
| 111 | 111 | * |
| 112 | 112 | * @return void |
| 113 | - */ |
|
| 113 | + */ |
|
| 114 | 114 | protected function bootViews() |
| 115 | 115 | { |
| 116 | 116 | $this->loadViewsFrom(__DIR__.'/../resources/views', 'paystack'); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * they are available in the host Laravel application. |
| 128 | 128 | * |
| 129 | 129 | * @return void |
| 130 | - */ |
|
| 130 | + */ |
|
| 131 | 131 | protected function bootRoutes() |
| 132 | 132 | { |
| 133 | 133 | if (config('paystack.enable_routes', true)) { |
@@ -46,9 +46,9 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function register(): void |
| 48 | 48 | { |
| 49 | - $this->mergeConfigFrom(__DIR__ . '/../config/paystack.php', 'paystack'); |
|
| 49 | + $this->mergeConfigFrom(__DIR__.'/../config/paystack.php', 'paystack'); |
|
| 50 | 50 | |
| 51 | - $this->app->singleton(PaystackClient::class, function () { |
|
| 51 | + $this->app->singleton(PaystackClient::class, function() { |
|
| 52 | 52 | return new PaystackClient(config('paystack.secretKey')); |
| 53 | 53 | }); |
| 54 | 54 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $this->app->singleton(SubAccountService::class, fn ($app) => new SubAccountService($app->make(PaystackClient::class))); |
| 61 | 61 | $this->app->singleton(BankService::class, fn ($app) => new BankService($app->make(PaystackClient::class))); |
| 62 | 62 | |
| 63 | - $this->app->singleton(Paystack::class, function ($app) { |
|
| 63 | + $this->app->singleton(Paystack::class, function($app) { |
|
| 64 | 64 | return new Paystack($app->make(PaystackClient::class)); |
| 65 | 65 | }); |
| 66 | 66 | |
@@ -108,7 +108,7 @@ |
||
| 108 | 108 | * @param int|string $id Transaction ID or reference string. |
| 109 | 109 | * @return array<string, mixed> |
| 110 | 110 | */ |
| 111 | - public function fetch(int|string $id): array |
|
| 111 | + public function fetch(int | string $id): array |
|
| 112 | 112 | { |
| 113 | 113 | return $this->handle(fn () => $this->client->get("transaction/{$id}")->json()); |
| 114 | 114 | } |
@@ -20,14 +20,14 @@ discard block |
||
| 20 | 20 | * The Paystack API client instance. |
| 21 | 21 | * |
| 22 | 22 | * @var \Unicodeveloper\Paystack\Client\PaystackClient |
| 23 | - */ |
|
| 23 | + */ |
|
| 24 | 24 | protected PaystackClient $client; |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * PlanService constructor. |
| 28 | 28 | * |
| 29 | 29 | * @param \Unicodeveloper\Paystack\Client\PaystackClient $client |
| 30 | - */ |
|
| 30 | + */ |
|
| 31 | 31 | public function __construct(PaystackClient $client) |
| 32 | 32 | { |
| 33 | 33 | $this->client = $client; |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @param callable $callback |
| 42 | 42 | * @return array{status: bool, message: string, data: mixed} |
| 43 | - */ |
|
| 43 | + */ |
|
| 44 | 44 | protected function handle(callable $callback): array |
| 45 | 45 | { |
| 46 | 46 | try { |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @param int $countryCode The country code of the states to list. It is gotten after the charge request. |
| 82 | 82 | * @return array<string, mixed> |
| 83 | - */ |
|
| 83 | + */ |
|
| 84 | 84 | public function listState(int $countryCode): array |
| 85 | 85 | { |
| 86 | 86 | return $this->handle(fn () => $this->client->get("address_verification/states?country={$countryCode}")->json()); |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @param array<string, mixed> $params Query parameter containing `account_number` and `bank_code`. |
| 101 | 101 | * @return array<string, mixed> |
| 102 | - */ |
|
| 102 | + */ |
|
| 103 | 103 | public function resolveAccount(array $params = []): array |
| 104 | 104 | { |
| 105 | 105 | return $this->handle(fn () => $this->client->get('bank/resolve', $params)->json()); |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | * |
| 16 | 16 | * @return \Unicodeveloper\Paystack\Paystack |
| 17 | 17 | */ |
| 18 | -if (! function_exists("paystack")) { |
|
| 18 | +if (!function_exists("paystack")) { |
|
| 19 | 19 | function paystack(): Paystack |
| 20 | 20 | { |
| 21 | 21 | return app()->make('laravel-paystack'); |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | * Format: TXN_<unique_id>_<random_hex> |
| 20 | 20 | * |
| 21 | 21 | * @return string |
| 22 | - */ |
|
| 22 | + */ |
|
| 23 | 23 | public static function generate(): string |
| 24 | 24 | { |
| 25 | 25 | return 'TXN_' . uniqid() . '_' . bin2hex(random_bytes(4)); |
@@ -22,6 +22,6 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | public static function generate(): string |
| 24 | 24 | { |
| 25 | - return 'TXN_' . uniqid() . '_' . bin2hex(random_bytes(4)); |
|
| 25 | + return 'TXN_'.uniqid().'_'.bin2hex(random_bytes(4)); |
|
| 26 | 26 | } |
| 27 | 27 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * The HTTP client response from the failed request (if available). |
| 20 | 20 | * |
| 21 | 21 | * @var Response|null |
| 22 | - */ |
|
| 22 | + */ |
|
| 23 | 23 | protected ?Response $response; |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @param string $message The error message. |
| 29 | 29 | * @param Response|null $response The original HTTP response from the failed request (optional). |
| 30 | - */ |
|
| 30 | + */ |
|
| 31 | 31 | public function __construct(string $message, ?Response $response = null) |
| 32 | 32 | { |
| 33 | 33 | parent::__construct($message); |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * Get the HTTP client response from the failed request, if available. |
| 39 | 39 | * |
| 40 | 40 | * @return Response|null |
| 41 | - */ |
|
| 41 | + */ |
|
| 42 | 42 | public function getResponse(): ?Response |
| 43 | 43 | { |
| 44 | 44 | return $this->response; |