How to Fix getExtensionInfo() Error in Drupal 10 Commerce Stripe

Fix getExtensionInfo() Error in Drupal 10 Commerce Stripe

If you are facing the following error in Drupal 10 while using the Commerce Stripe module:

Error: Call to a member function getExtensionInfo() on null in 
Drupal\commerce_stripe\Plugin\Commerce\PaymentGateway\Stripe->init() 
(line 104 of modules/contrib/commerce_stripe/src/Plugin/Commerce/PaymentGateway/Stripe.php)
    

Solution

Add the following code inside the __wakeup() method to ensure proper initialization:

public function __wakeup(): void {
    parent::__wakeup();
    $this->moduleExtensionList = \Drupal::service('extension.list.module');
    $this->eventDispatcher = \Drupal::service('event_dispatcher');
    
    $this->init();
}
    

Why This Works

  • parent::__wakeup(); – Ensures the base class initializes correctly.
  • $this->moduleExtensionList – Retrieves the module extension service.
  • $this->eventDispatcher – Loads the event dispatcher service.
  • $this->init(); – Calls the initialization method to avoid null reference issues.

Conclusion

Applying this fix will prevent the getExtensionInfo() error and allow the Commerce Stripe module to function correctly in Drupal 10.

Related Links

0 Comments