5

I have a situation where the Contributions are being set to Cancelled when the user contribution fails (payment processor fails the transaction). So, the user is blocked to try a new contribution until an administrator excludes that Membership with Cancelled status.

I took a look at documentation and understood that Membership Cancelled status would only be set manually, so I can't figure out why this situation is happening. I assured that "Override status" is not checked in the Membership edit panel, so it looks like something in the system is setting the Membership to Cancelled status. I wonder why and I need to fix it. Any clues?

Ps: The Payment processor IPN could be doing this?

PS2: I'm using Joomla! and the Payment Processor is PagSeguro.

  • I think I have a 'i have this problem too' and don't want to open a new ticket. I see Luciano's answer was accepted but not sure about that. Scenario - existing member goes to renew, enters incorrect cc - their Contribution is set to FAILED and their Membership (which might have been Current, or Grace) is set to CANCELLED. They are then disallowed from renewing again. I do not think this is correct outcome – petednz - fuzion Mar 7 '16 at 22:06
  • Trying to gather more examples of Payment Processors this is happening with to help confirm where this problem is kicking in since it can't be replicated with those on dmaster. – petednz - fuzion Mar 21 '17 at 8:18
3
+50

This is the expected behavior in CiviCRM, when you have a Contribution related to a Membership, and you set its Contribution status as Cancelled (manually or automatically through a ipn payment processor) it will cancel the Membership too. You can take a look to source code (4.6.x) where this is happening

https://github.com/civicrm/civicrm-core/blob/4.6/CRM/Contribute/BAO/Contribution.php#L1512

You can patch civicrm core to avoid Membership to be Cancelled when Contribution around this line:

https://github.com/civicrm/civicrm-core/blob/4.6/CRM/Contribute/BAO/Contribution.php#L1484

if (!$baseIPN->validateData($input, $ids, $objects, FALSE)) {
  CRM_Core_Error::fatal();
}

// ## Patch Begin ## Fix to not update membership status when updating contribution status
$memberships   = array(); //&$objects['membership'];
// ## Patch End ##
$participant   = &$objects['participant'];
$pledgePayment = &$objects['pledge_payment'];

There is a forum thread discussing this:

http://forum.civicrm.org/index.php/topic,34082.msg154608.html#msg154608

  • I do think this patch is good to solve the functional need in your project. However keep in mind that when you are patching CiviCRM your upgrades to a newer version requires you to review all the patches you have made. So from maintancability I would suggest to try to implment this in an extension. That is probably a little bit more complex. However it probably saves your headaches in the futrure when upgrading civicrm. – Jaap Jansma - CiviCooP May 25 '15 at 16:33
  • I agree, definitely patching civicrm core needs a lot of care when you upgrade CiviCRM versions. But I didn't find a better way to fix this. In an extension you would have to override CRM_Contribute_BAO_Contribution anyway to avoid this behavior with the same consequences – luciano_s May 25 '15 at 16:37
  • Thank you Luciano, but I checked in my system that the contributions are not Cancelled, but Failed, another kind of status. I took a look at Contribution.php#L1542 and saw that a failed Contribution should result in an expired Membership, is my understand correct? If so, I still can't see why those Memberships are being Cancelled by the system. Could it be a bug? – diegov May 25 '15 at 17:24
  • When the Contribution is Canceled it sets the Membership status to Canceled, when the Contribution is Failed it changes the Membership status to Expired. As I said, it is the expected behavior of CiviCRM by design. you can check in source code where the Membership is expired: github.com/civicrm/civicrm-core/blob/4.6/CRM/Contribute/BAO/… – luciano_s May 26 '15 at 8:25
  • The proposed patch removes all updates from contribution status to membership status. If you only want to remove the canceled contribution from being applied to the membership, you should only deactivate the part in : if ($contributionStatusId == array_search('Cancelled', $contributionStatuses)) { ... } – samuelsov Mar 2 '16 at 17:36
2

I believe there is some incorrect logic here and have opened a JIRA issue and am hoping client will fund.

If an existing user goes to renew a membership, makes an error with their CC - and hence has a Failed contribution, then there is no reason that i can think of why their existing membership should be set to Cancelled. Currently it means they are prevented from trying to renew again.

Outcome, imo, should be that if a Membership exists, and a payment Fails, then the membership status should be left how it was.

1

Whenever a transaction fails in payment processor the corresponding contribution gets cancelled. This is done by IPN.

But this shouldn't restrict the user from making a payment again or login (I guess you are using WordPress and SagePay).

If this happens, you should be checking the user permissions (roles) and you should be providing access for cancelled membership, saying if the member has a cancelled membership we should still allow the member to login.

  • No, the element that gets Cancelled status is the Membership, not the Contribution, this one gets Failed. It's expected that Cancelled membership blocks the user, as it should be an administrative status. The problem is that Cancelled should not be set in the event of failed contribution. BTW, I'm using Joomla and PagSeguro, a Brazilian Payment processor. – diegov May 19 '15 at 11:50
  • if you are getting failed it mean the user has tried to make a payment and the Card is not a valid one. so, the transaction is set to Failed. – Ramesh - ARTECH Consultancy May 19 '15 at 13:16
  • I had a same issue once, in this case, I just deleted the new membership which has a status as failed and allowed the user to make a new application. Please, try and let me know the status. thanks – Ramesh - ARTECH Consultancy May 19 '15 at 13:25
  • 1
    Membership doesn't have a Failed status, only Cancelled. Contribution has a Failed status. If I delete the Cancelled membership sure that the user can make a new one, that's not my problem, the problem is to stop that of happen, I can't stay removing the membership every time it happens. – diegov May 19 '15 at 15:25
  • when user cancels the transaction we get failed status. if you don't want to get failed status then in IPN change the status to something else and update the contribution – Ramesh - ARTECH Consultancy May 20 '15 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.