File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 2020use Imdhemy \Purchases \Subscription ;
2121use Lcobucci \JWT \Decoder ;
2222use 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 /**
You can’t perform that action at this time.
0 commit comments