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
71 changes: 64 additions & 7 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ on:
permissions:
contents: read

env:
# pin a Code Climate test-reporter release to avoid "latest" redirects returning HTML
CC_TEST_REPORTER_VERSION: v0.11.1

jobs:

phpunit:

runs-on: ubuntu-latest

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

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -31,13 +32,69 @@ jobs:
- name: Install Composer Dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Code Climate Setup
- name: Download Code Climate test-reporter
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
set -euo pipefail
echo "Downloading test-reporter from CodeClimate v${CC_TEST_REPORTER_VERSION}"
curl -fsSL "https://github.com/codeclimate/test-reporter/releases/download/${CC_TEST_REPORTER_VERSION}/artifacts.tar.gz" -o artifacts.tar.gz || { echo "curl failed"; exit 1; }
# Extract the linux-amd64 binary from the artifacts
tar -xf artifacts.tar.gz ./artifacts/bin/test-reporter-${CC_TEST_REPORTER_VERSION#v}-linux-amd64
mv ./artifacts/bin/test-reporter-${CC_TEST_REPORTER_VERSION#v}-linux-amd64 ./cc-test-reporter
chmod +x ./cc-test-reporter
rm -rf artifacts.tar.gz artifacts/
# Verify the binary works
./cc-test-reporter --version

- name: Check CodeClimate Configuration
run: |
if [ -z "${{ env.CC_TEST_REPORTER_ID }}" ]; then
echo "WARNING: CC_TEST_REPORTER_ID is not set. CodeClimate reporting will be skipped."
else
echo "CodeClimate Reporter ID is configured (length: ${#CC_TEST_REPORTER_ID})"
fi

- name: Code Climate before-build
if: env.CC_TEST_REPORTER_ID != ''
run: |
echo "Initializing CodeClimate test reporter..."
./cc-test-reporter before-build || {
echo "CodeClimate before-build failed, but continuing..."
exit 0
}

- name: Run Tests
run: |
php vendor/bin/phpunit --color --testdox --coverage-clover clover.xml tests
echo "TEST_EXIT_CODE=$?" >> $GITHUB_ENV

- name: Verify coverage file
run: |
if [ -f clover.xml ]; then
echo "Coverage file generated successfully"
ls -la clover.xml
head -5 clover.xml
else
echo "Coverage file not found!"
exit 1
fi

- name: Send Report
if: env.CC_TEST_REPORTER_ID != ''
run: |
./cc-test-reporter after-build -t clover --exit-code $?
if [ -f clover.xml ]; then
echo "Sending coverage report to CodeClimate..."
echo "File size: $(wc -l < clover.xml) lines"
echo "Exit code: $TEST_EXIT_CODE"

# Enable debug mode to see what's happening
./cc-test-reporter after-build -d -t clover --exit-code $TEST_EXIT_CODE || {
echo "CodeClimate upload failed. This might be due to:"
echo "1. Invalid CC_TEST_REPORTER_ID"
echo "2. Network issues"
echo "3. CodeClimate API problems"
echo "Continuing without failing the build..."
exit 0
}
else
echo "No coverage file found, skipping CodeClimate report"
fi
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ composer.phar
.devcontainer
.vscode
Dockerfile
*docker*
annotations.md
.phpunit.cache
clover.xml
6 changes: 3 additions & 3 deletions examples/checkout/00-create-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
],
'split_rules' => [
[
'receiver' => 'vendedor1@email.com',
'seller_id' => '1000000',
'percentage' => '50',
'charge_processing_fee' => true,
],
[
'receiver' => 'vendedor2@email.com',
'seller_id' => '1000001',
'percentage' => '20'
]
],
Expand Down Expand Up @@ -86,4 +86,4 @@
var_dump($error);
echo "</pre>" . PHP_EOL;

}
}
3 changes: 2 additions & 1 deletion examples/customer/00-customer-create.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'name' => 'Bruce Wayne',
'email' => 'brucewayne@email.com',
'cpf_cnpj' => '490.558.550-30',
'tax_id' => '49055855030',
'phone' => '(22) 2222-33333',
'business_name' => 'Wayne Enterprises',
'birthdate' => '1987-02-19',
Expand Down Expand Up @@ -43,4 +44,4 @@
var_dump($error);
echo "</pre>" . PHP_EOL;

}
}
3 changes: 2 additions & 1 deletion examples/customer/01-customer-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'name' => 'Arthur Morgan',
'email' => 'arthurmorgan@email.com',
'cpf_cnpj' => '212.348.796-11',
'tax_id' => '49055855030',
'phone' => '(11) 2222-3333',
'business_name' => 'Arthur Morgan Ltda.',
'birthdate' => '1987-11-21',
Expand Down Expand Up @@ -46,4 +47,4 @@
var_dump($error);
echo "</pre>" . PHP_EOL;

}
}
10 changes: 6 additions & 4 deletions examples/payment/00-payment-create-card-simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
[
'amount' => 100,
'callback_url' => 'https://ipag-sdk.requestcatcher.com/callback',
'redirect_url' => 'https://ipag-sdk.requestcatcher.com/redirect',
'order_id' => '12345679',
'merchant_id' => '12345678',
'payment' => [
'type' => Ipag\Sdk\Core\Enums\PaymentTypes::CARD,
'method' => Ipag\Sdk\Core\Enums\Cards::VISA,
Expand Down Expand Up @@ -42,7 +44,7 @@
// Faça algo aqui...
break;
default:
// Faça algo aqui...
// Faça algo aqui...
}

// Verifica o status retornado do gateway de pagamento
Expand All @@ -51,7 +53,7 @@
// Faça algo aqui...
break;
default:
// Faça algo aqui...
// Faça algo aqui...
}

