Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.x] Adds Laravel 11 support #1611

Closed
wants to merge 5 commits into from
Closed
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: 6 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 }}
20 changes: 15 additions & 5 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -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
```
nunomaduro marked this conversation as resolved.
Show resolved Hide resolved

## Upgrading To 14.12.2 From 14.12

### Webhook Added
Expand Down Expand Up @@ -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');
});
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -345,7 +355,7 @@ try {
} catch (IncompletePayment $exception) {
// Get the payment intent status...
$exception->payment->status;

// Check specific conditions...
if ($exception->payment->requiresPaymentMethod()) {
// ...
Expand Down
26 changes: 13 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
19 changes: 0 additions & 19 deletions src/Cashier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down
19 changes: 5 additions & 14 deletions src/CashierServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public function boot()
$this->registerLogger();
$this->registerRoutes();
$this->registerResources();
$this->registerMigrations();
$this->registerPublishing();
$this->registerCommands();

Expand Down Expand Up @@ -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.
*
Expand All @@ -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');

Expand Down
5 changes: 5 additions & 0 deletions testbench.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
providers:
- Laravel\Cashier\CashierServiceProvider

migrations:
- database/migrations
8 changes: 2 additions & 6 deletions tests/Feature/FeatureTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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));
Expand Down
9 changes: 3 additions & 6 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -21,9 +23,4 @@ protected function getEnvironmentSetUp($app)

Cashier::useCustomerModel(User::class);
}

protected function getPackageProviders($app)
{
return [CashierServiceProvider::class];
}
}