Skip to content

Commit

Permalink
[2.x] New version
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkGhostHunter committed Mar 6, 2024
1 parent 7c5d0c2 commit 977dbe7
Show file tree
Hide file tree
Showing 27 changed files with 109 additions and 331 deletions.
150 changes: 75 additions & 75 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,119 +9,119 @@ on:
jobs:

byte_level:
name: "0️⃣ Byte-level"
runs-on: "ubuntu-latest"
name: 0️⃣ Byte-level
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: "actions/checkout@v3"
- name: Checkout code
uses: actions/checkout@v4

- name: "Check file permissions"
- name: Check file permissions
run: |
test "$(find . -type f -not -path './.git/*' -executable)" == ""
- name: "Find non-printable ASCII characters"
test $(find . -type f -not -path './.git/*' -executable) ==
- name: Find non-printable ASCII characters
run: |
! LC_ALL=C.UTF-8 find ./src -type f -name "*.php" -print0 | xargs -0 -- grep -PHn "[^ -~]"
! LC_ALL=C.UTF-8 find ./src -type f -name *.php -print0 | xargs -0 -- grep -PHn [^ -~]
syntax_errors:
name: "1️⃣ Syntax errors"
runs-on: "ubuntu-latest"
name: 1️⃣ Syntax errors
runs-on: ubuntu-latest
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: "latest"
tools: "parallel-lint"
php-version: latest
tools: parallel-lint

- name: "Checkout code"
uses: "actions/checkout@v3"
- name: Checkout code
uses: actions/checkout@v4

- name: "Validate Composer configuration"
run: "composer validate --strict"
- name: Validate Composer configuration
run: composer validate --strict

- name: "Check source code for syntax errors"
run: "composer exec -- parallel-lint src/"
- name: Check source code for syntax errors
run: composer exec -- parallel-lint src/

unit_tests:
name: "2️⃣ Unit and Feature tests"
name: 2️⃣ Unit and Feature tests
needs:
- "byte_level"
- "syntax_errors"
runs-on: "ubuntu-latest"
- byte_level
- syntax_errors
runs-on: ubuntu-latest
strategy:
matrix:
php-version:
- "8.0"
- "8.1"
- "8.2"
- 8.1
- 8.2
- 8.3
laravel-constraint:
- "9.*"
- "10.*"
- 10.*
- 11.*
dependencies:
- "lowest"
- "highest"
- lowest
- highest
exclude:
- laravel-constraint: "10.*"
php-version: "8.0"
- laravel-constraint: 11.*
php-version: 8.1
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
extensions: "mbstring, intl"
coverage: "xdebug"
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
coverage: xdebug

- name: "Checkout code"
uses: "actions/checkout@v3"
- name: Checkout code
uses: actions/checkout@v4

- name: "Install dependencies"
uses: "ramsey/composer-install@v2"
- name: Install dependencies
uses: ramsey/composer-install@v3
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "--with=laravel/framework:${{ matrix.laravel-constraint }}"
dependency-versions: ${{ matrix.dependencies }}
composer-options: --with=laravel/framework:${{ matrix.laravel-constraint }}

- name: "Execute unit tests"
run: "composer run-script test"
- name: Execute unit tests
run: composer run-script test

- name: "Upload coverage to Codecov"
uses: "codecov/codecov-action@v3"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4

static_analysis:
name: "3️⃣ Static Analysis"
name: 3️⃣ Static Analysis
needs:
- "byte_level"
- "syntax_errors"
runs-on: "ubuntu-latest"
- byte_level
- syntax_errors
runs-on: ubuntu-latest
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
tools: "phpstan"
php-version: "latest"
coverage: "none"
tools: phpstan
php-version: latest
coverage: none

- name: "Checkout code"
uses: "actions/checkout@v3"
- name: Checkout code
uses: actions/checkout@v4

- name: "Install dependencies"
uses: "ramsey/composer-install@v2"
- name: Install dependencies
uses: ramsey/composer-install@v3

- name: "Execute static analysis"
run: "composer exec -- phpstan analyze -l 5 src/"
- name: Execute static analysis
run: composer exec -- phpstan analyze -l 5 src/

exported_files:
name: "4️⃣ Exported files"
name: 4️⃣ Exported files
needs:
- "byte_level"
- "syntax_errors"
runs-on: "ubuntu-latest"
- byte_level
- syntax_errors
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: "actions/checkout@v3"
- name: Checkout code
uses: actions/checkout@v4