// Verifica o status retornado da Adquirente de pagamento
Expand All @@ -60,7 +62,7 @@
// Faça algo aqui...
break;
default:
// Faça algo aqui...
// Faça algo aqui...
}

echo "Status do Pagamento retornado: {$statusPayment}" . PHP_EOL;
Expand All @@ -86,4 +88,4 @@
var_dump($error);
echo "</pre>" . PHP_EOL;

}
}
11 changes: 7 additions & 4 deletions examples/payment/01-payment-create-card-complete.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
[
'amount' => 10000,
'callback_url' => 'https://ipag-sdk.requestcatcher.com/callback',
'redirect_url' => 'https://ipag-sdk.requestcatcher.com/redirect',
'merchant_id' => '12345678',
'payment' => [
'type' => Ipag\Sdk\Core\Enums\PaymentTypes::CARD,
'method' => Ipag\Sdk\Core\Enums\Cards::VISA,
'installments' => 1,
'capture' => false,
'softdescriptor' => 'BRUCE ENTER',
'fraud_analysis' => true,
'recurring' => true,
'card' => [
'holder' => 'Bruce Wayne',
'number' => '4111 1111 1111 1111',
Expand Down Expand Up @@ -74,7 +77,7 @@
// Faça algo aqui...
break;
default:
// Faça algo aqui...
// Faça algo aqui...
}

// Verifica o status retornado do gateway de pagamento
Expand All @@ -83,7 +86,7 @@
// Faça algo aqui...
break;
default:
// Faça algo aqui...
// Faça algo aqui...
}

// Verifica o status retornado da Adquirente de pagamento
Expand All @@ -92,7 +95,7 @@
// Faça algo aqui...
break;
default:
// Faça algo aqui...
// Faça algo aqui...
}

echo "Status do Pagamento retornado: {$statusPayment}" . PHP_EOL;
Expand All @@ -118,4 +121,4 @@
var_dump($error);
echo "</pre>" . PHP_EOL;

}
}
10 changes: 6 additions & 4 deletions examples/payment/02-payment-create-card-foreign-customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
[
'amount' => 100,
'callback_url' => 'https://ipag-sdk.requestcatcher.com/callback',
'redirect_url' => 'https://ipag-sdk.requestcatcher.com/redirect',
'merchant_id' => '12345678',
'order_id' => '1234567',
'payment' => [
'type' => Ipag\Sdk\Core\Enums\PaymentTypes::CARD,
Expand Down Expand Up @@ -41,7 +43,7 @@
// Faça algo aqui...
break;
default:
// Faça algo aqui...
// Faça algo aqui...
}

// Verifica o status retornado do gateway de pagamento
Expand All @@ -50,7 +52,7 @@
// Faça algo aqui...
break;
default:
// Faça algo aqui...
// Faça algo aqui...
}

// Verifica o status retornado da Adquirente de pagamento
Expand All @@ -59,7 +61,7 @@
// Faça algo aqui...
break;
default:
// Faça algo aqui...
// Faça algo aqui...
}

echo "Status do Pagamento retornado: {$statusPayment}" . PHP_EOL;
Expand All @@ -85,4 +87,4 @@
var_dump($error);
echo "</pre>" . PHP_EOL;

}
}
10 changes: 6 additions & 4 deletions examples/payment/03-payment-create-card-for-event.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
[
'amount' => 100,
'callback_url' => 'https://ipag-sdk.requestcatcher.com/callback',
'redirect_url' => 'https://ipag-sdk.requestcatcher.com/redirect',
'merchant_id' => '12345678',
'order_id' => '123456789',
'payment' => [
'type' => Ipag\Sdk\Core\Enums\PaymentTypes::CARD,
Expand Down Expand Up @@ -79,7 +81,7 @@
// Faça algo aqui...
break;
default:
// Faça algo aqui...
// Faça algo aqui...
}

// Verifica o status retornado do gateway de pagamento
Expand All @@ -88,7 +90,7 @@
// Faça algo aqui...
break;
default:
// Faça algo aqui...
// Faça algo aqui...
}

// Verifica o status retornado da Adquirente de pagamento
Expand All @@ -97,7 +99,7 @@
// Faça algo aqui...
break;
default:
// Faça algo aqui...
// Faça algo aqui...
}

echo "Status do Pagamento retornado: {$statusPayment}" . PHP_EOL;
Expand All @@ -123,4 +125,4 @@
var_dump($error);
echo "</pre>" . PHP_EOL;

}
}
10 changes: 6 additions & 4 deletions examples/payment/04-payment-create-bankslip.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
[
"amount" => 7000,
"callback_url" => "https://ipag-sdk.requestcatcher.com/callback",
'redirect_url' => 'https://ipag-sdk.requestcatcher.com/redirect',
'merchant_id' => '12345678',
"payment" => [
"type" => Ipag\Sdk\Core\Enums\PaymentTypes::BOLETO,
"method" => Ipag\Sdk\Core\Enums\BankSlips::SIMULADO,
Expand Down Expand Up @@ -79,7 +81,7 @@
// Faça algo aqui...
break;
default:
// Faça algo aqui...
// Faça algo aqui...
}

// Verifica o status retornado do gateway de pagamento
Expand All @@ -88,7 +90,7 @@
// Faça algo aqui...
break;
default:
// Faça algo aqui...
// Faça algo aqui...
}

// Verifica o status retornado da Adquirente de pagamento
Expand All @@ -97,7 +99,7 @@
// Faça algo aqui...
break;
default:
// Faça algo aqui...
// Faça algo aqui...
}

echo "Status do Pagamento retornado: {$statusPayment}" . PHP_EOL;
Expand All @@ -124,4 +126,4 @@
var_dump($error);
echo "</pre>" . PHP_EOL;

}
}
Loading