| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace App\Console\Commands;
- use App\Services\Integrations\Asaas\AsaasClient;
- use Illuminate\Console\Command;
- use Illuminate\Support\Str;
- class AsaasSmokeTestCommand extends Command
- {
- protected $signature = 'asaas:smoke-test';
- protected $description = 'Executa um teste de fumaça criando um cliente e uma cobrança no Asaas Sandbox';
- public function handle()
- {
- $this->info('Iniciando teste de fumaça com o Asaas...');
- $client = new AsaasClient();
- try {
- $this->info('1. Criando Customer de teste...');
- $customer = $client->post('/customers', [
- 'name' => 'Teste Fumaça ' . Str::random(5),
- 'cpfCnpj' => '12345678909', // CPF matematicamente válido para testes
- 'email' => 'teste@ginasticacerebro.com.br',
- ]);
- $customerId = $customer['id'];
- $this->info("Customer criado com sucesso: $customerId");
- $this->info('2. Criando Cobrança (Payment) PIX...');
- $payment = $client->post('/payments', [
- 'customer' => $customerId,
- 'billingType' => 'PIX',
- 'value' => 10.50,
- 'dueDate' => now()->addDays(5)->format('Y-m-d'),
- 'description' => 'Cobrança Teste de Fumaça',
- ]);
- $this->info('Cobrança criada com sucesso: ' . $payment['id']);
- $this->info('Link de pagamento: ' . $payment['invoiceUrl']);
- $this->info('Teste finalizado com sucesso! 🎉');
- } catch (\Exception $e) {
- $this->error('Falha no teste: ' . $e->getMessage());
- return Command::FAILURE;
- }
- return Command::SUCCESS;
- }
- }
|