diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5690f20b..0f82e0e4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,10 +17,14 @@ jobs: fail-fast: true matrix: php: ['8.0', 8.1, 8.2, 8.3] - laravel: [9, 10] + laravel: [9, 10, 11] exclude: - php: '8.0' laravel: 10 + - php: '8.0' + laravel: 11 + - php: 8.1 + laravel: 11 - php: 8.3 laravel: 9 @@ -45,6 +49,6 @@ jobs: composer update --prefer-dist --no-interaction --no-progress - name: Execute tests - run: vendor/bin/phpunit --verbose + run: vendor/bin/phpunit env: STRIPE_SECRET: ${{ secrets.STRIPE_SECRET }} diff --git a/UPGRADE.md b/UPGRADE.md index 32cfc8bc..a5ba6ae3 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,15 @@ # Upgrade Guide +## Upgrading To 15.0 From 14.x + +### Migration Changes + +Cashier 15.0 no longer automatically loads migrations from its own migrations directory, so be sure to run the following command to publish Cashier's migrations to your application: + +```bash +php artisan vendor:publish --tag=cashier-migrations +``` + ## Upgrading To 14.12.2 From 14.12 ### Webhook Added @@ -132,7 +142,7 @@ The checkout button previously included with Cashier has been removed. Instead, ```php use Illuminate\Http\Request; - + Route::get('/product-checkout', function (Request $request) { return $request->user()->checkout('price_tshirt'); }); @@ -223,9 +233,9 @@ PR: https://github.com/laravel/cashier-stripe/pull/1001 Due to upgrading to a new Stripe API version, the `taxPercentage`, `syncTaxPercentage`, and `getTaxPercentageForPayload` methods have been removed from Cashier since they are deprecated by Stripe. We recommend that you upgrade to Stripe's new Tax Rates API. You can familiarize yourself with Tax Rates via Stripe's documentation on the topic: -Stripe migration guide: https://stripe.com/docs/billing/migration/taxes -Tax Rates documentation: https://stripe.com/docs/billing/taxes/tax-rates -Tax Rates on invoices: https://stripe.com/docs/billing/invoices/tax-rates +Stripe migration guide: https://stripe.com/docs/billing/migration/taxes +Tax Rates documentation: https://stripe.com/docs/billing/taxes/tax-rates +Tax Rates on invoices: https://stripe.com/docs/billing/invoices/tax-rates Using Tax Rates with Laravel Cashier is also documented within the official Cashier documentation: https://laravel.com/docs/billing#subscription-taxes @@ -345,7 +355,7 @@ try { } catch (IncompletePayment $exception) { // Get the payment intent status... $exception->payment->status; - + // Check specific conditions... if ($exception->payment->requiresPaymentMethod()) { // ... diff --git a/composer.json b/composer.json index af00df3f..54db192a 100644 --- a/composer.json +++ b/composer.json @@ -20,28 +20,28 @@ "require": { "php": "^8.0", "ext-json": "*", - "illuminate/console": "^9.21|^10.0", - "illuminate/contracts": "^9.21|^10.0", - "illuminate/database": "^9.21|^10.0", - "illuminate/http": "^9.21|^10.0", - "illuminate/log": "^9.21|^10.0", - "illuminate/notifications": "^9.21|^10.0", - "illuminate/pagination": "^9.21|^10.0", - "illuminate/routing": "^9.21|^10.0", - "illuminate/support": "^9.21|^10.0", - "illuminate/view": "^9.21|^10.0", + "illuminate/console": "^9.21|^10.0|^11.0", + "illuminate/contracts": "^9.21|^10.0|^11.0", + "illuminate/database": "^9.21|^10.0|^11.0", + "illuminate/http": "^9.21|^10.0|^11.0", + "illuminate/log": "^9.21|^10.0|^11.0", + "illuminate/notifications": "^9.21|^10.0|^11.0", + "illuminate/pagination": "^9.21|^10.0|^11.0", + "illuminate/routing": "^9.21|^10.0|^11.0", + "illuminate/support": "^9.21|^10.0|^11.0", + "illuminate/view": "^9.21|^10.0|^11.0", "moneyphp/money": "^4.0", "nesbot/carbon": "^2.0", "stripe/stripe-php": "^7.39|^8.0|^9.0|^10.0", - "symfony/http-kernel": "^6.0", + "symfony/http-kernel": "^6.0|^7.0", "symfony/polyfill-intl-icu": "^1.22.1" }, "require-dev": { "dompdf/dompdf": "^2.0", "mockery/mockery": "^1.0", - "orchestra/testbench": "^7.0|^8.0", + "orchestra/testbench": "^7.14|^8.14|^9.0", "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^9.0" + "phpunit/phpunit": "^9.0|^10.4" }, "suggest": { "ext-intl": "Allows for more locales besides the default \"en\" when formatting money values.", diff --git a/src/Cashier.php b/src/Cashier.php index dcf3cc69..5a975c78 100644 --- a/src/Cashier.php +++ b/src/Cashier.php @@ -42,13 +42,6 @@ class Cashier */ protected static $formatCurrencyUsing; - /** - * Indicates if Cashier migrations will be run. - * - * @var bool - */ - public static $runsMigrations = true; - /** * Indicates if Cashier routes will be registered. * @@ -173,18 +166,6 @@ public static function formatAmount($amount, $currency = null, $locale = null, a return $moneyFormatter->format($money); } - /** - * Configure Cashier to not register its migrations. - * - * @return static - */ - public static function ignoreMigrations() - { - static::$runsMigrations = false; - - return new static; - } - /** * Configure Cashier to not register its routes. * diff --git a/src/CashierServiceProvider.php b/src/CashierServiceProvider.php index cb091ef1..f6fe35a8 100644 --- a/src/CashierServiceProvider.php +++ b/src/CashierServiceProvider.php @@ -22,7 +22,6 @@ public function boot() $this->registerLogger(); $this->registerRoutes(); $this->registerResources(); - $this->registerMigrations(); $this->registerPublishing(); $this->registerCommands(); @@ -123,18 +122,6 @@ protected function registerResources() $this->loadViewsFrom(__DIR__.'/../resources/views', 'cashier'); } - /** - * Register the package migrations. - * - * @return void - */ - protected function registerMigrations() - { - if (Cashier::$runsMigrations && $this->app->runningInConsole()) { - $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); - } - } - /** * Register the package's publishable resources. * @@ -147,7 +134,11 @@ protected function registerPublishing() __DIR__.'/../config/cashier.php' => $this->app->configPath('cashier.php'), ], 'cashier-config'); - $this->publishes([ + $publishesMigrationsMethod = method_exists($this, 'publishesMigrations') + ? 'publishesMigrations' + : 'publishes'; + + $this->{$publishesMigrationsMethod}([ __DIR__.'/../database/migrations' => $this->app->databasePath('migrations'), ], 'cashier-migrations'); diff --git a/testbench.yaml b/testbench.yaml new file mode 100644 index 00000000..c0b21f4a --- /dev/null +++ b/testbench.yaml @@ -0,0 +1,5 @@ +providers: + - Laravel\Cashier\CashierServiceProvider + +migrations: + - database/migrations diff --git a/tests/Feature/FeatureTestCase.php b/tests/Feature/FeatureTestCase.php index 937b4660..8046a2d0 100644 --- a/tests/Feature/FeatureTestCase.php +++ b/tests/Feature/FeatureTestCase.php @@ -6,13 +6,14 @@ use Laravel\Cashier\Cashier; use Laravel\Cashier\Tests\Fixtures\User; use Laravel\Cashier\Tests\TestCase; +use Orchestra\Testbench\Concerns\WithLaravelMigrations; use Stripe\ApiRequestor as StripeApiRequestor; use Stripe\HttpClient\CurlClient as StripeCurlClient; use Stripe\StripeClient; abstract class FeatureTestCase extends TestCase { - use RefreshDatabase; + use RefreshDatabase, WithLaravelMigrations; protected function setUp(): void { @@ -27,11 +28,6 @@ protected function setUp(): void StripeApiRequestor::setHttpClient($curl); } - protected function defineDatabaseMigrations() - { - $this->loadLaravelMigrations(); - } - protected static function stripe(array $options = []): StripeClient { return Cashier::stripe(array_merge(['api_key' => getenv('STRIPE_SECRET')], $options)); diff --git a/tests/TestCase.php b/tests/TestCase.php index 9c6affa4..8f0e47ca 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -5,12 +5,14 @@ use Illuminate\Support\Str; use InvalidArgumentException; use Laravel\Cashier\Cashier; -use Laravel\Cashier\CashierServiceProvider; use Laravel\Cashier\Tests\Fixtures\User; +use Orchestra\Testbench\Concerns\WithWorkbench; use Orchestra\Testbench\TestCase as OrchestraTestCase; abstract class TestCase extends OrchestraTestCase { + use WithWorkbench; + protected function getEnvironmentSetUp($app) { $apiKey = config('cashier.secret'); @@ -21,9 +23,4 @@ protected function getEnvironmentSetUp($app) Cashier::useCustomerModel(User::class); } - - protected function getPackageProviders($app) - { - return [CashierServiceProvider::class]; - } }