php artisan config:publish
을 사용하여 app/config/packages/lightshire/laravel/
의 설정 파일을 이미 게시했습니다. 나는이Laravel 4 : Config get 배열 또는 null
$client_id = Config::get('lightshire/laravel-paypal::client_id');
에 액세스하기 위해 노력하고있어 그것을 반환 모든 array(0) { }
내 서비스 제공 업체
<?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');
}
}
내 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;
}
}
입니다 이유는 무엇입니까?
문제가 해결 되었습니까? 나는 같은 것을했습니다. –