I have already published the config files inside app/config/packages/lightshire/laravel/
using php artisan config:publish
. I'm trying to access this
$client_id = Config::get('lightshire/laravel-paypal::client_id');
and all it returns is array(0) { }
My Service Provider
<?php
namespace Lightshire\Paypal;
use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;
class PaypalServiceProvider extends IlluminateServiceProvider
{
protected $defer = false;
public function boot()
{
$this->package("lightshire/laravel-paypal");
include app_path()."/routes.php";
}
public function register()
{
$this->app["paypal"] = $this->app->share(function($app)
{
return new Paypal;
});
}
public function provides()
{
return array('paypal');
}
}
My Paypal.php
<?php
namespace Lightshire\Paypal;
require base_path()."/vendor/autoload.php";
use App;
use Config;
class Paypal
{
private $creds = null;
private $token = null;
public function __construct()
{
// // $data = Paypal::launch();
// $this->creds = $data["creds"];
// $this->token = $data["token"];
}
public static function getTokenCreds()
{
$client_id = Config::get('lightshire/laravel-paypal::client_id');
$secret = Config::get('laravel-paypal:secret');
$mode = Config::get('laravel-paypal:mode');
$endPoint = Config::get('laravel-paypal:endpoint');
;
$headers = array(
// 'Authorization' => 'Basic '.$encodedID,
'Accept' => 'application/json',
'Accept-Language' => 'en_US'
);
$params = array(
'grant_type' => 'client_credentials'
);
$url = "https://api.sandbox.paypal.com/v1/oauth2/token";
dd($client_id);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, $client_id.":".$secret);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
}
Any idea why?