Type incompatibility: Discrepancy in the getPublicKey() method between the UnzerOnsite class and the Interface it extends

Created on 28 November 2023, about 1 year ago
Updated 30 November 2023, about 1 year ago

Problem/Motivation

The problem is as follows:

Fatal error: Declaration of Drupal\commerce_unzer\Plugin\Commerce\PaymentGateway\UnzerOnSite::getPublicKey() must be compatible with Drupal\commerce_unzer\Plugin\Commerce\PaymentGateway\UnzerOnSiteInterface::getPublicKey(): string in /var/www/html/docroot/modules/contrib/commerce_unzer/src/Plugin/Commerce/PaymentGateway/UnzerOnSite.php on line 385

This error happens in the following contexts:

  • Trying to edit a payment gateway that was already using Commerce Unzer in versions. Specifically I am using the UnzerOnSite plugin.
  • In one of the projects I am working on, a custom field is used to show the different payment options through a WebformElement, the problem also happens here.

Steps to reproduce

I have been able to reproduce this error in a project in which Unzer is the Payment Gateway when I use "Credit card" as a payment method.

Proposed resolution

Add 'string' as the function's return type just like the attached patch does.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇪🇸Spain dimaro Seville, Spain

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024