checkIfSeparateMembershipPaymentEnabled throws error if Stripe and Globalpayments aren't installed
Summary
The checkIfSeparateMembershipPaymentEnabled
function in the Check.php file generates an error when users login to Civi for the first time per session.
Details
When loading the CiviCRM dashboard for the first time in a session, the checkIfSeparateMembershipPaymentEnabled
function is generating the error Invalid criteria for IN
. The issue is the Api4 call to the PaymentProcessor
entity, and specifically the use of payment_processor_type_id:name
in the where clause.
Our CiviCRM installation does not have the Stripe or Globalpayment payment processors installed. It seems the Api is doing a lookup using the supplied names to generate numeric IDs to construct the underlying query in the form of payment_processor_type_id IN (...)
with integer values in the parentheses.
Proposal
Implement an explicit join in the query to the PaymentProcessorType entity and construct the IN
clause against the name
field of that entity directly:
$paymentProcessorIDs = \Civi\Api4\PaymentProcessor::get(FALSE)
->addJoin('PaymentProcessorType AS ptype', 'LEFT', ['payment_processor_type_id', '=', 'ptype.id'])
->addWhere('ptype'name', 'IN', $separateMembershipPaymentNotSupportedProcessors)
->execute()
->column('id');
We've tested this modification locally and it all seems to behave itself. I'd be happy to work up a PR if you'd like.