I'm trying to use Mollie in Laravel, but I'm encountering problems. This is my code (token from the Laravel/Mollie Github page):
public function payApi($amount, $email) {
$payment = Mollie::api()->payments()->create([
'amount' => $amount,
'description' => $email,
'redirectUrl' => 'http://google.com',
]);
$payment = Mollie::api()->payments()->get($payment->id);
if ($payment->isPaid()) {
echo "Payment received";
}
}
This is the error:
Mollie_API_Exception in Base.php line 353: Error executing API call (request): Unauthorized request
I guess this is because I need to set the API test-key, but I don't know how to do that in Laravel-Mollie, it is documented for standard Mollie though.
As explained in the README.md, you need to connect Mollie to Laravel Socialite first. If you intend on using Mollie Connect, update config/services.php
by adding this to the array:
'mollie' => [
'client_id' => env('MOLLIE_CLIENT_ID', 'app_xxx'),
'client_secret' => env('MOLLIE_CLIENT_SECRET'),
'redirect' => env('MOLLIE_REDIRECT_URI'),
],
And add your test-key in config/mollie.php.