• Resolved m.spierings

    (@mspierings)


    Hi,

    I have my own direct debit process for subscriptions and I running into a problem where the function process_payment_request of the class Wc_gateway_eway is `protected’.

    This mean that when I create a new instance of this class, I get all the settings (api pw etc) however I can’t call this function on the instance of this class.

    The public function process_payment is not useful for me since I believe this one is used after a Form submit.

    I am just programatically adding a product and using the eway_customer_id_token to do a payment.

    I was able to use the protected function by creating my own class that extends that class and then I could create a proxy function which would call the protected function.
    This is an entire hack and I also had to reload all the config settings in my surrogate class.

    Any change you can add a public proxy function that calls the protect process_payment_request() or make the protected function public?

    Cheers,

    Mattijs

Viewing 4 replies - 1 through 4 (of 4 total)
  • con

    (@conschneider)

    Engineer

    Hi @mspierings

    Hi,
    I have my own direct debit process for subscriptions and I running into a problem where the function process_payment_request of the class Wc_gateway_eway is `protected’.
    This mean that when I create a new instance of this class, I get all the settings (api pw etc) however I can’t call this function on the instance of this class.

    To my knowledge accessing the protected method from your child class should work.

    Private method: Only can be used inside the class. Not inherited by child classes.
    Protected method: Only can be used inside the class and child classes. Inherited by child classes.

    Any change you can add a public proxy function that calls the protect process_payment_request() or make the protected function public?

    There is probably a good reason why the developers choose this scope and unless that reason can be fed to the wind, I think not. Alternatively you can try something like this as well: https://gist.github.com/flowl/774c6e6335b6cb205c352ad67af2799c – did not know that is possible, but lgtm.

    Kind regards,

    Thread Starter m.spierings

    (@mspierings)

    Hi Con,

    As far as I know, protected means:

    protected scope when you want to make your variable/function visible in all classes that extend current class including the parent class.

    Since I made and instance of this class, it doesn’t seem to fulfil the requirements.
    I mean, I tried it first of course and the code would not execute the function.

    Not sure if there is a good reason, I is a perfectly normal function that deals with the whole programatic part of making a payment, including sending invoice emails etc.
    It is exactly what I need. Otherwise I would have to duplicate all that behaviour which is an unnecessary burden.

    Thread Starter m.spierings

    (@mspierings)

    Thanks for the extension example.
    I did extend it myself and got it to work that way, but it looks like an unnecessary hack to have to this stuff.

    When you extend that gateway class of eway, you are running into other issue like missing the properties that are set in the original classes constructor. With some hackerthehack, you get it working but it feels horrible :(.

    con

    (@conschneider)

    Engineer

    Howdy Mattijs

    Glad to hear you got it working. That gist just got added to my snippets collection. I am with you that this is indeed a lot of hack’a whack, but I did not author the code and thus don’t know the intention behind the scope choices. Since this is payment, I am guessing security, ey(?)

    If you can make a case, then you can open a ticket with Woo Support and send your code for review. Or just keep a fork of your version of the plugin. Anyways, I am marking this as resolved, but feel free to follow up or open a new thread anytime.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘access process_payment_request function’ is closed to new replies.