Ver código fonte

refactor: 🔒️ Changed getStripeSecret Method -> differentiates between local/prod

IceToast 3 anos atrás
pai
commit
ef2c271257
2 arquivos alterados com 9 adições e 14 exclusões
  1. 5 0
      .env.example
  2. 4 14
      app/Http/Controllers/Admin/PaymentController.php

+ 5 - 0
.env.example

@@ -23,6 +23,11 @@ PAYPAL_SECRET=
 PAYPAL_CLIENT_ID=
 PAYPAL_EMAIL=
 
+
+#stripe details, you only need "test" for testing! you can do this by setting the APP_ENV to local
+STRIPE_TEST_SECRET=
+STRIPE_SECRET=
+
 #set-up for extra discord verification
 DISCORD_CLIENT_ID=
 DISCORD_CLIENT_SECRET=

+ 4 - 14
app/Http/Controllers/Admin/PaymentController.php

@@ -345,19 +345,7 @@ class PaymentController extends Controller
      */
     protected function getStripeClient()
     {
-        $environment = env('APP_ENV') == 'local'
-            ? $this->getStripeSecret()
-            :  $this->getStripeSecret();
-
-        return new \Stripe\StripeClient($environment);
-    }
-
-    /**
-     * @return string
-     */
-    protected function getStripeClientId()
-    {
-        return env('APP_ENV') == 'local' ? env('PAYPAL_SANDBOX_CLIENT_ID') : env('PAYPAL_CLIENT_ID');
+        return new \Stripe\StripeClient($this->getStripeClient());
     }
 
     /**
@@ -365,7 +353,9 @@ class PaymentController extends Controller
      */
     protected function getStripeSecret()
     {
-        return env('STRIPE_SECRET');
+        return env('APP_ENV') == 'local'
+            ?  env('STRIPE_TEST_SECRET')
+            : env('STRIPE_SECRET');
     }