Skip to content

Commit 587545f

Browse files
committed
fix(google): config google application credentials
- Fix #140 - Fix #176
1 parent e55e1c2 commit 587545f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

config/liap.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@
3030
*/
3131
'google_play_package_name' => env('GOOGLE_PLAY_PACKAGE_NAME', 'com.some.thing'),
3232

33+
/*
34+
|--------------------------------------------------------------------------
35+
| Google Application Credentials
36+
|--------------------------------------------------------------------------
37+
|
38+
| This value is the path to the Google Application Credentials file.
39+
| @see https://imdhemy.com/laravel-iap-docs/docs/credentials/google-play
40+
|
41+
*/
42+
'google_application_credentials' => env('GOOGLE_APPLICATION_CREDENTIALS', null),
43+
3344
/*
3445
|--------------------------------------------------------------------------
3546
| App Store Password

src/ServiceProviders/LiapServiceProvider.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Imdhemy\Purchases\Subscription;
2121
use Lcobucci\JWT\Decoder;
2222
use Lcobucci\JWT\Encoding\JoseEncoder;
23+
use RuntimeException;
2324

2425
/**
2526
* Laravel Iap service provider
@@ -112,6 +113,14 @@ public function register(): void
112113
private function registerConfig(): void
113114
{
114115
$this->mergeConfigFrom(self::CONFIG_PATH, self::CONFIG_KEY);
116+
117+
$googleCredentials = config(self::CONFIG_KEY . '.google_application_credentials');
118+
if ($googleCredentials !== null) {
119+
if (! file_exists($googleCredentials)) {
120+
throw new RuntimeException("Google Application Credentials file not found at $googleCredentials");
121+
}
122+
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $googleCredentials);
123+
}
115124
}
116125

117126
/**

0 commit comments

Comments
 (0)