Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fi

php examples/helper/termwind-cli.php success "Pint Ok!"

phpstan=$(vendor/bin/phpstan analyse --level=9 2>&1)
phpstan=$(vendor/bin/phpstan analyse --level=7 2>&1)

if [ $? -ne 0 ]; then
php examples/helper/termwind-cli.php error "PHPStan tests failed." "$phpstan"
Expand Down
122 changes: 61 additions & 61 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
{
"cSpell.enabled": false,
"editor.lineHeight": 1.9,
"editor.fontFamily": "JetBrains Mono",
// "editor.fontFamily": "Dank Mono",
// "editor.codeLensFontFamily": "Operator Mono",
"editor.fontLigatures": true,
"editor.formatOnSave": true,
"php-cs-fixer.onsave": true,
"php-cs-fixer.executablePath": "${extensionPath}/php-cs-fixer.phar",
"cSpell.userWords": [
"Assertable",
"autoload",
"Bootstrapper",
"bootstrappers",
"Codeigniter",
"Dispatchable",
"flashdata",
"intelephense",
"junstyle",
"Laravel",
"Livewire",
"onsave",
"phar",
"phpstan",
"Queueable",
"Stancl",
"timesheet",
"userdata"
],
"php-cs-fixer.lastDownload": 1693233566761,
"terminal.integrated.cursorStyle": "underline",
"terminal.integrated.defaultProfile.windows": "Git Bash",
"terminal.integrated.fontFamily": "Hack Nerd Font Mono",
"terminal.integrated.lineHeight": 1.2,
"editor.accessibilitySupport": "off",
"terminal.integrated.copyOnSelection": true,
"terminal.integrated.sendKeybindingsToShell": true,
"redhat.telemetry.enabled": true,
"editor.minimap.enabled": false,
"editor.tabSize": 4,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"github.copilot.enable": {
"*": true,
"plaintext": true,
"markdown": false,
"scminput": false
},
"editor.inlineSuggest.enabled": true,
"explorer.confirmDragAndDrop": false,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"files.associations": {
"*.js": "javascriptreact"
},
"window.zoomLevel": 1,
"editor.fontVariations": false,
"phpunit.phpunit": "vendor/bin/pest",
"jira-plugin.workingProject": "",
}
"cSpell.enabled": false,
"editor.lineHeight": 2.4,
// "editor.fontFamily": "JetBrains Mono",
// "editor.fontFamily": "Dank Mono",
// "editor.codeLensFontFamily": "Operator Mono",
"editor.fontLigatures": true,
"editor.formatOnSave": true,
"php-cs-fixer.onsave": true,
"php-cs-fixer.executablePath": "${extensionPath}/php-cs-fixer.phar",
"cSpell.userWords": [
"Assertable",
"autoload",
"Bootstrapper",
"bootstrappers",
"Codeigniter",
"Dispatchable",
"flashdata",
"intelephense",
"junstyle",
"Laravel",
"Livewire",
"onsave",
"phar",
"phpstan",
"Queueable",
"Stancl",
"timesheet",
"userdata"
],
"php-cs-fixer.lastDownload": 1693233566761,
"terminal.integrated.cursorStyle": "underline",
"terminal.integrated.defaultProfile.windows": "Git Bash",
"terminal.integrated.fontFamily": "Hack Nerd Font Mono",
"terminal.integrated.lineHeight": 1.2,
"editor.accessibilitySupport": "off",
"terminal.integrated.copyOnSelection": true,
"terminal.integrated.sendKeybindingsToShell": true,
"redhat.telemetry.enabled": true,
"editor.minimap.enabled": false,
"editor.tabSize": 4,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"github.copilot.enable": {
"*": true,
"plaintext": true,
"markdown": false,
"scminput": false
},
"editor.inlineSuggest.enabled": true,
"explorer.confirmDragAndDrop": false,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"files.associations": {
"*.js": "javascriptreact"
},
"window.zoomLevel": 1,
"editor.fontVariations": false,
"phpunit.phpunit": "vendor/bin/pest",
"jira-plugin.workingProject": ""
}
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,29 @@ $phpay->undoConfirmReceipt($chargeId);

```

### Assinaturas

```php
/**
* @var Subscription $phpay
*/
$phpay = PHPay::gateway(new AsaasGateway(TOKEN_ASAAS_SANDBOX))->subscription();

