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?
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?
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.
\Civi\Payment\System::singleton()->getByClass('Payment_MyCustomProcessor', $is_test);
Commented
Sep 4 at 9:29