Skip to content

Commit d8e00cc

Browse files
authored
[PAYSHIP-3719] Reauthorize order authorization (#1436)
* feat(api): introduce reauthorization support for PayPal payments - Added `ReauthorizeAuthorizationAction` to handle the reauthorization process for PayPal orders. - Implemented DTO classes, including `AuthorizationStatus`, `AuthorizationLinkRelation`, `ReauthorizeAuthorizationRequestDto`, and `PaymentAuthorizationResponseDto`. - Extended `PaymentHttpClient` to support fetching and reauthorizing authorizations via PayPal API. - Modified `PayPalOrderResponse` to return order authorizations and related details. These changes enable the handling of reauthorization logic for PayPal payments. * chore: integrate PHP-CS-Fixer and consolidate lint workflows - Removed `php-cs-fix.yml` CI workflow and replaced it with consolidated `lint.yml`. - Updated PHP-CS-Fixer rules and paths in `.php-cs-fixer.php`. - Added new composer scripts (`cs`, `cs:fix`, `cs:ci`) for running code style checks and autofixes. - Updated `Makefile` to use composer scripts for PHP-CS-Fixer. - Added `.php-cs-fixer.cache` to `.gitignore`. - Updated `composer.json` and `composer.lock` to include PHP-CS-Fixer as a dev dependency. * chore: update composer dependencies and lock file - Added `composer.lock` file to ensure consistent dependency versions. * chore: clean up unused imports and fix/ignore phpstan issues * chore: apply reviews
1 parent 5da1f92 commit d8e00cc

File tree

79 files changed

+8071
-997
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+8071
-997
lines changed

.github/workflows/cs-fix.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
1-
name: PHPStan
1+
name: Lint
22

33
on:
44
pull_request:
55
push:
66
branches:
7-
- main
7+
- 'main'
88
- '5.*'
99

1010
jobs:
11-
prestashop:
12-
name: ${{ matrix.ps-version }}
11+
php-cs-fixer:
12+
name: PHP CS Fixer
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v6
16+
- uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: '8.5'
19+
tools: cs2pr
20+
- run: composer install
21+
- run: composer cs:ci | cs2pr
22+
23+
phpstan:
24+
name: PHPStan / ${{ matrix.ps-version }}
1325
strategy:
1426
matrix:
1527
ps-version: ['ps17', 'ps8', 'ps9']
@@ -24,4 +36,4 @@ jobs:
2436
- run: |
2537
composer install --ignore-platform-reqs
2638
composer phpstan:ci
27-
working-directory: ${{ matrix.ps-version }}
39+
working-directory: ${{ matrix.ps-version }}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ mysql
66
vendor
77
*/vendor
88
*/.phpunit.result.cache
9+
.php-cs-fixer.cache
910
*/.php-cs-fixer.cache
1011
*/.php_cs.cache
1112
**/.phpunit.result.cache
1213
.cloudflared.yml
13-
docker-compose.local.yml
14+
docker-compose.local.yml
15+
composer2.2.phar

.php-cs-fixer.php

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,52 @@
11
<?php
22

3-
$config = new PhpCsFixer\Config();
4-
5-
$finder = $config->getFinder();
6-
$finder->in([__DIR__]); // This includes everything in the current directory (the root directory)
7-
$finder->notName('index.php');
8-
9-
return $config->setRules([
10-
'@PSR2' => true,
11-
'class_attributes_separation' => true,
12-
'blank_line_before_statement' => [
13-
'statements' => ['return', 'throw', 'continue', 'break', 'declare', 'exit'],
14-
],
15-
]);
3+
declare(strict_types=1);
4+
5+
use PhpCsFixer\Config;
6+
use PhpCsFixer\Finder;
7+
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
8+
9+
$header = <<<'EOF'
10+
Copyright since 2007 PrestaShop SA and Contributors
11+
PrestaShop is an International Registered Trademark & Property of PrestaShop SA
12+
13+
NOTICE OF LICENSE
14+
15+
This source file is subject to the Academic Free License version 3.0
16+
that is bundled with this package in the file LICENSE.md.
17+
It is also available through the world-wide-web at this URL:
18+
https://opensource.org/licenses/AFL-3.0
19+
If you did not receive a copy of the license and are unable to
20+
obtain it through the world-wide-web, please send an email
21+
to [email protected] so we can send you a copy immediately.
22+
23+
@author PrestaShop SA and Contributors <[email protected]>
24+
@copyright Since 2007 PrestaShop SA and Contributors
25+
@license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
26+
EOF;
27+
28+
return (new Config())
29+
->setParallelConfig(ParallelConfigFactory::detect())
30+
->setRiskyAllowed(false)
31+
->setRules([
32+
'@PSR2' => true,
33+
'no_unused_imports' => true,
34+
'class_attributes_separation' => true,
35+
'blank_line_before_statement' => [
36+
'statements' => ['return', 'throw', 'continue', 'break', 'declare', 'exit'],
37+
],
38+
'header_comment' => [
39+
'header' => $header,
40+
'comment_type' => 'PHPDoc',
41+
'separate' => 'bottom',
42+
'location' => 'after_open'
43+
]
44+
])
45+
// 💡 by default, Fixer looks for `*.php` files excluding `./vendor/` - here, you can groom this config
46+
->setFinder(
47+
(new Finder())
48+
// 💡 root folder to check
49+
->in(['api', 'core', 'infrastructure', 'presentation', 'utility'])
50+
->notName(['index.php'])
51+
)
52+
;

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@ down:
2020
docker compose down --remove-orphans --volumes
2121

2222
php-cs-fixer:
23-
docker exec -i $${MODULE_VERSION}-ps-prestashop-$${PS_VERSION_TAG} /bin/bash -c "cd modules/ps_checkout && php vendor/bin/php-cs-fixer fix"
23+
composer cs:fix
2424

2525
autoindex:
2626
docker exec -i $${MODULE_VERSION}-ps-prestashop-$${PS_VERSION_TAG} /bin/bash -c "cd modules/ps_checkout && php vendor/bin/autoindex prestashop:add:index /var/www/html/modules/ps_checkout && php vendor/bin/autoindex prestashop:add:index /var/www/html/modules/ps_checkout/vendor"
2727

2828
add-header-stamp:
2929
docker exec -i $${MODULE_VERSION}-ps-prestashop-$${PS_VERSION_TAG} /bin/bash -c "cd modules/ps_checkout && php vendor/bin/header-stamp --license=vendor/prestashop/header-stamp/assets/afl.txt"
3030

31-
lint: php-cs-fixer autoindex add-header-stamp
31+
lint: php-cs-fixer autoindex
32+
33+
php-unit-api:
34+
docker exec -i $${MODULE_VERSION}-ps-prestashop-$${PS_VERSION_TAG} bash -c "php modules/ps_checkout/vendor/bin/phpunit --configuration=modules/ps_checkout/vendor/invertus/api/tests/phpunit.xml --bootstrap=modules/ps_checkout/vendor/invertus/api/tests/bootstrap.php"
3235

3336
php-unit-infrastructure:
3437
docker exec -i $${MODULE_VERSION}-ps-prestashop-$${PS_VERSION_TAG} bash -c "php modules/ps_checkout/vendor/bin/phpunit --configuration=modules/ps_checkout/vendor/invertus/infrastructure/tests/phpunit.xml --bootstrap=modules/ps_checkout/vendor/invertus/infrastructure/tests/bootstrap.php"
@@ -42,7 +45,7 @@ php-unit-core:
4245
php-unit-presentation:
4346
docker exec -i $${MODULE_VERSION}-ps-prestashop-$${PS_VERSION_TAG} bash -c "php modules/ps_checkout/vendor/bin/phpunit --configuration=modules/ps_checkout/vendor/invertus/presentation/tests/phpunit.xml --bootstrap=modules/ps_checkout/vendor/invertus/presentation/tests/bootstrap.php"
4447

45-
unit-test: php-unit-utility php-unit-core php-unit-presentation
48+
unit-test: php-unit-api php-unit-utility php-unit-core php-unit-presentation
4649

4750
php-integration:
4851
docker exec -i $${MODULE_VERSION}-ps-prestashop-$${PS_VERSION_TAG} bash -c "php modules/ps_checkout/vendor/bin/phpunit --configuration=modules/ps_checkout/tests/phpunit-integration.xml --bootstrap=modules/ps_checkout/tests/bootstrap-integration.php"

api/monorepo.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,11 @@
55
"psr-4": {
66
"PsCheckout\\Api\\": "src/"
77
}
8+
},
9+
"autoload-dev": {
10+
"psr-4": {
11+
"PsCheckout\\Tests\\Api\\Integration\\": "tests/Integration/",
12+
"PsCheckout\\Tests\\Api\\Unit\\": "tests/Unit/"
13+
}
814
}
915
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?php
2+
/**
3+
* Copyright since 2007 PrestaShop SA and Contributors
4+
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
5+
*
6+
* NOTICE OF LICENSE
7+
*
8+
* This source file is subject to the Academic Free License version 3.0
9+
* that is bundled with this package in the file LICENSE.md.
10+
* It is also available through the world-wide-web at this URL:
11+
* https://opensource.org/licenses/AFL-3.0
12+
* If you did not receive a copy of the license and are unable to
13+
* obtain it through the world-wide-web, please send an email
14+
* to [email protected] so we can send you a copy immediately.
15+
*
16+
* @author PrestaShop SA and Contributors <[email protected]>
17+
* @copyright Since 2007 PrestaShop SA and Contributors
18+
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
19+
*/
20+
21+
namespace PsCheckout\Api\Dto\PayPal;
22+
23+
class LinkDescription
24+
{
25+
/**
26+
* @var string
27+
*/
28+
private $href;
29+
30+
/**
31+
* @var string
32+
*/
33+
private $rel;
34+
35+
/**
36+
* @var string|null
37+
*/
38+
private $method;
39+
40+
/**
41+
* @param string $href
42+
* @param string $rel
43+
* @param string|null $method
44+
*/
45+
public function __construct(string $href, string $rel, ?string $method)
46+
{
47+
$this->href = $href;
48+
$this->rel = $rel;
49+
$this->method = $method;
50+
}
51+
52+
/**
53+
* Returns Href.
54+
* The complete target URL. To make the related call, combine the method with this [URI Template-
55+
* formatted](https://tools.ietf.org/html/rfc6570) link. For pre-processing, include the `$`, `(`, and
56+
* `)` characters. The `href` is the key HATEOAS component that links a completed call with a
57+
* subsequent call.
58+
*/
59+
public function getHref(): string
60+
{
61+
return $this->href;
62+
}
63+
64+
/**
65+
* Sets Href.
66+
* The complete target URL. To make the related call, combine the method with this [URI Template-
67+
* formatted](https://tools.ietf.org/html/rfc6570) link. For pre-processing, include the `$`, `(`, and
68+
* `)` characters. The `href` is the key HATEOAS component that links a completed call with a
69+
* subsequent call.
70+
*
71+
* @required
72+
* @maps href
73+
*/
74+
public function setHref(string $href): void
75+
{
76+
$this->href = $href;
77+
}
78+
79+
/**
80+
* Returns Rel.
81+
* The [link relation type](https://tools.ietf.org/html/rfc5988#section-4), which serves as an ID for a
82+
* link that unambiguously describes the semantics of the link. See [Link Relations](https://www.iana.
83+
* org/assignments/link-relations/link-relations.xhtml).
84+
*/
85+
public function getRel(): string
86+
{
87+
return $this->rel;
88+
}
89+
90+
/**
91+
* Sets Rel.
92+
* The [link relation type](https://tools.ietf.org/html/rfc5988#section-4), which serves as an ID for a
93+
* link that unambiguously describes the semantics of the link. See [Link Relations](https://www.iana.
94+
* org/assignments/link-relations/link-relations.xhtml).
95+
*
96+
* @required
97+
* @maps rel
98+
*/
99+
public function setRel(string $rel): void
100+
{
101+
$this->rel = $rel;
102+
}
103+
104+
/**
105+
* Returns Method.
106+
* The HTTP method required to make the related call.
107+
*/
108+
public function getMethod(): ?string
109+
{
110+
return $this->method;
111+
}
112+
113+
/**
114+
* Sets Method.
115+
* The HTTP method required to make the related call.
116+
*
117+
* @maps method
118+
*/
119+
public function setMethod(?string $method): void
120+
{
121+
$this->method = $method;
122+
}
123+
}

0 commit comments

Comments
 (0)