laravel-paddle
laravel-paddle copied to clipboard
Support .env variables according read.me
Hello! I'm using v2.4.0 and according to documentation I could set the vendor_id, vendor_auth_code and public_key on .env or in published config file. But I've set in .env and my Paddle::subscription()->listPlans() returned a non permission returned from Paddle ([107] You don't have permission to access this resource). So I investigated and found on the src/Api/Request.php line 101 the code:
$data = $this->getData() + ['vendor_id' => config('paddle.vendor_id')];
if ($method === static::METHOD_POST) {
$data['vendor_auth_code'] = config('paddle.vendor_auth_code');
}
This mean that the vendor_id and vendor_auth_code is coming only from config file and it's not getting from .env, right?
I solved it adding a null coalescing operator in this part and I would like to check if can I send a PR with this new code?
$data = $this->getData() + ['vendor_id' => config('paddle.vendor_id')??env('PADDLE_VENDOR_ID')];
if ($method === static::METHOD_POST) {
$data['vendor_auth_code'] = config('paddle.vendor_auth_code')??env('PADDLE_VENDOR_AUTH_CODE');
}
I've changed all other config usages too for try to use the .env if config variable is not set.
Thanks!
@rcarvs hello. You shouldn't change "laravel-paddle" package source code.
You can update your config/paddle.php like this:
'vendor_id' => env('PADDLE_VENDOR_ID'),
'vendor_auth_code' => env('PADDLE_VENDOR_AUTH_CODE'),
In this case, the package will take variable values from your .env file.