"On user deletion delete the Billwerk Customer" option does not work

Created on 15 April 2024, about 1 year ago
Updated 24 April 2024, 12 months ago

Problem/Motivation

The "On user deletion delete the Billwerk Customer" option at /admin/config/services/billwerk-subscriptions/default-handler-settings

doesn't seem to execute anything? Or is this being blocked on the billwerk side to due existing contracts?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇩🇪Germany Anybody Porta Westfalica

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

Comments & Activities

  • Issue created by @Anybody
  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇩🇪Germany Anybody Porta Westfalica

    Eventually this is just blocked by billwerk and we should instead lock the customer and the contract, if it's not possible to delete it.

  • 🇩🇪Germany Anybody Porta Westfalica

    I can confirm this still doesn't work and there are not even log entries in this case. Maybe the user delete hook doesn't work?

  • 🇩🇪Germany Anybody Porta Westfalica

    This is the current implementation in billwerk_subscriptions_handler_default.module:

    /**
     * Implements hook_entity_TYPE_delete().
     */
    function billwerk_subscriptions_handler_default_entity_user_delete(UserInterface $user) {
      $onDrupalUserDelete = \Drupal::config('billwerk_subscriptions_handler_default.settings')->get('on_drupal_user_delete');
      if (!empty($onDrupalUserDelete)) {
        try {
          $subscriber = Subscriber::load($user);
          if ($subscriber->hasUserBillwerkContractId()) {
            switch ($onDrupalUserDelete) {
              case 'lock':
                $subscriber->billwerkLockCustomer();
                break;
    
              case 'delete':
                $subscriber->billwerkDeleteCustomer();
                break;
    
            }
          }
        }
        catch (\Exception $e) {
          // Log exception:
          Error::logException(\Drupal::logger('billwerk_subscriptions_handler'), $e);
          // Show error message:
          // For now do not show the error to the user, as it might be confusing or
          // even risky.
          // @see https://www.drupal.org/project/billwerk_subscriptions/issues/3439472:
          // \Drupal::messenger()->addError($e->getMessage());
        }
      }
    }
    
  • 🇩🇪Germany Anybody Porta Westfalica
Production build 0.71.5 2024