1

I have a custom Payment class extending CRM_Core_Payment.

In a custom page outside of the class, I need to call some public methods, such as supportsRecurring() or getReturnSuccessUrl().

What is the clean way to instantiate the class?

1 Answer 1

1

There are a couple functions in \Civi\Payment\System which you can call depending on what info about the processor you have at the time.

e.g. if the name (the name field in civicrm_payment_processor) is MyCustomProcessor, then you could do:

$pp = \Civi\Payment\System::singleton()->getByName('MyCustomProcessor', $is_test);

where $is_test is true or false depending on whether you are in test mode or not.

1
  • Thank you @demerit, I found the best way in my case thanks to your answer. \Civi\Payment\System::singleton()->getByClass('Payment_MyCustomProcessor', $is_test);
    – Bastien Ho
    Commented Sep 4 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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