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
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.1, 8.2]
laravel: [10]
php: [8.2, 8.3, 8.4]
laravel: [11, 12]

steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -34,7 +34,7 @@ jobs:
run: composer require "laravel/framework:^${{ matrix.laravel }}" --no-update

- name: Install dependencies
uses: nick-fields/retry@v2
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 5
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/vendor/
/composer.lock
.phpunit.result.cache
.phpunit.cache/
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. This projec

## Unreleased

### Changed

- Minimum PHP version is now 8.2, previously was 8.1.
- Upgraded to Laravel 11 and 12, dropping support for Laravel 10.

## [0.7.1] - 2024-09-01

### Removed

- Removed checking the prefix of account and charge ids, as Stripe does not consider changing these as
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ developed against as guide. You may find the package works with older versions o

| Laravel | Stripe PHP | Stripe API | Laravel-Stripe | Cashier |
|:--------|:-----------|:---------------|:---------------|:----------------------------|
| `12.x` | `^16.2` | `>=2020-03-02` | `0.8.x` | `^15.6` |
| `11.x` | `^16.2` | `>=2020-03-02` | `0.8.x` | `^15.6` |
| `10.x` | `^7.52` | `>=2020-03-02` | `0.7.x` | `^14.8` |
| `9.x` | `^7.52` | `>=2020-03-02` | `0.6.x` | `^12.3` |
| `8.x` | `^7.52` | `>=2020-03-02` | `0.5.x\|0.6.x` | `^12.3` |
Expand Down
26 changes: 13 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": "^8.1",
"php": "^8.2",
"ext-json": "*",
"illuminate/console": "^10.0",
"illuminate/contracts": "^10.0",
"illuminate/database": "^10.0",
"illuminate/http": "^10.0",
"illuminate/queue": "^10.0",
"illuminate/routing": "^10.0",
"illuminate/support": "^10.0",
"illuminate/console": "^11.0|^12.0",
"illuminate/contracts": "^11.0|^12.0",
"illuminate/database": "^11.0|^12.0",
"illuminate/http": "^11.0|^12.0",
"illuminate/queue": "^11.0|^12.0",
"illuminate/routing": "^11.0|^12.0",
"illuminate/support": "^11.0|^12.0",
"psr/log": "^3.0",
"stripe/stripe-php": "^7.52"
"stripe/stripe-php": "^16.2"
},
"require-dev": {
"laravel/cashier": "^14.8",
"laravel/legacy-factories": "^1.0",
"orchestra/testbench": "^8.0",
"phpunit/phpunit": "^9.5"
"laravel/cashier": "^15.6",
"laravel/legacy-factories": "^1.4",
"orchestra/testbench": "^9.14|^10.0",
"phpunit/phpunit": "^11.5"
},
"autoload": {
"psr-4": {
Expand Down
47 changes: 23 additions & 24 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
convertDeprecationsToExceptions="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
verbose="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
failOnWarning="true"
failOnDeprecation="true"
failOnNotice="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
>
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/lib/Unit/</directory>
</testsuite>
<testsuite name="Integration">
<directory suffix="Test.php">./tests/lib/Integration/</directory>
</testsuite>
</testsuites>
<php>
<ini name="error_reporting" value="E_ALL"/>
<env name="APP_KEY" value="base64:BMfTqJC1cFk6A/jTPsjQgC+cROx7TDaEeGIAat6CuqY="/>
</php>
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/lib/Unit/</directory>
</testsuite>
<testsuite name="Integration">
<directory suffix="Test.php">./tests/lib/Integration/</directory>
</testsuite>
</testsuites>
<php>
<ini name="error_reporting" value="E_ALL"/>
<env name="APP_KEY" value="base64:BMfTqJC1cFk6A/jTPsjQgC+cROx7TDaEeGIAat6CuqY="/>
</php>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
5 changes: 0 additions & 5 deletions src/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@

class Assert
{
/** @deprecated */
const ACCOUNT_ID_PREFIX = 'acct_';
/** @deprecated */
const CHARGE_ID_PREFIX = 'ch_';

/**
* @param string $expected
* the expected prefix.
Expand Down
2 changes: 1 addition & 1 deletion src/Connect/AuthorizeUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static function scopes()
* @param string $state
* @param array|null $options
*/
public function __construct($state, array $options = null)
public function __construct(string $state, ?array $options = null)
{
$this->state = $state;
$this->options = $options ?: [];
Expand Down
6 changes: 3 additions & 3 deletions src/Connect/Authorizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function __construct(Client $client, StateProviderInterface $state)
* @return AuthorizeUrl
* @see https://stripe.com/docs/connect/standard-accounts#integrating-oauth
*/
public function authorizeUrl(array $options = null)
public function authorizeUrl(?array $options = null)
{
if (!$state = $this->state->get()) {
throw new RuntimeException('State parameter cannot be empty.');
Expand All @@ -79,7 +79,7 @@ public function authorizeUrl(array $options = null)
* @return StripeObject
* @see https://stripe.com/docs/connect/standard-accounts#token-request
*/
public function authorize($code, array $options = null)
public function authorize(string $code, ?array $options = null)
{
$params = [
self::CODE => $code,
Expand All @@ -102,7 +102,7 @@ public function refresh()
* @return StripeObject
* @see https://stripe.com/docs/connect/standard-accounts#revoked-access
*/
public function deauthorize($accountId, array $options = null)
public function deauthorize(string $accountId, ?array $options = null)
{
$params = [
self::STRIPE_USER_ID => $accountId,
Expand Down
10 changes: 4 additions & 6 deletions tests/lib/Integration/Connect/OAuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Illuminate\Foundation\Auth\User;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\Facades\Route;
use PHPUnit\Framework\Attributes\DataProvider;

class OAuthTest extends TestCase
{
Expand Down Expand Up @@ -208,10 +209,7 @@ public function testForbidden()
Queue::assertNotPushed(FetchUserCredentials::class);
}

/**
* @return array
*/
public function invalidProvider()
public static function invalidProvider(): array
{
return [
'state' => ['state'],
Expand All @@ -227,9 +225,9 @@ public function invalidProvider()
* we expect it to send. But it is good to handle the scenario just in case.
*
* @param string $missing
* @dataProvider invalidProvider
*/
public function testInvalid($missing)
#[DataProvider('invalidProvider')]
public function testInvalid(string $missing): void
{
$params = collect([
'state' => 'session_token',
Expand Down
26 changes: 5 additions & 21 deletions tests/lib/Integration/Console/StripeQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,14 @@
use CloudCreativity\LaravelStripe\Facades\Stripe;
use CloudCreativity\LaravelStripe\Models\StripeAccount;
use CloudCreativity\LaravelStripe\Tests\Integration\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;
use Stripe\Balance;
use Stripe\Charge;
use Stripe\Collection;

class StripeQueryTest extends TestCase
{

/**
* @param string $fqn
* @param string $resource
* @dataProvider classProvider
*/
#[DataProvider('classProvider')]
public function testAll(string $fqn, string $resource): void
{
Stripe::fake(new Collection());
Expand Down Expand Up @@ -65,11 +61,7 @@ public function testAllSingular(): void
});
}

/**
* @param string $fqn
* @param string $resource
* @dataProvider classProvider
*/
#[DataProvider('classProvider')]
public function testAllConnect(string $fqn, string $resource): void
{
/** @var StripeAccount $account */
Expand All @@ -95,11 +87,7 @@ public function testAllConnect(string $fqn, string $resource): void
});
}

/**
* @param string $fqn
* @param string $resource
* @dataProvider classProvider
*/
#[DataProvider('classProvider')]
public function testRetrieveAndExpand(string $fqn, string $resource): void
{
Stripe::fake(new $fqn($id = 'foo_bazbat'));
Expand Down Expand Up @@ -147,11 +135,7 @@ public function testRetrieveSingular(): void
});
}

/**
* @param $fqn
* @param $resource
* @dataProvider classProvider
*/
#[DataProvider('classProvider')]
public function testRetrieveConnect($fqn, $resource)
{
/** @var StripeAccount $account */
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/Integration/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function tearDown(): void
*
* @return array
*/
public function classProvider(): array
public static function classProvider(): array
{
return [
'accounts' => [\Stripe\Account::class, 'accounts'],
Expand Down
29 changes: 7 additions & 22 deletions tests/lib/Unit/Connect/AuthorizeUrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
namespace CloudCreativity\LaravelStripe\Tests\Unit\Connect;

use CloudCreativity\LaravelStripe\Connect\AuthorizeUrl;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Stripe\Stripe;
use Stripe\Util\Util;
Expand Down Expand Up @@ -52,7 +53,7 @@ protected function tearDown(): void
/**
* @return array
*/
public function valueProvider()
public static function valueProvider(): array
{
return [
'read_only' => [
Expand Down Expand Up @@ -93,13 +94,8 @@ public function valueProvider()
];
}

/**
* @param array $expected
* @param string $method
* @param mixed|null $value
* @dataProvider valueProvider
*/
public function testStandard(array $expected, $method, $value = null)
#[DataProvider('valueProvider')]
public function testStandard(array $expected, string $method, mixed $value = null): void
{
$args = !is_null($value) ? [$value] : [];
$result = call_user_func_array([$this->url, $method], $args);
Expand All @@ -108,13 +104,8 @@ public function testStandard(array $expected, $method, $value = null)
$this->assertUrl('https://connect.stripe.com/oauth/authorize', $expected, "{$method}");
}

/**
* @param array $expected
* @param string $method
* @param mixed|null $value
* @dataProvider valueProvider
*/
public function testExpress(array $expected, $method, $value = null)
#[DataProvider('valueProvider')]
public function testExpress(array $expected, string $method, mixed $value = null): void
{
$this->assertSame($this->url, $this->url->express(), 'express is fluent');

Expand All @@ -125,13 +116,7 @@ public function testExpress(array $expected, $method, $value = null)
$this->assertUrl('https://connect.stripe.com/express/oauth/authorize', $expected, "{$method}");
}

/**
* @param string $uri
* @param array $params
* @param string $message
* @return void
*/
private function assertUrl($uri, array $params, $message = '')
private function assertUrl(string $uri, array $params, string $message = ''): void
{
$params = array_replace([
'state' => 'state_secret',
Expand Down