Jump to content

Community

Commerce Plugin - Integrating 3rd-Party Class Wrapper


Tom Christian
 Share

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.

Thanks

 

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.

Edited by Tom Christian
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We use technologies, such as cookies, to customise content and advertising, to provide social media features and to analyse traffic to the site. We also share information about your use of our site with our trusted social media, advertising and analytics partners. See more about cookies and our Privacy Policy