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
7 changes: 7 additions & 0 deletions .docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
FROM php:8.2-cli-alpine

RUN apk add --no-cache \
curl \
bash \
nodejs \
npm

COPY --from=composer /usr/bin/composer /usr/bin/composer
RUN composer self-update


WORKDIR /usr/src/app
COPY . .

Expand Down
5 changes: 4 additions & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ ISSUE_ID=$(echo "$BRANCH_NAME" | grep -o -E "$REGEX_ISSUE_ID")
COMMIT_MESSAGE=$(cat "$1")

if [ -z "$ISSUE_ID" ]; then
echo "🛑 ${BRed} Branch name does not follow the expected pattern...${KN}"
php examples/helper/termwind-cli.php error "${BRed} Branch name does not follow the expected pattern...${KN}"

exit 1
fi

Expand All @@ -21,4 +22,6 @@ case "$COMMIT_MESSAGE" in
;;
esac

php examples/helper/termwind-cli.php success "PHPAY-$ISSUE_ID: $COMMIT_MESSAGE"

echo "PHPAY-$ISSUE_ID: $COMMIT_MESSAGE" > "$1"
29 changes: 8 additions & 21 deletions .husky/pre-commit
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,33 +1,20 @@
#!/usr/bin/env sh

echo "============================================="
echo "Pre Commit Hook - Running pint tests 🧪"
echo "============================================="

pint_output=$(./vendor/bin/pint --test 2>&1)
pint_output=$(vendor/bin/pint --test -v 2>&1)

if [ $? -ne 0 ]; then
echo "Pint tests failed. Please fix the issues before pushing."
php examples/helper/termwind-cli.php error "Pint tests failed." "$pint_output"

exit 1
fi

echo "🟢 Pint Ok!"

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

echo "============================================="
echo "Pre Commit Hook - Running PHPStan tests 🧪"
echo "============================================="

pint_output=$(./vendor/bin/phpstan analyse -l 9 src tests 2>&1)
phpstan=$(vendor/bin/phpstan analyse --level=9 2>&1)

if [ $? -ne 0 ]; then
echo "PHPStan tests failed. Please fix the issues before commit."
php examples/helper/termwind-cli.php error "PHPStan tests failed." "$phpstan"
exit 1
fi

echo "🟢 PHPStan Ok!"

echo "\n"

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

exit 0
19 changes: 6 additions & 13 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
#!/usr/bin/env sh
pest_output=$(./vendor/bin/pest --colors=always --stop-on-failure 2>&1)

# echo "============================================="
# echo "Pre Push Hook - Running pest tests 🧪"
# echo "============================================="
if [ $? -ne 0 ]; then
php examples/helper/termwind-cli.php error "Pest tests failed." "$pest_output"

# pest_output=$(./vendor/bin/pest --colors=always --stop-on-failure 2>&1)
exit 1
fi

# if [ $? -ne 0 ]; then
# echo "🛑 Pest tests failed. Please fix the issues before pushing."
# echo "$pest_output"
# exit 1
# fi

# echo "🟢 Pest Ok!"
# echo "\n"
php examples/helper/termwind-cli.php success "Pest Ok!"

exit 0
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@
"window.zoomLevel": 1,
"editor.fontVariations": false,
"phpunit.phpunit": "vendor/bin/pest",
"jira-plugin.workingProject": "",
}
84 changes: 73 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,93 @@ composer require phpay-io/phpay

## ⚙️ Como usar o PHPay?

### Asaas

```php
/**
* instance with gateway inject
* @var AsaasGateway $phpay
*/
$phpay = new PHPay(new AsaasGateway(TOKEN_ASAAS_SANDBOX));
$phpay = (new PHPay(new AsaasGateway(TOKEN_ASAAS_SANDBOX)));
```

### Efí
### Cobranças

```php
/**
* @var EfiGateway $phpay
* instance with gateway inject and resource call
*
* @var Charge $phpay
*/
$phpay = new PHPay(new EfiGateway(CLIENT_ID, CLIENT_SECRET));
```

## Gerando uma Cobrança
$phpay = (new PHPay(new AsaasGateway(TOKEN_ASAAS_SANDBOX)))->charge();

