Skip to content

Conversation

@madsnorgaard
Copy link

Summary

This PR adds Drupal 11 support and fixes several bugs in the commerce_payfast module.

Changes

1. Drupal 11 Support

  • Added ^11 to core_version_requirement in commerce_payfast.info.yml

2. Fixed Broken Service Definition

  • Removed non-existent SiteUrlService reference from commerce_payfast.services.yml
  • The functionality is already implemented directly in PaymentOffsiteForm::getSiteUrl()

3. Fixed Logger Channel Names

  • Changed all instances of Drupal::logger('your_module') to Drupal::logger('commerce_payfast')
  • Affects: OffsiteRedirect.php (3 places), PaymentOffsiteForm.php (2 places)

4. Fixed Uninitialized Variable Bug

  • Added $storage = NULL initialization before try block in loadPaymentByRemoteId()
  • Added early return FALSE in catch blocks to prevent undefined variable error

5. Added Proper Exception Imports

  • Added use statements for InvalidPluginDefinitionException and PluginNotFoundException

Files Changed

  • commerce_payfast.info.yml - D11 version requirement
  • commerce_payfast.services.yml - Removed broken service
  • src/Plugin/Commerce/PaymentGateway/OffsiteRedirect.php - Bug fixes
  • src/PluginForm/OffsiteRedirect/PaymentOffsiteForm.php - Logger fix

Testing

  • Tested on Drupal 11.1.7 + Commerce 3.0 + PHP 8.3
  • Payment flow works with sandbox credentials
  • ITN callbacks processed correctly
  • Error logging appears under commerce_payfast channel

Backwards Compatibility

All changes are backwards compatible with Drupal 9.3+ and 10.x.

- Add ^11 to core_version_requirement in commerce_payfast.info.yml
- Remove broken SiteUrlService from services.yml (class doesn't exist,
  functionality already in PaymentOffsiteForm::getSiteUrl())
- Fix logger channel from 'your_module' to 'commerce_payfast' in:
  - OffsiteRedirect.php (3 places)
  - PaymentOffsiteForm.php (2 places)
- Fix uninitialized $storage variable in loadPaymentByRemoteId():
  - Initialize $storage = NULL before try block
  - Add early return FALSE in catch blocks to prevent undefined var error
- Add proper use statements for InvalidPluginDefinitionException and
  PluginNotFoundException

Tested on Drupal 11.1.7 with Commerce 3.0 and PHP 8.3.
All changes are backwards compatible with Drupal 9.3+ and 10.x.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant