stripe-php icon indicating copy to clipboard operation
stripe-php copied to clipboard

Exception Error

Open Pok4 opened this issue 2 years ago • 3 comments

Describe the bug

Uncaught Error: Interface "Stripe\Exception\ExceptionInterface" not found in /home/argoscms/public_html/ext/pok4/shop/stripe/lib/Exception/ApiErrorException.php:8

This is the error. I'm using this autoloader - https://github.com/nette/robot-loader In cache i found this:

  ),
    'Stripe\\Exception\\ApiConnectionException' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\ApiConnectionException.php',
      1 => 1696003164,
    ),
    'Stripe\\Exception\\ApiErrorException' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\ApiErrorException.php',
      1 => 1696003164,
    ),
    'Stripe\\Exception\\AuthenticationException' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\AuthenticationException.php',
      1 => 1696003164,
    ),
    'Stripe\\Exception\\BadMethodCallException' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\BadMethodCallException.php',
      1 => 1696003164,
    ),
    'Stripe\\Exception\\CardException' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\CardException.php',
      1 => 1696003164,
    ),
    'Stripe\\Exception\\IdempotencyException' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\IdempotencyException.php',
      1 => 1696003164,
    ),
    'Stripe\\Exception\\InvalidArgumentException' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\InvalidArgumentException.php',
      1 => 1696003164,
    ),
    'Stripe\\Exception\\InvalidRequestException' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\InvalidRequestException.php',
      1 => 1696003164,
    ),
    'Stripe\\Exception\\OAuth\\ExceptionInterface' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\OAuth\\ExceptionInterface.php',
      1 => 1696003164,
    ),
    'Stripe\\Exception\\OAuth\\InvalidClientException' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\OAuth\\InvalidClientException.php',
      1 => 1696003164,
    ),
    'Stripe\\Exception\\OAuth\\InvalidGrantException' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\OAuth\\InvalidGrantException.php',
      1 => 1696003164,
    ),
    'Stripe\\Exception\\OAuth\\InvalidRequestException' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\OAuth\\InvalidRequestException.php',
      1 => 1696003164,
    ),
    'Stripe\\Exception\\OAuth\\InvalidScopeException' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\OAuth\\InvalidScopeException.php',
      1 => 1696003164,
    ),
    'Stripe\\Exception\\OAuth\\OAuthErrorException' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\OAuth\\OAuthErrorException.php',
      1 => 1696003164,
    ),
    'Stripe\\Exception\\OAuth\\UnknownOAuthErrorException' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\OAuth\\UnknownOAuthErrorException.php',
      1 => 1696003164,
    ),
    'Stripe\\Exception\\OAuth\\UnsupportedGrantTypeException' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\OAuth\\UnsupportedGrantTypeException.php',
      1 => 1696003164,
    ),
    'Stripe\\Exception\\OAuth\\UnsupportedResponseTypeException' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\OAuth\\UnsupportedResponseTypeException.php',
      1 => 1696003164,
    ),
    'Stripe\\Exception\\PermissionException' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\PermissionException.php',
      1 => 1696003164,
    ),
    'Stripe\\Exception\\RateLimitException' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\RateLimitException.php',
      1 => 1696003164,
    ),
    'Stripe\\Exception\\SignatureVerificationException' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\SignatureVerificationException.php',
      1 => 1696003164,
    ),
    'Stripe\\Exception\\UnexpectedValueException' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\UnexpectedValueException.php',
      1 => 1696003164,
    ),
    'Stripe\\Exception\\UnknownApiErrorException' => 
    array (
      0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\UnknownApiErrorException.php',
      1 => 1696003164,
    ),

Autoloader found somethings but i think that not found this one in the title... In very bottom of autoloader i found this: 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\ExceptionInterface.php' => 1696003164,

Can you give me suggestions how to fix this ?

In my code i have the following lines:

					// Retrieve the details of a PaymentIntent 
					try { 
						$paymentIntent = $stripe->paymentIntents->retrieve($checkout_session->payment_intent); 
					} catch (\Stripe\Exception\ApiErrorException $e) { 
						$api_error = $e->getMessage(); 
					} 
					 

To Reproduce

.

Expected behavior

.

Code snippets

No response

OS

Windows/XAMP

PHP version

PHP 8.1

Library version

12.5.0

API version

2023-09-28

Additional context

No response

Pok4 avatar Nov 05 '23 21:11 Pok4

The problem is autoloader library that i use - https://github.com/nette/robot-loader/issues/29 I open issue there and they tell me that this file is not a standart class... (because if check there) Can you give me a workaround to fix it ?

Pok4 avatar Nov 06 '23 10:11 Pok4

When i change the content of the file to:

<?php

namespace Stripe\Exception;


 
interface ExceptionInterface
{
}



everything is fine and worked correctly... I'm on PHP 8.1. Maybe the other part with if is not needed... The autoloader is loaded the file OK.

Pok4 avatar Nov 06 '23 10:11 Pok4

Hi @Pok4, I'm sorry you are having this issue. Unfortunately we can't remove the if as the library still supports PHP 5.6 where there is no Throwable type.

Considering it's a bug in a third-party loader you might need to work with the https://github.com/nette/robot-loader or switch to standard module loading techniques just for stripe (`require_once '/path/to/stripe-php/init.php';)

pakrym-stripe avatar Nov 07 '23 16:11 pakrym-stripe