/**
* create a new subscription
*/
$phpay->setCustomer($customer)->create([
'billingType' => 'BOLETO',
'value' => 100,
'nextDueDate' => '2025-04-09',
]);
```

## 📝 Roadmap

- Definições de Arquitetura ✅
- Domínios ✅
- Documentação 🕑
- Documentação ✍️
- Site 🕛
- Gateways ✍️

Expand All @@ -125,6 +143,7 @@ $phpay->undoConfirmReceipt($chargeId);
- Cobranças ✅
- Clientes ✅
- Webhook ✅
- Assinaturas ✍️
- Pix 🕥

- Efí.
Expand All @@ -133,6 +152,7 @@ $phpay->undoConfirmReceipt($chargeId);
- Cobranças ✅
- Clientes 🕥
- Webhook 🕥
- Assinaturas ✍️
- Pix 🕥

- Lançamento v1.0.0 🚀
Expand Down
60 changes: 60 additions & 0 deletions examples/asaas/subscriptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

use PHPay\Asaas\AsaasGateway;
use PHPay\Asaas\Resources\Subscription\Subscription;
use PHPay\PHPay;

require_once __DIR__ . '/../../vendor/autoload.php';

require_once __DIR__ . '/credentials.php';

$customer = [
'name' => NAME,
'cpfCnpj' => CPF_CNPJ,
];

$subscriptionId = 'sub_e3knxyfo6ffgb6kg';

/**
* @var Subscription $phpay
*/
$phpay = PHPay::gateway(new AsaasGateway(TOKEN_ASAAS_SANDBOX))->subscription();

/* subscription store */
$phpay->setCustomer($customer)
->create([
'billingType' => 'BOLETO',
'value' => 100,
'nextDueDate' => '2025-04-09',
'discount' => [
'value' => 10,
'dueDateLimitDays' => 5,
'type' => 'FIXED', /* PERCENTAGE */
],
'interest' => [
'value' => 2,
],
'fine' => [
'value' => 1,
'type' => 'FIXED', /* PERCENTAGE */
],
'cycle' => 'MONTHLY',
'description' => 'Teste de assinatura',
'maxPayments' => 12,
'externalReference' => '123456',
// 'split' => [
// [
// 'walletId' => 'rec_123456',
// 'fixedValue' => 50,
// 'percentageValue' => 50,
// 'externalReference' => '123456',
// 'description' => 'Teste de divisão',
// ],
// ],
// 'callback' => [
// 'successUrl' => 'https://example.com/success',
// 'autoRedirect' => true,
// ]
]);

print_r($subscriptionCreated);
3 changes: 1 addition & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
parameters:
paths:
- src
- tests
- src
7 changes: 7 additions & 0 deletions src/Contracts/GatewayInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,11 @@ public function webhook(array $webhook = []): object;
* @return object
*/
public function pix(array $pix = []): object;

/**
* get resource subscription from gateway.
*
* @return object
*/
public function subscription(): object;
}
6 changes: 6 additions & 0 deletions src/Gateways/Asaas/AsaasGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PHPay\Asaas\Resources\Charge\Charge;
use PHPay\Asaas\Resources\Customer\Customer;
use PHPay\Asaas\Resources\Pix\Pix;
use PHPay\Asaas\Resources\Subscription\Subscription;
use PHPay\Asaas\Resources\Webhook\Webhook;

class AsaasGateway implements AsaasGatewayInterface
Expand Down Expand Up @@ -79,4 +80,9 @@ public function pix(array $pix = []): Pix
{
return new Pix($this->token, $this->sandbox);
}

public function subscription(): Subscription
{
return new Subscription($this->token, $this->sandbox);
}
}
8 changes: 8 additions & 0 deletions src/Gateways/Asaas/Interface/AsaasGatewayInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use PHPay\Asaas\Resources\Charge\Charge;
use PHPay\Asaas\Resources\Customer\Customer;
use PHPay\Asaas\Resources\Pix\Pix;
use PHPay\Asaas\Resources\Subscription\Subscription;
use PHPay\Asaas\Resources\Webhook\Webhook;
use PHPay\Contracts\GatewayInterface;

Expand All @@ -25,6 +26,13 @@ public function customer(array $customer = []): Customer;
*/
public function charge(): Charge;

/**
* get resource subscription from gateway.
*
* @return Subscription
*/
public function subscription(): Subscription;

/**
* get resource webhook from gateway.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace PHPay\Asaas\Resources\Subscription\Interface;

use PHPay\Asaas\Resources\Subscription\Subscription;

interface SubscriptionInterface
{
public function __construct(string $token, bool $sandbox = true);

/**
* set customer
*
* @param array<mixed> $customer
* @return Subscription
*/
public function setCustomer(array $customer): Subscription;

/**
* create subscription
*
* @param array<mixed> $subscription
* @return array<mixed>
*/
public function create(array $subscription): array;

// public function findAll();
// public function find(string $subscriptionId);
// public function update(string $subscriptionId, array $subscription);
// public function destroy(string $subscriptionId);
// public function findCharges(string $subscriptionId);
// public function generateCarnet(string $subscriptionId);
// public function nfeSettings(string $subscriptionId, array $nfeSettings);
// public function findNfeSettings(string $subscriptionId);
// public function updateNfeSettings(string $subscriptionId, array $nfeSettings);
// public function destroyNfeSettings(string $subscriptionId);
// public function findNfes(string $subscriptionId);
}
Loading