Skip to content
Open
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
23 changes: 20 additions & 3 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,46 @@ jobs:

runs-on: ubuntu-latest

strategy:
matrix:
php-version: [ '7.4', '8.3', '8.4' ]

env:
CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE_ID }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@master
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: ${{ matrix.php-version }}
coverage: xdebug

- name: Get composer cache directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer Dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Code Climate Setup
if: ${{ env.CC_TEST_REPORTER_ID != '' }}
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter && chmod +x ./cc-test-reporter
./cc-test-reporter before-build
- name: Run Tests
run: |
php vendor/bin/phpunit --color --testdox --coverage-clover clover.xml tests
- name: Send Report
if: ${{ env.CC_TEST_REPORTER_ID != '' && matrix.php-version == '7.4' }}
run: |
./cc-test-reporter after-build -t clover --exit-code $?
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ $responsePayment = $ipagClient->payment()->getById($transactionId);
$responsePayment = $ipagClient->payment()->getByUuid($transactionUuid);
```
```php
$responsePayment = $ipagClient->payment()->getByUuid($transactionTid);
$responsePayment = $ipagClient->payment()->getByTid($transactionTid);
```
```php
$responsePayment = $ipagClient->payment()->getByUuid($orderId);
$responsePayment = $ipagClient->payment()->getByOrderId($orderId);
```

### Capturar Pagamento
Expand All @@ -315,11 +315,11 @@ $responsePayment = $ipagClient->payment()->captureByUuid($transactionUuid, $amou
```
ou
```php
$responsePayment = $ipagClient->payment()->captureByUuid($transactionTid, $amount);
$responsePayment = $ipagClient->payment()->captureByTid($transactionTid, $amount);
```
ou
```php
$responsePayment = $ipagClient->payment()->captureByUuid($orderId, $amount);
$responsePayment = $ipagClient->payment()->captureByOrderId($orderId, $amount);
```

