Jump to content

Commerce Plugin - Integrating 3rd-Party Class Wrapper

Tom Christian

Recommended Posts

I'm trying to build a plugin so that whenever an invoice is generated or updated some data is sent to a 3rd-party service.

Extending the \IPS\nexus\Invoice class and save() method seems to be what I need.

My question - The 3rd-party service I'm integrating has a nice PHP wrapper to help structure their XML requests from a php array structure. The wrapper is split into three .php files. What is the best way of integrating this into a plugin? Where can I store these files and how do I load them? I'm aware of the autoloader but I'm not confident of how exactly it works.



Link to comment
Share on other sites

​And using the psr0 method: eg:

\IPS\IPS::$PSR0Namespaces['FreshBooksApi'] = \IPS\ROOT_PATH . '/plugins/commerceTests/Freshbooks/FreshBooksApi';

How would I then call that inside a hook? Everything I try returns a class not found error.


Are the classnames \FreshBooksApi\Class? If so, that should work fine.

Though you can't distribute files in the plugins directory (since they're created dynamically), you'd need to put them somewhere else. /system/3rd_party/ is probably a good place.

Link to comment
Share on other sites

\IPS\IPS::$PSR0Namespaces['Freshbooks'] = \IPS\ROOT_PATH . '/plugins/commerceTests/Freshbooks';

​Mark, when creating an invoice, is it possible for me to store some additional data? Before creating the invoice, my plugin sends the invoice data to Freshbooks which responds with an invoice_id. I need to store that ID so that any future invoice updates within Commerce can also be applied over to freshbooks.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...