From bc914c79c77af0f62e7c59d7a2ef824998c76e8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Lucas?= Date: Thu, 19 Dec 2024 08:56:49 -0300 Subject: [PATCH] PHPAY-40: feat: adding authorize token create to efi gateway --- .github/README.md | 142 ++++++++------------------------------- examples/efi/charges.php | 4 -- 2 files changed, 27 insertions(+), 119 deletions(-) diff --git a/.github/README.md b/.github/README.md index b9b7285..0074f8b 100644 --- a/.github/README.md +++ b/.github/README.md @@ -25,141 +25,52 @@ composer require phpay-io/phpay ## ⚙️ Como usar o PHPay? +### Asaas + ```php require 'vendor/autoload.php'; use PHPay\Gateways\Asaas\AsaasGateway; use PHPay\PHPay; -$phpay = PHPay::getInstance(new AsaasGateway(TOKEN_ASAAS_SANDBOX)) - ->getGateway(); +/** + * initialize phpay with asaas + * + * @var AsaasGateway $phpay + */ +$asaas = new PHPay(new AsaasGateway(TOKEN_ASAAS_SANDBOX)); ``` -## Customer +### Efí ```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']); +/** + * initialize phpay + * + * @var EfiGateway $phpay + */ +$phpay = new PHPay(new EfiGateway()); +``` -$phpay - ->customer() - ->destroy($customerCreated['id']); +### Observação -$phpay - ->customer() - ->restore($customerCreated['id']); +O Efí exige um token do tipo Bearer que é gerado com o +envio do client_id e client_secret, passa isso utilizar o +método a baixo: -$phpay - ->customer() - ->getNotifications($customerCreated['id']); +```php +$token = $phpay + ->authorization(CLIENT_ID, CLIENT_SECRET) + ->getToken(); ``` -## 🤑 Charges +## Gerando uma Cobrança ```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) + ->setCustomer($customer) ->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 @@ -173,6 +84,7 @@ $phpay - Integração com Efí. + - Autorização ✅ - Cobranças 🕥 - Clientes 🕥 - Webhook 🕥 diff --git a/examples/efi/charges.php b/examples/efi/charges.php index 665adf8..3ceb9d9 100644 --- a/examples/efi/charges.php +++ b/examples/efi/charges.php @@ -30,10 +30,6 @@ ->authorization(CLIENT_ID, CLIENT_SECRET) ->getToken(); -print_r($token); - -die(); - /** * create charge *