### Cancelar Pagamento
Expand All @@ -333,11 +333,11 @@ $responsePayment = $ipagClient->payment()->cancelByUuid($transactionUuid, $amoun
```
ou
```php
$responsePayment = $ipagClient->payment()->cancelByUuid($transactionTid, $amount);
$responsePayment = $ipagClient->payment()->cancelByTid($transactionTid, $amount);
```
ou
```php
$responsePayment = $ipagClient->payment()->cancelByUuid($orderId, $amount);
$responsePayment = $ipagClient->payment()->cancelByOrderId($orderId, $amount);
```

> Todos os exemplos: [examples/payment/](https://github.com/ipagdevs/ipag-sdk-php/tree/master/examples/payment/)
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function setState(?string $state): self
}
public function zipcode(): Mutator
{
return new Mutator(null, fn ($value) => strval(preg_replace('/\D/', '', $value)));
return new Mutator(null, fn ($value) => strval(preg_replace('/\D/', '', $value ?? '')));
}

/**
Expand Down
8 changes: 5 additions & 3 deletions src/Model/Attendee.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ protected function dob(): Mutator
return new Mutator(
null,
function ($value, $ctx) {
if (is_null($value)) {
return null;
}

$d = \DateTime::createFromFormat('Y-m-d', $value);

return is_null($value) ||
($d && $d->format('Y-m-d') === $value) ?
$value : $ctx->raise('inválido');
return ($d && $d->format('Y-m-d') === $value) ? $value : $ctx->raise('inválido');
}
);
}
Expand Down
8 changes: 5 additions & 3 deletions src/Model/Boleto.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ protected function due_date(): Mutator
return new Mutator(
null,
function ($value, $ctx) {
if (is_null($value)) {
return null;
}

$d = \DateTime::createFromFormat('Y-m-d', $value);

return is_null($value) ||
($d && $d->format('Y-m-d') === $value) ?
$value : $ctx->raise('inválido');
return ($d && $d->format('Y-m-d') === $value) ? $value : $ctx->raise('inválido');
}
);
}
Expand Down
16 changes: 10 additions & 6 deletions src/Model/Charge.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ protected function due_date(): Mutator
return new Mutator(
null,
function ($value, $ctx) {
if (is_null($value)) {
return null;
}

$d = \DateTime::createFromFormat('Y-m-d', $value);

return is_null($value) ||
($d && $d->format('Y-m-d') === $value) ?
$value : $ctx->raise('inválido');
return ($d && $d->format('Y-m-d') === $value) ? $value : $ctx->raise('inválido');
}
);
}
Expand All @@ -118,11 +120,13 @@ protected function last_charge_date(): Mutator
return new Mutator(
null,
function ($value, $ctx) {
if (is_null($value)) {
return null;
}

$d = \DateTime::createFromFormat('Y-m-d', $value);

return is_null($value) ||
($d && $d->format('Y-m-d') === $value) ?
$value : $ctx->raise('inválido');
return ($d && $d->format('Y-m-d') === $value) ? $value : $ctx->raise('inválido');
}
);
}
Expand Down
10 changes: 6 additions & 4 deletions src/Model/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,13 @@ protected function birthdate(): Mutator
return new Mutator(
null,
function ($value, $ctx) {
if (is_null($value)) {
return null;
}

$d = \DateTime::createFromFormat('Y-m-d', $value);

return is_null($value) ||
($d && $d->format('Y-m-d') === $value) ?
$value : $ctx->raise('inválido');

return ($d && $d->format('Y-m-d') === $value) ? $value : $ctx->raise('inválido');
}
);
}
Expand Down
8 changes: 5 additions & 3 deletions src/Model/Holder.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,13 @@ protected function birthdate(): Mutator
return new Mutator(
null,
function ($value, $ctx) {
if (is_null($value)) {
return null;
}

$d = \DateTime::createFromFormat('Y-m-d', $value);

return is_null($value) ||
($d && $d->format('Y-m-d') === $value) ?
$value : $ctx->raise('inválido');
return ($d && $d->format('Y-m-d') === $value) ? $value : $ctx->raise('inválido');
}
);
}
Expand Down
8 changes: 5 additions & 3 deletions src/Model/Owner.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ protected function birthdate(): Mutator
return new Mutator(
null,
function ($value, $ctx) {
if (is_null($value)) {
return null;
}

$d = \DateTime::createFromFormat('Y-m-d', $value);

return is_null($value) ||
($d && $d->format('Y-m-d') === $value) ?
$value : $ctx->raise('inválido');
return ($d && $d->format('Y-m-d') === $value) ? $value : $ctx->raise('inválido');
}
);
}
Expand Down
8 changes: 5 additions & 3 deletions src/Model/PaymentSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ protected function start_date(): Mutator
return new Mutator(
null,
function ($value, $ctx) {
if (is_null($value)) {
return null;
}

$d = \DateTime::createFromFormat('Y-m-d', $value);

return is_null($value) ||
($d && $d->format('Y-m-d') === $value) ?
$value : $ctx->raise('inválido');
return ($d && $d->format('Y-m-d') === $value) ? $value : $ctx->raise('inválido');
}
);
}
Expand Down
8 changes: 5 additions & 3 deletions src/Model/Seller.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ protected function birthdate(): Mutator
return new Mutator(
null,
function ($value, $ctx) {
if (is_null($value)) {
return null;
}

$d = \DateTime::createFromFormat('Y-m-d', $value);

return is_null($value) ||
($d && $d->format('Y-m-d') === $value) ?
$value : $ctx->raise('inválido');
return ($d && $d->format('Y-m-d') === $value) ? $value : $ctx->raise('inválido');
}
);
}
Expand Down
16 changes: 10 additions & 6 deletions src/Model/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,13 @@ protected function starting_date(): Mutator
return new Mutator(
null,
function ($value, $ctx) {
if (is_null($value)) {
return null;
}

$d = \DateTime::createFromFormat('Y-m-d', $value);

return is_null($value) ||
($d && $d->format('Y-m-d') === $value) ?
$value : $ctx->raise('inválido');
return ($d && $d->format('Y-m-d') === $value) ? $value : $ctx->raise('inválido');
}
);
}
Expand Down Expand Up @@ -200,11 +202,13 @@ protected function closing_date(): Mutator
return new Mutator(
null,
function ($value, $ctx) {
if (is_null($value)) {
return null;
}

$d = \DateTime::createFromFormat('Y-m-d', $value);

return is_null($value) ||
($d && $d->format('Y-m-d') === $value) ?
$value : $ctx->raise('inválido');
return ($d && $d->format('Y-m-d') === $value) ? $value : $ctx->raise('inválido');
}
);
}
Expand Down
16 changes: 10 additions & 6 deletions src/Model/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ protected function validated_at(): Mutator
return new Mutator(
null,
function ($value, $ctx) {
if (is_null($value)) {
return null;
}

$d = \DateTime::createFromFormat('Y-m-d', $value);

return is_null($value) ||
($d && $d->format('Y-m-d') === $value) ?
$value : $ctx->raise('inválido');
return ($d && $d->format('Y-m-d') === $value) ? $value : $ctx->raise('inválido');
}
);
}
Expand Down Expand Up @@ -119,11 +121,13 @@ protected function expires_at(): Mutator
return new Mutator(
null,
function ($value, $ctx) {
if (is_null($value)) {
return null;
}

$d = \DateTime::createFromFormat('Y-m-d', $value);

return is_null($value) ||
($d && $d->format('Y-m-d') === $value) ?
$value : $ctx->raise('inválido');
return ($d && $d->format('Y-m-d') === $value) ? $value : $ctx->raise('inválido');
}
);
}
Expand Down