@@ -70,10 +70,6 @@ protected function createProduct()
7070 $ id = $ this ->getProductId ();
7171
7272 try {
73- Stripe \Product::retrieve ($ id );
74-
75- $ this ->line ('Stripe product ' . $ id . ' already exists ' );
76- } catch (\Exception $ e ) {
7773 Stripe \Product::create ([
7874 'id ' => $ this ->getProductId ().'- ' .$ id ,
7975 'name ' => Spark::$ details ['product ' ],
@@ -83,6 +79,8 @@ protected function createProduct()
8379 ]);
8480
8581 $ this ->info ('Stripe product created: ' . $ id );
82+ } catch (\Stripe \Error \InvalidRequest $ e ) {
83+ $ this ->line ('Stripe product ' . $ id . ' already exists ' );
8684 }
8785
8886 }
@@ -99,9 +97,7 @@ protected function createStripePlans($plans)
9997 continue ;
10098 }
10199
102- if ($ this ->planExists ($ plan )) {
103- $ this ->line ('Stripe plan ' . $ plan ->id . ' already exists ' );
104- } else {
100+ try {
105101 Stripe \Plan::create ([
106102 'id ' => $ plan ->id ,
107103 'nickname ' => $ plan ->name ,
@@ -115,24 +111,9 @@ protected function createStripePlans($plans)
115111 ]);
116112
117113 $ this ->info ('Stripe plan created: ' . $ plan ->id );
114+ } catch (\Stripe \Error \InvalidRequest $ e ) {
115+ $ this ->line ('Stripe plan ' . $ plan ->id . ' already exists ' );
118116 }
119117 }
120118 }
121-
122- /**
123- * Check if a plan already exists
124- *
125- * @param $plan
126- * @return bool
127- */
128- private function planExists ($ plan )
129- {
130- try {
131- Stripe \Plan::retrieve ($ plan ->id );
132- return true ;
133- } catch (\Exception $ e ) {
134- }
135-
136- return false ;
137- }
138119}
0 commit comments