diff --git a/composer.json b/composer.json index 8084fa9..d3b375f 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { - "name": "mariolucasdev/payhub", + "name": "mariolucasdev/phpay", "type": "library", "autoload": { "psr-4": { - "Payhub\\": "src/" + "PHPay\\": "src/" } }, "authors": [ @@ -27,4 +27,4 @@ "scripts": { "test": "vendor/bin/pest" } -} +} \ No newline at end of file diff --git a/examples/asaas/clients.php b/examples/asaas/clients.php index 8de41e0..cc9bf31 100644 --- a/examples/asaas/clients.php +++ b/examples/asaas/clients.php @@ -1,7 +1,7 @@ - * @param bool $sandbox + * initialize phpay * * @return AsaasGateway */ -$payhub = Payhub::asaas(TOKEN_ASAAS_SANDBOX); +$phpay = PHPay::asaas(TOKEN_ASAAS_SANDBOX); /** * store asaas cliente @@ -27,7 +24,7 @@ * @param array $client * @return string cliente id asaas */ -$payhub +$phpay ->client($client) ->store(); @@ -36,7 +33,7 @@ * * @return array clients */ -$response = $payhub +$response = $phpay ->client() ->with(['cpfCnpj' => '09102295466',]) ->all(); @@ -49,7 +46,7 @@ * @param array $client * @return array client */ -$response = $payhub +$response = $phpay ->client() ->with(['cpfCnpj' => '09102295466']) ->get(); @@ -62,17 +59,24 @@ * @param array $client * @return bool */ -$payhub->client($client) +$phpay + ->client($client) ->delete(); /** * restore cliente no asaas - * - * @param array $client - * @return bool */ -$response = $payhub +$response = $phpay ->client() ->restore('cus_000006376400'); // print_r($response); + +/** + * notifications cliente no asaas + */ +$response = $phpay + ->client() + ->notifications('cus_000006376400'); + +// print_r($response); diff --git a/src/Contracts/GatewayInterface.php b/src/Contracts/GatewayInterface.php index 5c27138..46d8d2d 100644 --- a/src/Contracts/GatewayInterface.php +++ b/src/Contracts/GatewayInterface.php @@ -1,6 +1,6 @@ customerId = (new Client())::$method($client); - // } catch (\Exception $e) { - // return (new AsaasExceptions())($e->getMessage()); - // } - - // return $this; - // } /** * generate pix diff --git a/src/Gateways/Asaas/Enums/BillingType.php b/src/Gateways/Asaas/Enums/BillingType.php index 30d5888..52d8507 100644 --- a/src/Gateways/Asaas/Enums/BillingType.php +++ b/src/Gateways/Asaas/Enums/BillingType.php @@ -1,6 +1,6 @@ post(str_replace('{id}', $id, env('ASSAS_CLIENTS_RESTORE'))) ->json(); - print_r($client); - - die(); - - // if ($client['restored']) { - // return true; - // } + if ($client) { + return true; + } return false; } catch (\Exception $e) { @@ -189,4 +185,19 @@ public function restore(string $id): bool return false; } } + + /** + * get client notifications + * + * @param string $id + * @return array + */ + public function notifications(string $id): ?array + { + $notifications = Http::asaas() + ->get(str_replace('{id}', $id, env('ASSAS_CLIENTS_NOTIFICATIONS'))) + ->json(); + + return $notifications; + } } diff --git a/src/Gateways/Asaas/Resources/Interfaces/ClientInterface.php b/src/Gateways/Asaas/Resources/Interfaces/ClientInterface.php index 721cc90..cbfce96 100644 --- a/src/Gateways/Asaas/Resources/Interfaces/ClientInterface.php +++ b/src/Gateways/Asaas/Resources/Interfaces/ClientInterface.php @@ -1,8 +1,8 @@ toBeInstanceOf(Payhub::class); + ->toBeInstanceOf(PHPay::class); });