Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIWEMB-249: Add hook to allow other extensions to opt for Membershipextras support #462

Merged
merged 6 commits into from
Apr 12, 2023

Conversation

omarabuhussein
Copy link
Member

@omarabuhussein omarabuhussein commented Apr 7, 2023

Overview

Membershipextras only supports payment processors that implement the Payment_Manual class, but given we now want it to work with GoCardless as well, and in the future we will probably add Stripe support too, this approach has to change. Here we we new hook that allows such extensions to opt for Membershipextras support.

Before

Membershipextras extension only work with Payment Processors that:

  • Have their class_name field = Payment_Manual
  • Or for Payment Plans with empty payment_processor_id field (which are considered "Pay Later").

After

This extension stills supports the same conditions mentioned in the "Before" section, it also allows other payment processor extensions to add themselves to get Membershipextras support.

Technical Details

The new hook is called:

hook_membershipextras_updateSupportedPaymentProcessors an passes the list of payment processors Membershipextras support by reference $supportedPaymentProcessor, which allows other extension to update the list. Here is a sample implementation inside an test extension called "testextension", which adds a payment processor defined inside it called "My new Test Payment Processor" to the list of Membershipextras supported processors:

function testextension_membershipextras_updateSupportedPaymentProcessors(&$supportedPaymentProcessor) {
  $myExtensionPaymentProcessors = \Civi\Api4\PaymentProcessor::get()
    ->addWhere('is_test', 'IN', [FALSE, TRUE])
    ->addWhere('name', '=', 'My new Test Payment Processor')
    ->execute()
    ->getArrayCopy();

  $supportedPaymentProcessor = array_merge($supportedPaymentProcessor, $myExtensionPaymentProcessors );
}

Other notes

  • I also added the settings mixin to the info file, because without it the setting page will just be empty, the new Civix versions relies on the mixin to load the settings defined in the settings folder.
  • Most of the changes in this PR are about changing the word "manual" (and in someplaces "offline) to "supported", given we no longer support just "Manual" or "Offline" payment processors, I don't get rid of all occurrences though, given in some places it requires more extra work than just renaming things.

This adds the settings mixin to the info file, which is required to load the settings from the settings folder
after upgrading the civix file to version v22.05.2
…r to 'supported'

As prepartion to support other payment processors that does not implement the Payment_Manual core class,
I am changing the occurrences of the word 'Manual' payment processor (and 'Offline' in some places) to 'Supported'
for better clarity.
@omarabuhussein omarabuhussein changed the title Ciwemb 249 support for new pps CIWEMB-249: Add hook to allow other extensions to opt for Membershipextras support Apr 7, 2023
$supportedPaymentProcessors = self::getManualPaymentProcessors();

// Allow extensions to opt in for Membershipextras
// Support.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why we need two lines here in the inline comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update @erawat , I also pushed two new commits to fix some issues with the tests, given I discovered that the previous time the action ran them they failed despite reporting them as passed,.

@omarabuhussein omarabuhussein merged commit e6cceda into CIWEMB-84-workstream Apr 12, 2023
2 checks passed
@omarabuhussein omarabuhussein deleted the CIWEMB-249-support-for-new-pps branch April 12, 2023 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants