202-ecommerce / stripe_official

After years of hard work with Stripe connector for PrestaShop, 202 ecommerce stop the development of Stripe module on January 9th 2023. Thanks for all contributors that help us!
20 stars 20 forks source link

Fatal error in BO in multishop settings #42

Closed lmeyer1 closed 3 years ago

lmeyer1 commented 3 years ago

Setup to reproduce:

Provoke the error

Stacktrace

/vendor/stripe/stripe-php/lib/BaseStripeClient.php in __construct at line 55 /modules/stripe_official/classes/StripeDispute.php in getAllDisputes at line 43 /modules/stripe_official/classes/StripeDispute.php in orderHasDispute at line 51 /modules/stripe_official/stripe_official.php in hookDisplayAdminOrderContentOrder at line 1286

public function hookDisplayAdminOrderContentOrder($params)
{
    $stripePayment = new StripePayment();
    $stripePayment->getStripePaymentByCart($params['order']->id_cart);

    $stripeCapture = new StripeCapture();
    $stripeCapture->getByIdPaymentIntent($stripePayment->getIdPaymentIntent());

    $stripeDispute = new StripeDispute();
    $dispute = $stripeDispute->orderHasDispute($stripePayment->getIdStripe()); <<<<

The reason is stripe is disabled in this shop, thus it is impossible to instantiate the BaseStripeClient.

Solution

hookDisplayAdminOrderContentOrder must not search for disputes, if the module stripe is not activated in the current shop, or if there is no payment:

    if(!empty($stripePayment->getIdStripe())) {
        $stripeDispute = new StripeDispute();
        $dispute = $stripeDispute->orderHasDispute($stripePayment->getIdStripe());
    } else {
        $dispute = null;
    }
mribeiro202 commented 3 years ago

Hi @lmeyer1 ,

we are working on your PR https://github.com/202-ecommerce/stripe_official/pull/43 thank's for you help :)

mribeiro202 commented 3 years ago

Hi @lmeyer1

I close this issue because you made the PR.

have a nice day