0

My SandBox settings are like below

enter image description here

My .env code is like below

PAYPAL_SANDBOX_CLIENT_ID=Afr4Ig_nu8QUTt3uPBJW-VLEQoBTdS_OjGqZIXtM4FLWZpLNamAEo6NtTbHeB-_WWwESBdioqQNZW1Kw
PAYPAL_SANDBOX_SECRET=EMHy-4TQ5C6O8qA8ZittO-XhdJ-xM-PUuHR2f6oRBlVqR9MB26WDYtkjdR4ejhQpKPyLZpGmwxMTSXSA

I am trying to access them like below in one of my controller

if(config('paypal.settings.mode') == 'live'){
            $this->client_id = config('paypal.live_client_id');
            $this->secret = config('paypal.live_secret');
        } else {
            $this->client_id = config('paypal.sandbox_client_id');
            $this->secret = config('paypal.sandbox_secret');
        }

        echo $this->client_id;

        die();

But I am getting blank white screen.

abu abu
  • 6,599
  • 19
  • 74
  • 131
  • 1
    Your ".env code" has no relation to what you are doing in your controller, or if it does you aren't showing that part of your code. You should turn on PHP errors and do basic debugging. – Preston PHX Sep 03 '20 at 18:43

1 Answers1

1

You should have a file called paypal.php in your config folder.

The content of that file could look similar to the following:

<?php

return [
    'settings' => [
        'mode' => 'sandbox'
    ],
    'sandbox_client_id' => env('PAYPAL_SANDBOX_CLIENT_ID', ''),
    'sandbox_secret' => env('PAYPAL_SANDBOX_SECRET', '')
]

This will load the values from your environment and make them available with the config function calls you provided.

Bohrnsen
  • 79
  • 6