Undefined property: Drupal\commerce_paystack\Plugin\Commerce\PaymentGateway\PaystackStandard::$entityId

Created on 2 August 2025, 21 days ago

Problem/Motivation

Using the latest release of Commerce Paystack I tried making a payment and after a successful payment and I got redirected back to the site, the order wasn't marked as paid, instead I got the the warning and error,

Warning: Undefined property: Drupal\commerce_paystack\Plugin\Commerce\PaymentGateway\PaystackStandard::$entityId in Drupal\commerce_paystack\Plugin\Commerce\PaymentGateway\PaystackStandard->onReturn() (line 115 of modules/contrib/commerce_paystack/src/Plugin/Commerce/PaymentGateway/PaystackStandard.php).

Error messageWe encountered an issue recording your payment. Please contact customer service to resolve the issue.

This appears to be related to how the payment gateway entity ID is referenced in the onReturn() method. Updating the code to use $order->get('payment_gateway')->entity->id() resolved the issue and orders were again marked as paid.

Steps to reproduce

  1. Complete a payment using Paystack.
  2. Observe that the order is not marked as paid and the above warning appears.

Proposed resolution

Update the payment creation code in onReturn() to use the payment gateway entity ID from the order object. This change restores expected functionality and compatibility.

I am opening a merge request for the fix.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇳🇬Nigeria chike Nigeria

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024