artfulrobot / uk.artfulrobot.civicrm.gocardless

A CiviCRM extension providing GoCardless integration to handle UK Direct Debits.
GNU Affero General Public License v3.0
5 stars 18 forks source link

Can't delete a subscription in CiviCRM > 5.24 #91

Closed cheveuxroux69 closed 3 years ago

cheveuxroux69 commented 4 years ago

We're running CiviCRM 5.28, and this extension seems to work well but fails to delete subscriptions. I know that this isn't yet a supported version of CiviCRM. The problem is on line 119 of CRM/Core/Payment/GoCardless.php which is a debug dump of the params[] array passed in cancel subscription. From Civi 5.25, passing data to cancel a subscription is now done via a "PropertyBag" rather than an array (https://docs.civicrm.org/dev/en/latest/extensions/payment-processors/create/). The fix is to comment out the debug dump (lines 118-120) in /Core/Payment/GoCardless.php - the value "$params['id']" does not exist in a PropertyBag so the debug line fails. This value is not used in the rest of the cancelSubscription() function so is not important.

Sep 17 05:48:05  [warning] Deprecated function Legacy property name 'subscriptionId', use Canonical property name 'recurProcessorID'.
Array (    [civi.tag] => deprecated )
Sep 17 05:48:05  [warning] Deprecated function PropertyBag array access for core property 'subscriptionId', use getSubscriptionId().
Array (     [civi.tag] => deprecated )
Sep 17 05:48:05  [warning] Deprecated function PropertyBag array access to get 'id', use proper getCustomProperty('id') for non-core properties. Unknown property 'id'..
Array (    [civi.tag] => deprecated )

Sep 17 05:48:05  [error] 
$Fatal Error Details = array(3) {
  ["message"]=>
  string(31) "Property 'id' has not been set."
  ["code"]=>
  NULL
  ["exception"]=>
  object(BadMethodCallException)#8258 (7) {
    ["message":protected]=>
    string(31) "Property 'id' has not been set."
    ["string":"Exception":private]=>
    string(0) ""
    ["code":protected]=>
    int(0)
    ["file":protected]=>
    string(96) "/home/xx/public_html/wp-content/plugins/civicrm/civicrm/Civi/Payment/PropertyBag.php"
    ["line":protected]=>
    int(1097)
    ["trace":"Exception":private]=>
    array(19) {
      [0]=>
      array(6) {
        ["file"]=>
        string(96) "/home/xx/public_html/wp-content/plugins/civicrm/civicrm/Civi/Payment/PropertyBag.php"
        ["line"]=>
        int(140)
        ["function"]=>
        string(17) "getCustomProperty"
        ["class"]=>
        string(24) "Civi\Payment\PropertyBag"
        ["type"]=>
        string(2) "->"
        ["args"]=>
        array(2) {
          [0]=>
          string(2) "id"
          [1]=>
          string(7) "default"
        }
      }
      [1]=>
      array(6) {
        ["file"]=>
        string(128) "/home/xx/public_html/wp-content/civicrm_extensions/uk.artfulrobot.civicrm.gocardless/CRM/Core/Payment/GoCardless.php"
        ["line"]=>
        int(119)
        ["function"]=>
        string(9) "offsetGet"
        ["class"]=>
        string(24) "Civi\Payment\PropertyBag"
        ["type"]=>
        string(2) "->"
        ["args"]=>
        array(1) {
          [0]=>
          string(2) "id"
        }
      }
      [2]=>
      array(6) {
        ["file"]=>
        string(88) "/home/xx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Payment.php"
        ["line"]=>
        int(1427)
        ["function"]=>
        string(18) "cancelSubscription"
        ["class"]=>
        string(27) "CRM_Core_Payment_GoCardless"
        ["type"]=>
        string(2) "->"
        ["args"]=>
        array(2) {
          [0]=>
          NULL
          [1]=>
          object(Civi\Payment\PropertyBag)#8269 (3) {
            ["props":protected]=>
            array(1) {
              ["default"]=>
              array(3) {
                ["isNotifyProcessorOnCancelRecur"]=>
                bool(true)
                ["contributionRecurID"]=>
                int(1905)
                ["recurProcessorID"]=>
                string(14) "SB000XXXXXXXX"
              }
            }
            ["suppressLegacyWarnings":protected]=>
            bool(false)
            ["lastWarning"]=>
            NULL
          }
        }
      }
      [3]=>
      array(6) {
        ["file"]=>
        string(110) "/home/xx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contribute/Form/CancelSubscription.php"
        ["line"]=>
        int(223)
        ["function"]=>
        string(17) "doCancelRecurring"
        ["class"]=>
        string(16) "CRM_Core_Payment"
        ["type"]=>
        string(2) "->"
        ["args"]=>
        array(1) {
          [0]=>
          object(Civi\Payment\PropertyBag)#8269 (3) {
            ["props":protected]=>
            array(1) {
              ["default"]=>
              array(3) {
                ["isNotifyProcessorOnCancelRecur"]=>
                bool(true)
                ["contributionRecurID"]=>
                int(1905)
                ["recurProcessorID"]=>
                string(14) "SB000XXXXXXXX"
              }
            }
            ["suppressLegacyWarnings":protected]=>
            bool(false)
            ["lastWarning"]=>
            NULL
          }
        }
      }
artfulrobot commented 4 years ago

Thanks, I think https://github.com/artfulrobot/uk.artfulrobot.civicrm.gocardless/pull/83 is relevant, I'll try to take a look at it soon.

(The irony, of course, is that I wrote PropertyBag and the documentation to which you link... :facepalm: )

cheveuxroux69 commented 4 years ago

:) thanks!

artfulrobot commented 3 years ago

Please try 1.9.3 which includes the pr on cancelling subscriptions