- name: "Check exported files"
- name: Check exported files
run: |
EXPECTED="LICENSE.md,README.md,composer.json"
CURRENT="$(git archive HEAD | tar --list --exclude="src" --exclude="src/*" --exclude=".stubs" --exclude=".stubs/*" --exclude="routes" --exclude="routes/*" --exclude="stubs" --exclude="stubs/*" --exclude="lang" --exclude="lang/*" --exclude="config" --exclude="config/*" --exclude="database" --exclude="database/*" --exclude="resources" --exclude="resources/*" | paste -s -d ",")"
echo "CURRENT =${CURRENT}"
echo "EXPECTED=${EXPECTED}"
test "${CURRENT}" == "${EXPECTED}"
EXPECTED=LICENSE.md,README.md,composer.json
CURRENT=$(git archive HEAD | tar --list --exclude=src --exclude=src/* --exclude=.stubs --exclude=.stubs/* --exclude=routes --exclude=routes/* --exclude=stubs --exclude=stubs/* --exclude=lang --exclude=lang/* --exclude=config --exclude=config/* --exclude=database --exclude=database/* --exclude=resources --exclude=resources/* | paste -s -d ,)
echo CURRENT =${CURRENT}
echo EXPECTED=${EXPECTED}
test ${CURRENT} == ${EXPECTED}
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public function confirm(WebpayRequest $payment)
}
```

> [!NOTE]
>
> Only supports Webpay at the moment. Webpay Mall and Oneclick Mall are planned based on support.
## Become a sponsor
Expand All @@ -35,8 +37,7 @@ Your support allows me to keep this package free, up-to-date and maintainable. A

## Requisites:

* Laravel 9.x, or later
* PHP 8.0 or later
* Laravel 10, or later

# Installation

Expand Down Expand Up @@ -101,6 +102,8 @@ To operate in production mode, where all transaction will be real, you will need
TRANSBANK_ENV=production
```

> [!NOTE]
>
> Production keys don't work on _integration_ and vice versa.
## Middleware endpoint protection
Expand Down Expand Up @@ -153,7 +156,9 @@ Route::get('failed-transaction', function () {
RouteRedirect::as('confirm', 'failed-transaction');
```

> If you're using a different middleware to verify CSRF tokens, set the class in `RouteRedirect::$csrfMiddleware`.
> [!IMPORTANT]
>
> If you're using you own middleware to verify CSRF/XSRF tokens, set the class in `RouteRedirect::$csrfMiddleware`.
## Events

Expand All @@ -167,6 +172,8 @@ You will be able to hear all transactions started and completed. This package se

All exceptions implement `TransbankException`, so you can easily catch and check what happened.

> [!IMPORTANT]
>
> Transactions properly rejected by banks or credit card issuers **do not** throw exceptions.
There are 4 types of exceptions:
Expand Down
13 changes: 6 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Easy-to-use Transbank SDK for PHP.",
"type": "library",
"license": "MIT",
"minimum-stability": "stable",
"minimum-stability": "dev",
"prefer-stable": true,
"keywords": [
"payments",
Expand All @@ -26,16 +26,15 @@
"issues": "https://github.com/Laragear/Transbank/issues"
},
"require": {
"php": "8.*",
"php": "^8.1",
"ext-json": "*",
"illuminate/http": "9.*|10.*",
"illuminate/log": "9.*|10.*",
"illuminate/events": "9.*|10.*",
"illuminate/http": "10.*|11.*",
"illuminate/log": "10.*|11.*",
"illuminate/events": "10.*|11.*",
"guzzlehttp/guzzle": "^7.5"
},
"require-dev": {
"orchestra/testbench": "^7.22|8.*",
"jetbrains/phpstorm-attributes": "*"
"orchestra/testbench": "8.*|9.*"
},
"autoload": {
"psr-4": {
Expand Down
10 changes: 6 additions & 4 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd" cacheDirectory=".phpunit.cache">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
</report>
Expand All @@ -19,4 +16,9 @@
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
<env name="DB_CONNECTION" value="testing"/>
</php>
<source>
<include>
<directory>src/</directory>
</include>
</source>
</phpunit>
22 changes: 0 additions & 22 deletions src/ApiRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ class ApiRequest implements JsonSerializable, ArrayAccess, Jsonable
{
/**
* Create a new API Request instance.
*
* @param string $service
* @param string $action
* @param array $attributes
*/
public function __construct(public string $service, public string $action, public array $attributes = [])
{
Expand All @@ -23,9 +19,6 @@ public function __construct(public string $service, public string $action, publi

/**
* Convert the object to its JSON representation.
*
* @param int $options
* @return string
*/
public function toJson($options = 0): string
{
Expand All @@ -38,8 +31,6 @@ public function toJson($options = 0): string

/**
* Specify data which should be serialized to JSON.
*
* @return array
*/
public function jsonSerialize(): array
{
Expand All @@ -48,9 +39,6 @@ public function jsonSerialize(): array

/**
* Whether an offset exists.
*
* @param mixed $offset
* @return bool
*/
public function offsetExists(mixed $offset): bool
{
Expand All @@ -59,9 +47,6 @@ public function offsetExists(mixed $offset): bool

/**
* Offset to retrieve.
*
* @param mixed $offset
* @return mixed
*/
public function offsetGet(mixed $offset): mixed
{
Expand All @@ -70,10 +55,6 @@ public function offsetGet(mixed $offset): mixed

/**
* Offset to set.
*
* @param mixed $offset
* @param mixed $value
* @return void
*/
public function offsetSet(mixed $offset, mixed $value): void
{
Expand All @@ -82,9 +63,6 @@ public function offsetSet(mixed $offset, mixed $value): void

/**
* Offset to unset.
*
* @param mixed $offset
* @return void
*/
public function offsetUnset(mixed $offset): void
{
Expand Down
3 changes: 0 additions & 3 deletions src/Events/TransactionCompleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ class TransactionCompleted
{
/**
* Create a new Transaction Completed event.
*
* @param \Laragear\Transbank\ApiRequest $apiRequest Data sent to Transbank.
* @param \Laragear\Transbank\Services\Transactions\Transaction $transaction
*/
public function __construct(public ApiRequest $apiRequest, public Transaction $transaction)
{
Expand Down
3 changes: 0 additions & 3 deletions src/Events/TransactionCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ class TransactionCreated
{
/**
* Create a new Transaction Created event.
*
* @param \Laragear\Transbank\ApiRequest $apiRequest Data sent to Transbank.
* @param \Laragear\Transbank\Services\Transactions\Response $response Raw response from Transbank.
*/
public function __construct(public ApiRequest $apiRequest, public Response $response)
{
Expand Down
2 changes: 0 additions & 2 deletions src/Events/TransactionCreating.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ class TransactionCreating
{
/**
* Create a new Transaction Creating event.
*
* @param \Laragear\Transbank\ApiRequest $apiRequest
*/
public function __construct(public ApiRequest $apiRequest)
{
Expand Down
Loading

0 comments on commit 977dbe7

Please sign in to comment.