What it is
The nexus/Item extension allows your application to integrate with Commerce, supporting paid content within a third party application. Downloads uses this integration to better support paid files through Commerce, for instance.
How to use
The class template includes 4 properties, and various methods depending upon the class you are extending. By default the template is generated as so:
class _{class} extends \IPS\nexus\Invoice\Item\Charge // or \IPS\nexus\Invoice\Item\Purchase
You will need to decide if you are extending an Item\Charge or an Item\Purchase and adjust accordingly. Once you have done so, you can extend any methods in this class that you wish.
The four class properties to define are
/**
* @brief Application
*/
public static $application = '{app}';
/**
* @brief Application
*/
public static $type = '';
/**
* @brief Icon
*/
public static $icon = '';
/**
* @brief Title
*/
public static $title = '';
You will specify your application under $application, the type of content under $type, an fa-* icon for $icon, and a language string for $title.
From there, you will need to determine which methods you will need to override. Downloads, for instance, overrides the url() and acpUrl() methods to link to the file that was purchased, the image() and purchaseImage() methods to return the screenshot of the file as the image to represent the purchase, the renewalPaymentMethodIds() method to restrict which payment gateways can be used for renewals, and the acpPage() and clientAreaPage() methods to return information about the file when viewing the purchase. You may only need to override onPaid() in order to perform an action when a purchase within your application is marked as paid, or you may need to override other methods as Downloads does.
Report Document