```php
/**
* create charge
*/
$phpay
->charge($charge)
->setCharge($charge)
->setCustomer($customer)
->create();

/**
* find charge
*/
$phpay->find($chargeId);

/**
* get all charges
*/
$phpay->getAll();

/**
* get all charges with filters
*/
$phpay
->setQueryParams(['limit' => 2])
->getAll();

/**
* update charge
*/
$phpay->update($chargeId, $data);

/**
* destroy charge
*/
$phpay->destroy($chargeId);

/**
* restore charge
*/
$phpay->restore($chargeId);

/**
* get status charge
*/
$phpay->getStatus($chargeId);

/**
* get digitable line charge
*/
$phpay->getDigitableLine($chargeId);

/**
* get qrcode charge
*/
$phpay->getQrCodePix($chargeId);

/**
* confirm receipt charge
*/
$phpay->confirmReceipt($chargeId, [
'paymentDate' => date('Y-m-d'),
'value' => 100.00,
'notifyCustomer' => true,
]);

/**
* undo confirm receipt
*/
$phpay->undoConfirmReceipt($chargeId);

```

## 📝 Roadmap
Expand Down
100 changes: 21 additions & 79 deletions examples/asaas/charges.php
Original file line number Diff line number Diff line change
@@ -1,141 +1,83 @@
<?php

use PHPay\Asaas\AsaasGateway;
use PHPay\Asaas\Resources\Charge\Charge;
use PHPay\PHPay;

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

require_once __DIR__ . '/credentials.php';

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

$charge = [
'billingType' => 'PIX',
'value' => 100.00,
'description' => 'Teste de fatura',
'dueDate' => date('Y-m-d', strtotime('+1 day')),
];

/**
* @var AsaasGateway $phpay
* @var Charge $phpay
*/
$phpay = new PHPay(new AsaasGateway(TOKEN_ASAAS_SANDBOX));
$phpay = (new PHPay(new AsaasGateway(TOKEN_ASAAS_SANDBOX)))->charge();

/**
* create charge
*
* @return array charges
*/
$phpay
->charge($charge)
->setCharge($charge)
->setCustomer($customer)
->create();

/**
* get all charges
*
* @return array charges
* find charge
*/
$phpay
->charge()
->find($chargeCreated['id']);
$phpay->find($chargeId);

/**
* get all charges
*
* @return array charges
*/
$phpay
->charge()
->getAll();
$phpay->getAll();

/**
* get all charges with filters
*
* @return array charges
*/
$phpay
->charge()
->setQueryParams(['limit' => 5])
->setQueryParams(['limit' => 2])
->getAll();

/**
* update charge
*
* @return array charge
*/
$phpay
->charge()
->update($chargeId, [
'description' => 'Teste de fatura atualizado',
]);
$phpay->update($chargeId, $data);

/**
* destroy charge
*
* @return array bool
*/
$phpay
->charge()
->destroy($chargeId);
$phpay->destroy($chargeId);

/**
* restore charge
*
* @return array charge
*/
$phpay
->charge()
->restore($chargeId);
$phpay->restore($chargeId);

/**
* get charge status
*
* @return array charge status
* get status charge
*/
$phpay
->charge()
->getStatus($chargeId);
$phpay->getStatus($chargeId);

/**
* get digitable line charge
*
* @return string
*/
$phpay
->charge()
->getDigitableLine($chargeId);
$phpay->getDigitableLine($chargeId);

/**
* get qrcode charge
*
* @return string
*/
$qrcode = $phpay
->charge()
->getQrCodePix($chargeId);
$phpay->getQrCodePix($chargeId);

/**
* confirm receipt charge
*
* @return array charges
*/
$confirmed = $phpay
->charge()
->confirmReceipt($chargeId, [
'paymentDate' => date('Y-m-d'),
'value' => 100.00,
'notifyCustomer' => true,
]);
$phpay->confirmReceipt($chargeId, [
'paymentDate' => date('Y-m-d'),
'value' => 100.00,
'notifyCustomer' => true,
]);

/**
* undo confirm receipt
*
* @return array charges
*/
$phpay
->charge()
->undoConfirmReceipt($chargeId);
$phpay->undoConfirmReceipt($chargeId);
Loading