laravel-google-merchant-api icon indicating copy to clipboard operation
laravel-google-merchant-api copied to clipboard

Getting "Call to a member function request() on null" Error

Open tcagkansokmen opened this issue 2 years ago • 3 comments

I just configured everything, but when I try to get products it returns error like above.

"vendor/moirei/laravel-google-merchant-api/src/Api/AbstractApi.php:263"

I checked my client_credentials_path and its reachable from any controllers.

What could be the main issue?

tcagkansokmen avatar Nov 10 '22 06:11 tcagkansokmen

this occurs when you haven't selected your merchant account via OrderApi or ProductApi::merchant('your-merchant')

h0lley avatar Dec 21 '22 13:12 h0lley

this occurs when you haven't selected your merchant account via OrderApi or ProductApi::merchant('your-merchant')

@h0lley can you please elaborate, it would be grateful.

habib3962 avatar Sep 26 '23 10:09 habib3962

We thought it would automatically pick our merchant credentials from config files. but its only working like this.

ProductApi::merchant([ 'merchant_id' => '1234567890', 'client_credentials_path' => storage_path('app/google-merchant-api/file-name.json') ])->insert(function($product){ $product->offerId(2) ->title('Purple Shoes 2') ->description('What are thooose!!') ->price(10); //->custom('purchase_quantity_limit', 1000) //->availabilityDate( Carbon::now()->addDays(7) ); })->then(function($response){ echo 'Product inserted'; })->otherwise(function($response){ echo 'Insert failed'; })->catch(function($e){ echo($e->getResponse()->getBody()->getContents()); });

habib3962 avatar Sep 26 '23 12:09 habib3962