From 8b4732add828a33a794c99f93d54fb9cbb2972c7 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Wed, 2 Jan 2019 17:19:59 +0100 Subject: [PATCH 1/3] Set Stripe API version This makes sure we always use a fixed API version when making Stripe calls. It prevents breakages if another API version is defined in the Stripe account. --- src/Cashier.php | 7 +++++++ src/CashierServiceProvider.php | 3 +++ tests/CashierTest.php | 3 ++- tests/TestCase.php | 15 +++++++++++++++ tests/VerifyWebhookSignatureTest.php | 1 - tests/WebhookControllerTest.php | 1 - 6 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 tests/TestCase.php diff --git a/src/Cashier.php b/src/Cashier.php index b97a1f89..fdba47f5 100644 --- a/src/Cashier.php +++ b/src/Cashier.php @@ -6,6 +6,13 @@ class Cashier { + /** + * The API version used for making Stripe calls. + * + * @var string + */ + public static $stripeVersion = '2018-11-08'; + /** * The current currency. * diff --git a/src/CashierServiceProvider.php b/src/CashierServiceProvider.php index 0fa943fc..6ce86c80 100644 --- a/src/CashierServiceProvider.php +++ b/src/CashierServiceProvider.php @@ -2,6 +2,7 @@ namespace Laravel\Cashier; +use Stripe\Stripe; use Illuminate\Support\ServiceProvider; class CashierServiceProvider extends ServiceProvider @@ -18,5 +19,7 @@ public function boot() $this->publishes([ __DIR__.'/../resources/views' => $this->app->basePath('resources/views/vendor/cashier'), ]); + + Stripe::setApiVersion(Cashier::$stripeVersion); } } diff --git a/tests/CashierTest.php b/tests/CashierTest.php index d44a6ae8..784bfaec 100644 --- a/tests/CashierTest.php +++ b/tests/CashierTest.php @@ -7,7 +7,6 @@ use Carbon\Carbon; use Illuminate\Http\Request; use Laravel\Cashier\Billable; -use PHPUnit\Framework\TestCase; use Illuminate\Database\Schema\Builder; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\ConnectionInterface; @@ -19,6 +18,8 @@ class CashierTest extends TestCase { public function setUp() { + parent::setUp(); + Eloquent::unguard(); $db = new DB; diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 00000000..98eca4d4 --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,15 @@ + Date: Wed, 2 Jan 2019 17:39:17 +0100 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d164cb4..0b752bd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## [Unreleased](https://github.com/laravel/cashier/compare/v9.0.0...9.0) +### Changed +- Set Stripe API version ([#603](https://github.com/laravel/cashier/pull/603)) + ### Fixed - Correct PHP Doc @return tag ([#601](https://github.com/laravel/cashier/pull/601)) From 1b8fcfaa4a21bb089cf1c081338f76c2be926f63 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Wed, 2 Jan 2019 17:43:54 +0100 Subject: [PATCH 3/3] Only test against latest version --- CHANGELOG.md | 3 --- src/Cashier.php | 7 ------- src/CashierServiceProvider.php | 3 --- tests/TestCase.php | 3 +-- 4 files changed, 1 insertion(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b752bd6..5d164cb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,6 @@ ## [Unreleased](https://github.com/laravel/cashier/compare/v9.0.0...9.0) -### Changed -- Set Stripe API version ([#603](https://github.com/laravel/cashier/pull/603)) - ### Fixed - Correct PHP Doc @return tag ([#601](https://github.com/laravel/cashier/pull/601)) diff --git a/src/Cashier.php b/src/Cashier.php index fdba47f5..b97a1f89 100644 --- a/src/Cashier.php +++ b/src/Cashier.php @@ -6,13 +6,6 @@ class Cashier { - /** - * The API version used for making Stripe calls. - * - * @var string - */ - public static $stripeVersion = '2018-11-08'; - /** * The current currency. * diff --git a/src/CashierServiceProvider.php b/src/CashierServiceProvider.php index 6ce86c80..0fa943fc 100644 --- a/src/CashierServiceProvider.php +++ b/src/CashierServiceProvider.php @@ -2,7 +2,6 @@ namespace Laravel\Cashier; -use Stripe\Stripe; use Illuminate\Support\ServiceProvider; class CashierServiceProvider extends ServiceProvider @@ -19,7 +18,5 @@ public function boot() $this->publishes([ __DIR__.'/../resources/views' => $this->app->basePath('resources/views/vendor/cashier'), ]); - - Stripe::setApiVersion(Cashier::$stripeVersion); } } diff --git a/tests/TestCase.php b/tests/TestCase.php index 98eca4d4..df358e93 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -3,13 +3,12 @@ namespace Laravel\Cashier\Tests; use Stripe\Stripe; -use Laravel\Cashier\Cashier; use PHPUnit\Framework\TestCase as BaseTestCase; abstract class TestCase extends BaseTestCase { protected function setUp() { - Stripe::setApiVersion(Cashier::$stripeVersion); + Stripe::setApiVersion('2018-11-08'); } }