I need a way to hook into the marketpress loading to include a custom payment gateway

Is it possible to get an extra action added to the loading phase of MarketPress? I have written a custom payment gateway but if there was an additional action on like 335 of marketpress.php, it would make it alot simpler to included these custom gateways into the normal loading process of Marketpress.

require_once $this->plugin_dir( 'includes/common/payment-gateways/class-mp-gateway-api.php' );
mp_include_dir( $this->plugin_dir( 'includes/common/payment-gateways' ) );
**NEW LINE** do_action( 'marketpress/payment-gateways_loaded' );
MP_Gateway_API::load_active_gateways();
  • Panos

    Hello @netadmin3,
    I hope you are having a nice day!

    As Nastia has already mentioned, our developers response times take longer than expected. Also I would like to add here that this is out of the scope of our support and considered custom development as stated in our support policy.

    Anyhow, I would like to join in here and try and help out. So first of all, the line you mention (335) only loads files so their functions can be used when called. What you need to do is to create a new custom payment gateway.

    To do so, you can copy one of the existing ones and transform it to meet your needs. All payment gateway files are included in folder
    marketpress/includes/common/payment-gateways/

    You will need to copy the main file and it's folder and rename them. It is important that you follow the naming convention and capitalize only when needed, for instance 'paypal' can be renamed to 'customway', 'Paypal' to 'Cutomway', 'Paypal_Error' to 'Customway_Error', 'init_paypal' to 'init_customway' etc. I mentioned paypal, but in my opinion, Mijireh is the easiest to copy and understand.

    When you are done with the renaming you will need to check if there are any errors. I trust you will be doing this in a testing environment and not in a live site :slight_smile: . If there are no errors you will be able to see your custom gateway in you site admin > Store Settings > Payments.

    Next comes the part where you will have to edit the parts for the settings (merchant ids or keys of your gateway) and actions to take on checkout (like redirects, database updates).

    There is much more that you might need to do, depending on the gateway method. If you find that this task is overwhelming I would recommend posting a job for this in our Jobs Board where you can hire one of our pros.

    I hope this was helpfull!

    Kind regards,
    Panos

  • threadinc

    panoskatws,

    We as a development agency have already developed numerous payment gateways for many of our clients from stand alone checkout systems, wooCommerce, and now MarketPress. I was only asking that we add a feature request to create a hookable action into the natural flow of your plugins startup process. This requested action on the line I mention (335) only loads files so their functions can be used when called and would allow other developers to extend your plugin with custom gateways that could be built separately from MarketPress. One of the greatest features of WordPress is the filter/action system that allows developers to create new functionality for the core WordPress or extend Plugins without having to "hack" these features in where they are needed.

    While your suggestion would work for the time being, by added a new gateway directly to your plugin, it violated the whole idea of extensibility that makes WordPress what it is and would obviously be an undocumented addition that could cause future problems if MarketPress ever needed to be reinstalled.

    By using the action hook as I have suggested, it allows plugin developers the ability to create custom Payment gateways that will function as a core payment gateway does, but also exists as its own documented separate plugin, allowing proper version control, administrative access control and further extensibility.

    Kind Regards,
    Thread Inc.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.