Reputation: 574
I'm using the srmklive/laravel-paypal v.3 package ( https://github.com/srmklive/laravel-paypal that does not have documentation) in a laravel project. Someone can explain me how to use it? And how can i set the request?
For example when i press a pay button the controller process this code:
public function payment()
{
$provider = new PayPalClient;
// Through facade. No need to import namespaces
$provider = PayPal::setProvider();
$provider->setCurrency('EUR');
$provider->createOrder([
"intent"=> "CAPTURE",
"purchase_units"=> [
"amount"=> [
"currency_code"=> "EUR",
"value"=> "100.00"
]
]
]);
}
But i have this error: Trying to access array offset on value of type null
Relative to this portion of code:
$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/');
of class srmklive\paypal\src\Traits\PayPalAPI\Orders.php:21
This class is out of my controller because it's a library class, but there are no documentation.
Upvotes: 1
Views: 5868
Reputation: 82
This is the way to make it work. There's no documentation!
PayPal::setProvider();
$paypalProvider = PayPal::getProvider();
$paypalProvider->setApiCredentials(config('paypal'));
$paypalProvider->setAccessToken($paypalProvider->getAccessToken());
Source https://github.com/srmklive/laravel-paypal/issues/407#issuecomment-798562911
Upvotes: 1