amzn / amazon-pay-api-sdk-php

Amazon Pay API SDK (PHP)
Apache License 2.0
48 stars 31 forks source link

main.CRITICAL: Warning: file_get_contents(): Filename cannot be empty in vendor/amzn/amazon-pay-api-sdk-php/Amazon/Pay/API/Client.php on line 424 #22

Open Morgy93 opened 2 years ago

Morgy93 commented 2 years ago

Hello,

if $key_spec = $this->config['private_key']; on line 421 in https://github.com/amzn/amazon-pay-api-sdk-php/blob/2.2.5/Amazon/Pay/API/Client.php#L421 is empty, then an error is thrown on line 424 for $contents = file_get_contents($key_spec);:

main.CRITICAL: Warning: file_get_contents(): Filename cannot be empty in vendor/amzn/amazon-pay-api-sdk-php/Amazon/Pay/API/Client.php on line 424
shangamesh commented 2 years ago

Hello The private_key file path need to configured in the configuration $amazonpay_config = array( 'public_key_id' => 'PUBLIC_KEY',
'private_key' => 'FILE_PATH', // Example : /Users/xyz/Downloads/private_key.pem' 'sandbox' => true,
'region' => 'us'
);

if the file path is empty then following exception will be thrown PHP Fatal error: Uncaught ValueError: Path cannot be empty in 'file_path'

if file content is empty then following exception will be thrown phpseclib3\Exception\NoKeyLoadedException: Unable to read key in 'file_path'

Please configure the file path & make sure file content is not empty

Morgy93 commented 2 years ago

@shangamesh Thanks for the information, but the error is thrown on dev and staging environments where we work with "limited" configured data.

It's never good to have uncaught errors, so it should be fixed nonetheless.

Dexterzprotege commented 2 years ago

@Morgy93 Are you not having any contents in the Config file? And what do you mean by "limited" configurational data?

Morgy93 commented 2 years ago

@Morgy93 Are you not having any contents in the Config file? And what do you mean by "limited" configurational data?

The stage environments have limited data in the env.php file. Basically, everything stripped except necessary things like db connection or base url.

cfortin commented 1 year ago

Can someone please expand on the 'config file' that you are referring to? E.g. where should I be able to find this config file? What is it called?

This extension was working fine for us until upgrade and now it's not. The 'Amazon Pay Team' have been pestering us with emails about upgrading the extension (which we have now done, to 5.15.0) but we're still seeing this error.

Many thanks in advance.