Organization Membership renew "Payment Processor Error Message: Invalid Relationship"
We have several Organizations unable to renew their membership using a Contribution Page that uses "Allow individuals to contribute and / or signup for membership on behalf of an organization?" with the option required. Specifically when the Org itself has a Drupal login and tries to renew on behalf of itself.
- Create new org and individual contacts, each with the same primary email address, and an “employee of” relationship between them
- For the Org, create a Drupal user (clicked Actions -> Create User Record)
- Create a New Contribute Page
- Entered Financial Type as Member Dues and uncheck Use a confirmation page?
- In the Title tab check Allow individuals to contribute and / or signup for membership on behalf of an organization? and selected Organization Profile as On Behalf Of Organization and Copy it removeing all fields except Organization Name and Email (Main) then set it to Required
- Amounts tab: check Payment Processor -> Credit card test and check Pay later option and enter Pay Later Instructions and uncheck Contribution Amounts section enabled
- Memberships tab: check Membership Section Enabled? and check any Membership Types and checked Require Membership Signup
- Open the form Logged in or Masquerading as the new Org user
- Select a Membership and and enter the Organization Name and Email (Main) which should be the same as the other Email field and select I will send payment by check and click Contribute
- Got an error "Payment Processor Error Message: Invalid relationship".
You may need to edit the Membership to expire it then redo the form to get the error.
Doing some digging, we found this to originate from CRM/Contact/BAO/Relationship.php in the create() function. There it is calling checkValidRelationship() with $params=[[contact_id_a] => 17783, [contact_id_b] => 17783, [relationship_type_id] => 4, [is_permission_a_b] => 1]. It seems that Civi is trying to check the relationship between the Org and Individual (type 4) but using the Org contact id for both contacts. So maybe Civi is confusing the two contacts as they have the same email.
A user logged in as an Org should be able to make a renewal contribution on behalf of themselves.
- CiviCRM: CiviCRM 5.31.0
- CMS: Drupal 7.74
I tried to reproduce on dmaster but I didn’t appear to have permission to create a drupal user on the org contact, so was not able to test properly.