I'm trying to implement the paypal into my site. But I'm getting this error .
Type error: Argument 1 passed to PayPal\Rest\ApiContext::setConfig() must be of the type array, null given, called in D:\wamp64\www\vonservices\app\Http\Controllers\PaymentController.php on line 40 . Here is my controller code :
class PaymentController extends Controller
{
private $_api_context;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
//parent::__construct();
/** setup PayPal api context **/
$paypal_conf = \Config::get('paypal');
$this->_api_context = new ApiContext(new OAuthTokenCredential($paypal_conf['client_id'], $paypal_conf['secret']));
$this->_api_context->setConfig($paypal_conf['settings']);
}
/**
* Show the application paywith paypalpage.
*
* @return \Illuminate\Http\Response
*/
public function payWithPaypal()
{
return view('paywithpaypal');
}
/**
* Store a details of payment with paypal.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
}
?>```
\Config::get('paypal')
is an old way to find data in config. Try use config('paypal')
and php artisan config:cache
before using it.