diff --git a/README.md b/README.md index 5dbbde7..b9b7285 100644 --- a/README.md +++ b/README.md @@ -28,32 +28,157 @@ composer require phpay-io/phpay ```php require 'vendor/autoload.php'; +use PHPay\Gateways\Asaas\AsaasGateway; use PHPay\PHPay; -$client = [ - 'name' => 'João da Silva', - 'cpf_cnpj' => '99999999999' // valid -]; +$phpay = PHPay::getInstance(new AsaasGateway(TOKEN_ASAAS_SANDBOX)) + ->getGateway(); +``` + +## Customer -$invoice = [ - 'value' => 100.00, - 'dueDate' => '2024-12-01', - 'description' => 'Pagamento de teste', -]; +```php +$customerCreated = $phpay + ->customer($customer) + ->create(); + +$phpay + ->customer() + ->getAll(); + +$phpay + ->customer() + ->setFilter([ + 'cpfCnpj' => $customerCreated['cpfCnpj'], + ]) + ->getAll(); + +$phpay + ->customer() + ->find($customerCreated['id']); + +$phpay + ->customer([ + 'name' => 'Mário Lucas Updated', + ]) + ->update($customerCreated['id']); + +$phpay + ->customer() + ->destroy($customerCreated['id']); + +$phpay + ->customer() + ->restore($customerCreated['id']); + +$phpay + ->customer() + ->getNotifications($customerCreated['id']); +``` -$response = PHPay::asaas('SUA_CHAVE_API') - ->client($client) - ->invoice($invoice) - ->qrCodePix(); +## 🤑 Charges -print_r($response); +```php +$customerCreated = $phpay + ->customer($customer) + ->create(); + +$phpay + ->charge($charge) + ->setCustomer($customerCreated['id']) + ->create(); + +$phpay + ->charge() + ->find($chargeCreated['id']); + +$phpay + ->charge() + ->getAll(); + +$phpay + ->charge() + ->update($chargeCreated['id'], [ + 'description' => 'Teste de fatura atualizado', + ]); + +$phpay + ->charge() + ->destroy($chargeCreated['id']); + +$phpay + ->charge() + ->restore($chargeCreated['id']); + +$phpay + ->charge() + ->getStatus($chargeCreated['id']); + +$phpay + ->charge() + ->getDigitableLine($chargeCreated['id']); + +$phpay + ->charge() + ->getQrCodePix($chargeCreated['id']); + +$phpay + ->charge() + ->confirmReceipt($chargeCreated['id'], [ + 'paymentDate' => date('Y-m-d'), + 'value' => 100.00, + 'notifyCustomer' => true, + ]); + +$phpay + ->charge() + ->undoConfirmReceipt($chargeCreated['id']); +``` + +## WebHooks + +```php +$webhook = $phpay + ->webhook($webhook) + ->create(); + +$phpay + ->webhook() + ->getAll(); + +$phpay + ->webhook() + ->find($webhook['id']); + +$phpay + ->webhook() + ->update($webhook['id'], [ + 'name' => 'Webhook de Teste Atualizado', + 'url' => 'https://mariolucas.me/webhook/atualizado', + ]); + +$phpay + ->webhook() + ->destroy($webhook['id']); ``` ## 📝 Roadmap - Integração com Asaas. + + - Cobranças ✅ + - Clientes ✅ + - Webhook ✅ + - Pix 🕥 + - Integração com Efí. -- Lançamento v1.0.0 + + - Cobranças 🕥 + - Clientes 🕥 + - Webhook 🕥 + - Pix 🕥 + +- Lançamento v1.0.0 🚀 ## 🌟 Contribuindo diff --git a/examples/asaas/webhook.php b/examples/asaas/webhook.php index 57522ca..51eee9e 100644 --- a/examples/asaas/webhook.php +++ b/examples/asaas/webhook.php @@ -52,7 +52,7 @@ * * @return array */ -$webhooks = $phpay +$phpay ->webhook() ->getAll(); @@ -61,9 +61,9 @@ * * @return array */ -$webhook = $phpay +$phpay ->webhook() - ->find('84c3c34b-9d23-44a3-95b2-d232c3f06dba'); + ->find($webhook['id']); /** * update a webhook @@ -73,7 +73,7 @@ */ $webhookUpdated = $phpay ->webhook() - ->update('84c3c34b-9d23-44a3-95b2-d232c3f06dba', [ + ->update($webhook['id'], [ 'name' => 'Webhook de Teste Atualizado', 'url' => 'https://sixtec.com.br/webhook/atualizado', ]); @@ -85,4 +85,4 @@ */ $webhookDeleted = $phpay ->webhook() - ->destroy('84c3c34b-9d23-44a3-95b2-d232c3f06dba'); + ->destroy($webhook['id']);