From adb6c6daff0ec1e8b5d3e4245a4dfa720e541f6a Mon Sep 17 00:00:00 2001 From: sunaoka Date: Thu, 27 Apr 2023 14:11:46 +0900 Subject: [PATCH 1/8] Update config/amazon-pay.php --- config/amazon-pay.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/amazon-pay.php b/config/amazon-pay.php index f25af53..7643fba 100644 --- a/config/amazon-pay.php +++ b/config/amazon-pay.php @@ -1,7 +1,7 @@ (bool)env('AMAZON_PAY_SANDBOX', 'true'), + 'sandbox' => (bool)env('AMAZON_PAY_SANDBOX', true), 'merchant_id' => env('AMAZON_PAY_MERCHANT_ID'), 'store_id' => env('AMAZON_PAY_STORE_ID'), 'public_key_id' => env('AMAZON_PAY_PUBLIC_KEY_ID'), From 105077ebf390a1683802130fee1bfe25ee647d5a Mon Sep 17 00:00:00 2001 From: sunaoka Date: Thu, 27 Apr 2023 14:12:07 +0900 Subject: [PATCH 2/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9791cbb..580326c 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ The settings can be found in the generated `config/amazon-pay.php` configuration (bool)env('AMAZON_PAY_SANDBOX', 'true'), + 'sandbox' => (bool)env('AMAZON_PAY_SANDBOX', true), 'merchant_id' => env('AMAZON_PAY_MERCHANT_ID'), 'store_id' => env('AMAZON_PAY_STORE_ID'), 'public_key_id' => env('AMAZON_PAY_PUBLIC_KEY_ID'), From 073509543d20c21b4bbeb958d051bb79168b855f Mon Sep 17 00:00:00 2001 From: sunaoka Date: Tue, 8 Aug 2023 18:15:32 +0900 Subject: [PATCH 3/8] Added tests for PHP 8.3. --- .github/workflows/test.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 64f7903..50db504 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest ] - php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ] + php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ] laravel: [ 6, 7, 8, 9, 10 ] exclude: - php: 7.2 @@ -42,6 +42,12 @@ jobs: laravel: 7 - php: 8.2 laravel: 8 + - php: 8.3 + laravel: 6 + - php: 8.3 + laravel: 7 + - php: 8.3 + laravel: 8 name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} From fb705a4e0629e6c2d6c0f2047855701dda7e0733 Mon Sep 17 00:00:00 2001 From: sunaoka Date: Thu, 30 Nov 2023 11:22:37 +0900 Subject: [PATCH 4/8] Housekeeping --- .phpstan/classAliases.php | 3 +++ phpstan.neon.dist | 8 ++++++++ tests/AmazonPayServiceProviderTest.php | 4 ++++ tests/TestCase.php | 14 +++++++++++--- 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 .phpstan/classAliases.php diff --git a/.phpstan/classAliases.php b/.phpstan/classAliases.php new file mode 100644 index 0000000..764588b --- /dev/null +++ b/.phpstan/classAliases.php @@ -0,0 +1,3 @@ +> */ protected function getPackageProviders($app): array { @@ -20,7 +24,11 @@ protected function getPackageProviders($app): array } /** - * @inerhitDoc + * Get package aliases. + * + * @param \Illuminate\Foundation\Application $app + * + * @return array> */ protected function getPackageAliases($app): array { @@ -30,7 +38,7 @@ protected function getPackageAliases($app): array } /** - * @inerhitDoc + * @param \Illuminate\Foundation\Application|array{config: \Illuminate\Config\Repository} $app */ protected function defineEnvironment($app): void { From 4eeeedbda73bd45ebfc486bf80885c2f2af8c949 Mon Sep 17 00:00:00 2001 From: sunaoka Date: Thu, 30 Nov 2023 11:27:49 +0900 Subject: [PATCH 5/8] Update GitHub Actions --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 50db504..4e9a52b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -60,7 +60,7 @@ jobs: tools: composer:v2 - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install dependencies run: | From 89486157a6e144b4d32753158e44d7ce964be675 Mon Sep 17 00:00:00 2001 From: sunaoka Date: Wed, 13 Mar 2024 16:05:07 +0900 Subject: [PATCH 6/8] Update GitHub Actions --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4e9a52b..fcdeadf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -75,7 +75,7 @@ jobs: run: vendor/bin/phpunit --coverage-clover=coverage.xml - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} files: ./coverage.xml From 01b59867a58cbfb7eee714a54b1b7f3a4b85cee2 Mon Sep 17 00:00:00 2001 From: sunaoka Date: Wed, 13 Mar 2024 16:16:07 +0900 Subject: [PATCH 7/8] Format source code --- config/amazon-pay.php | 24 ++++++------- src/Client.php | 42 +++++++++-------------- src/Facade/AmazonPay.php | 10 +++--- src/Provider/AmazonPayServiceProvider.php | 5 +-- tests/AmazonPayServiceProviderTest.php | 31 ++++++++--------- tests/TestCase.php | 10 +++--- 6 files changed, 54 insertions(+), 68 deletions(-) diff --git a/config/amazon-pay.php b/config/amazon-pay.php index 7643fba..7814dd5 100644 --- a/config/amazon-pay.php +++ b/config/amazon-pay.php @@ -1,19 +1,19 @@ (bool)env('AMAZON_PAY_SANDBOX', true), - 'merchant_id' => env('AMAZON_PAY_MERCHANT_ID'), - 'store_id' => env('AMAZON_PAY_STORE_ID'), - 'public_key_id' => env('AMAZON_PAY_PUBLIC_KEY_ID'), - 'private_key' => env('AMAZON_PAY_PRIVATE_KEY'), - 'region' => env('AMAZON_PAY_REGION'), - 'language' => env('AMAZON_PAY_LANGUAGE'), - 'currency_code' => env('AMAZON_PAY_CURRENCY_CODE'), - 'algorithm' => env('AMAZON_PAY_ALGORITHM'), + 'sandbox' => (bool) env('AMAZON_PAY_SANDBOX', true), + 'merchant_id' => env('AMAZON_PAY_MERCHANT_ID'), + 'store_id' => env('AMAZON_PAY_STORE_ID'), + 'public_key_id' => env('AMAZON_PAY_PUBLIC_KEY_ID'), + 'private_key' => env('AMAZON_PAY_PRIVATE_KEY'), + 'region' => env('AMAZON_PAY_REGION'), + 'language' => env('AMAZON_PAY_LANGUAGE'), + 'currency_code' => env('AMAZON_PAY_CURRENCY_CODE'), + 'algorithm' => env('AMAZON_PAY_ALGORITHM'), 'override_service_url' => env('AMAZON_PAY_OVERRIDE_SERVICE_URL'), - 'proxy' => !empty(env('AMAZON_PAY_PROXY_HOST')) ? [ - 'host' => env('AMAZON_PAY_PROXY_HOST'), - 'port' => env('AMAZON_PAY_PROXY_PORT'), + 'proxy' => ! empty(env('AMAZON_PAY_PROXY_HOST')) ? [ + 'host' => env('AMAZON_PAY_PROXY_HOST'), + 'port' => env('AMAZON_PAY_PROXY_PORT'), 'username' => env('AMAZON_PAY_PROXY_USERNAME'), 'password' => env('AMAZON_PAY_PROXY_PASSWORD'), ] : null, diff --git a/src/Client.php b/src/Client.php index 151d284..497f46b 100644 --- a/src/Client.php +++ b/src/Client.php @@ -33,7 +33,7 @@ class Client extends \Amazon\Pay\API\Client ]; /** - * @param array|null $config + * @param array|null $config * * @throws Exception */ @@ -51,7 +51,7 @@ public function __construct($config = null) throw new LogicException('The "region" is required'); } - if (!in_array(strtolower($config['region']), $this->availableRegions, true)) { + if (! in_array(strtolower($config['region']), $this->availableRegions, true)) { throw new LogicException("{$config['region']} is not a valid region"); } @@ -61,8 +61,6 @@ public function __construct($config = null) /** * Get Amazon Pay script URL * - * @return string - * * @throws Exception */ public function getAmazonPayScript(): string @@ -77,13 +75,11 @@ public function getAmazonPayScript(): string } /** - * @param string $method - * @param string $urlFragment - * @param string|array $payload - * @param array|null $headers - * @param array|null $queryParams - * - * @return array + * @param string $method + * @param string $urlFragment + * @param string|array $payload + * @param array|null $headers + * @param array|null $queryParams * * @throws Exception */ @@ -91,15 +87,15 @@ public function apiCall($method, $urlFragment, $payload, $headers = null, $query { if ($this->fakeResponse !== null) { $response = [ - 'status' => $this->fakeStatus, - 'method' => $method, - 'url' => $urlFragment, - 'headers' => $headers ?? [], - 'request' => is_array($payload) ? json_encode($payload) : $payload, - 'response' => json_encode($this->fakeResponse), + 'status' => $this->fakeStatus, + 'method' => $method, + 'url' => $urlFragment, + 'headers' => $headers ?? [], + 'request' => is_array($payload) ? json_encode($payload) : $payload, + 'response' => json_encode($this->fakeResponse), 'request_id' => Str::uuid()->toString(), - 'retries' => 0, - 'duration' => 0, + 'retries' => 0, + 'duration' => 0, ]; $this->fakeResponse = null; @@ -110,13 +106,7 @@ public function apiCall($method, $urlFragment, $payload, $headers = null, $query return parent::apiCall($method, $urlFragment, $payload, $headers, $queryParams); // @codeCoverageIgnore } - /** - * @param array|null $response - * @param int $status - * - * @return void - */ - public function fake(array $response = null, int $status = 200): void + public function fake(?array $response = null, int $status = 200): void { $this->fakeResponse = $response; $this->fakeStatus = $status; diff --git a/src/Facade/AmazonPay.php b/src/Facade/AmazonPay.php index 0fe3ba2..b6bb507 100644 --- a/src/Facade/AmazonPay.php +++ b/src/Facade/AmazonPay.php @@ -10,10 +10,10 @@ /** * @method static \Mockery\MockInterface spy() Convert the facade into a Mockery spy. * @method static \Mockery\MockInterface partialMock() Initiate a partial mock on the facade. - * @method static \Mockery\Expectation shouldReceive(string|array ...$methodNames) Initiate a mock expectation on the facade. - * @method static void swap($instance) Hotswap the underlying instance behind the facade. - * @method static void clearResolvedInstance(string $name) Clear a resolved facade instance. - * @method static void clearResolvedInstances() Clear all of the resolved instances. + * @method static \Mockery\Expectation shouldReceive(string|array ...$methodNames) Initiate a mock expectation on the facade. + * @method static void swap($instance) Hotswap the underlying instance behind the facade. + * @method static void clearResolvedInstance(string $name) Clear a resolved facade instance. + * @method static void clearResolvedInstances() Clear all of the resolved instances. * * @mixin Client */ @@ -21,8 +21,6 @@ class AmazonPay extends Facade { /** * Get the registered name of the component. - * - * @return string */ protected static function getFacadeAccessor(): string { diff --git a/src/Provider/AmazonPayServiceProvider.php b/src/Provider/AmazonPayServiceProvider.php index 2240218..8043d42 100644 --- a/src/Provider/AmazonPayServiceProvider.php +++ b/src/Provider/AmazonPayServiceProvider.php @@ -15,12 +15,13 @@ class AmazonPayServiceProvider extends ServiceProvider public function register(): void { $this->mergeConfigFrom( - dirname(__DIR__, 2) . '/config/amazon-pay.php', + dirname(__DIR__, 2).'/config/amazon-pay.php', 'amazon-pay' ); $this->app->singleton('AmazonPay', function ($app) { $config = $app->make('config')->get('amazon-pay'); + return new Client($config); }); @@ -34,7 +35,7 @@ public function boot(): void { if ($this->app->runningInConsole()) { $this->publishes( - [dirname(__DIR__, 2) . '/config/amazon-pay.php' => $this->app->configPath('amazon-pay.php')], + [dirname(__DIR__, 2).'/config/amazon-pay.php' => $this->app->configPath('amazon-pay.php')], 'amazon-pay-config' ); } diff --git a/tests/AmazonPayServiceProviderTest.php b/tests/AmazonPayServiceProviderTest.php index 6e9f3d3..1227a5e 100644 --- a/tests/AmazonPayServiceProviderTest.php +++ b/tests/AmazonPayServiceProviderTest.php @@ -21,19 +21,19 @@ public function testGetAmazonPayScript(): void public function testFake(): void { $fakeResponse = [ - 'refundId' => 'S01-5105180-3221187-R022311', - 'chargeId' => 'S01-5105180-3221187-C056351', - 'refundAmount' => [ - 'amount' => '14.00', - 'currencyCode' => 'USD' + 'refundId' => 'S01-5105180-3221187-R022311', + 'chargeId' => 'S01-5105180-3221187-C056351', + 'refundAmount' => [ + 'amount' => '14.00', + 'currencyCode' => 'USD', ], - 'softDescriptor' => 'Descriptor', - 'creationTimestamp' => '20190714T155300Z', - 'statusDetails' => [ - 'state' => 'RefundInitiated', - 'reasonCode' => null, - 'reasonDescription' => null, - 'lastUpdatedTimestamp' => '20190714T155300Z' + 'softDescriptor' => 'Descriptor', + 'creationTimestamp' => '20190714T155300Z', + 'statusDetails' => [ + 'state' => 'RefundInitiated', + 'reasonCode' => null, + 'reasonDescription' => null, + 'lastUpdatedTimestamp' => '20190714T155300Z', ], 'releaseEnvironment' => 'Sandbox', ]; @@ -41,9 +41,9 @@ public function testFake(): void \AmazonPay::fake($fakeResponse); $payload = [ - 'chargeId' => 'S01-5105180-3221187-C056351', - 'refundAmount' => [ - 'amount' => '14.00', + 'chargeId' => 'S01-5105180-3221187-C056351', + 'refundAmount' => [ + 'amount' => '14.00', 'currencyCode' => 'USD', ], 'softDescriptor' => 'Descriptor', @@ -56,7 +56,6 @@ public function testFake(): void self::assertSame($fakeResponse['refundId'], $response['refundId']); - \AmazonPay::fake($fakeResponse); $actual = \AmazonPay::getRefund('S01-5105180-3221187-R022311'); diff --git a/tests/TestCase.php b/tests/TestCase.php index 76f8c89..de06ac3 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -13,7 +13,6 @@ class TestCase extends \Orchestra\Testbench\TestCase * Get package providers. * * @param \Illuminate\Foundation\Application $app - * * @return array> */ protected function getPackageProviders($app): array @@ -27,7 +26,6 @@ protected function getPackageProviders($app): array * Get package aliases. * * @param \Illuminate\Foundation\Application $app - * * @return array> */ protected function getPackageAliases($app): array @@ -38,15 +36,15 @@ protected function getPackageAliases($app): array } /** - * @param \Illuminate\Foundation\Application|array{config: \Illuminate\Config\Repository} $app + * @param \Illuminate\Foundation\Application|array{config: \Illuminate\Config\Repository} $app */ protected function defineEnvironment($app): void { $app['config']->set('amazon-pay', [ 'public_key_id' => 'public_key_id', - 'private_key' => 'private_key', - 'sandbox' => true, - 'region' => 'us', + 'private_key' => 'private_key', + 'sandbox' => true, + 'region' => 'us', ]); } } From 57e0a6985fa76e151df2e51d9b03bd4d19e4f1f1 Mon Sep 17 00:00:00 2001 From: sunaoka Date: Wed, 13 Mar 2024 16:17:51 +0900 Subject: [PATCH 8/8] Support Laravel 11.x --- .github/workflows/test.yml | 12 +++++++++++- README.md | 2 +- composer.json | 4 ++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fcdeadf..6e317b8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: matrix: os: [ ubuntu-latest ] php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ] - laravel: [ 6, 7, 8, 9, 10 ] + laravel: [ 6, 7, 8, 9, 10, 11 ] exclude: - php: 7.2 laravel: 8 @@ -22,20 +22,30 @@ jobs: laravel: 9 - php: 7.2 laravel: 10 + - php: 7.2 + laravel: 11 - php: 7.3 laravel: 9 - php: 7.3 laravel: 10 + - php: 7.3 + laravel: 11 - php: 7.4 laravel: 9 - php: 7.4 laravel: 10 + - php: 7.4 + laravel: 11 - php: 8.0 laravel: 10 + - php: 8.0 + laravel: 11 - php: 8.1 laravel: 6 - php: 8.1 laravel: 7 + - php: 8.1 + laravel: 11 - php: 8.2 laravel: 6 - php: 8.2 diff --git a/README.md b/README.md index 580326c..cd15d10 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Latest Stable Version](https://poser.pugx.org/sunaoka/amazon-pay-api-sdk-php-laravel/v/stable)](https://packagist.org/packages/sunaoka/amazon-pay-api-sdk-php-laravel) [![License](https://poser.pugx.org/sunaoka/amazon-pay-api-sdk-php-laravel/license)](https://packagist.org/packages/sunaoka/amazon-pay-api-sdk-php-laravel) [![PHP from Packagist](https://img.shields.io/packagist/php-v/sunaoka/amazon-pay-api-sdk-php-laravel)](composer.json) -[![Laravel](https://img.shields.io/badge/laravel-6.x%20%7C%207.x%20%7C%208.x%20%7C%209.x%20%7C%2010.x-red)](https://laravel.com/) +[![Laravel](https://img.shields.io/badge/laravel-%3E=%206.x-red)](https://laravel.com/) [![Test](https://github.com/sunaoka/amazon-pay-api-sdk-php-laravel/actions/workflows/test.yml/badge.svg)](https://github.com/sunaoka/amazon-pay-api-sdk-php-laravel/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/sunaoka/amazon-pay-api-sdk-php-laravel/branch/main/graph/badge.svg?token=B69XU9TMMH)](https://codecov.io/gh/sunaoka/amazon-pay-api-sdk-php-laravel) diff --git a/composer.json b/composer.json index 0750057..2cd5070 100644 --- a/composer.json +++ b/composer.json @@ -15,10 +15,10 @@ "php": "^7.2 || ^8.0", "ext-json": "*", "amzn/amazon-pay-api-sdk-php": "^2.0", - "illuminate/support": "^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0" + "illuminate/support": "^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0" }, "require-dev": { - "orchestra/testbench": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0", + "orchestra/testbench": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0", "phpstan/phpstan": "^1.9" }, "autoload": {