I want to know how to add a gateway to Protected Content.

I want to know how to add a gateway to Protected Content.

There is NO documentation about this at all.

The gateway I need to add basically emulates Authorize.net

Please do not simple tell me to copy and change the Authorize.net gateway. There are pieces to it in several directories.

And do not push me off to your development staff for some additional fees. There should be documentation on how to do this.

Thank you.

  • Vaughan

    Hi Craig,

    Welcome to wpmudev.

    We don't have any documentation on this, other than the comments in the code itself.

    The only thing I can suggest is to copy the authorize.net code and change it to work with the gateway API that you want to use.

    If you have any specific questions about the functions in the code, I can certainly ask the developers for help. I have flagged one of our developers to see if he can help you along with this, however we do not do custom work here ourselves.

    Thanks

  • Jose

    Hi there @Craig,

    Hope you are doing great today.

    Unfortunately, there is no code documentation for our plugins.

    The good news are that Protected Content is very well written. It provides clear comments for each method across the plugin and follows a clear MVC pattern.

    In the main class, it implements an autoloader function so that you don't need to explicitly include your custom files. It will auto load all the classes inside the ../app/ folder tree that follows the class/file name convention.

    If you need to override some part of the core, you can use the hook 'ms_class_file_override', and point it to your custom file.

    Please do not simple tell me to copy and change the Authorize.net gateway.

    With the considerations mentioned above, I would suggest to base your custom gateway on one of the already existing gateways. If you whant to do it from scratch, you need to create at least a custom gateway model, extending from the class MS_Model_Gateway.

    Hope this helps as a start. Please don't hesitate to ask if you have some specific question about the code.

    Cheers!
    Jose

  • Craig

    Thanks for the replies.

    This is ridiculous that there is no documentation to be able to create a new Gateway. After reading the Community Board, I am getting the impression this is the case for ALL your plugins.

    OK, guys ... I can hack with the best of them. I need to implement the QuantumGateway in a BUNCH of your plugins ... they provide the code for a BUNCH of Shopping Carts:

    http://www.quantumgateway.com/modules.php

    No where on this list of available code is there any mention WPMUDev anything. Woocommerce isn't mentioned either, however, if I need to write a Gateway for it, I got something read:

    http://docs.woothemes.com/document/payment-gateway-api/

    Let's see here .. another "copy an existing gateway" reply which I asked not to get ... and I got it anyway.

    Great ... what do I copy?

    plugins/protected-content/app/assets/js/ms-view-gateway-authorize.js
    plugins/protected-content/app/assets/js/ms-view-gateway-authorize.min.js

    /plugins/protected-content/app/model/gatewayclass-ms-model-gateway-authorize.php

    Does all the stuff in:

    plugins/protected-content/app/view/gateway/authorize

    need to be copied too?

    Do I implement the QuantumGateway on Membership Pro the same way?

  • Jose

    @Craig,

    This is ridiculous that there is no documentation to be able to create a new Gateway. After reading the Community Board, I am getting the impression this is the case for ALL your plugins.

    Yes, you are correct and I hear you about your frustration. Creating a documentation for developers is a debt and it is an ongoing discussion. Hopefully, we will provide it in the future.

    Does all the stuff in:
    plugins/protected-content/app/view/gateway/authorize
    need to be copied too?

    You will need to create some views definitively, but ther might be some views that are not needed for your gateway. For instance, some gateway do not provide credit card payment, so the credi card view is not necessary.

    The MVC pattern is very clear and has a lot of benefits from a manteinance perspective, but it usually takes more lines of code.
    Maybe in this case you would prefer to workaround the plugin structure and just write an external plugin that will just hook into the checkout steps and add your custom gateway.
    You can get an idea of what I mean by looking at the hooks used in ../wp-content/plugins/protected-content/app/controller/class-ms-controller-gateway.php:

    ...
    $this->add_action( 'ms_controller_gateway_settings_render_view', 'gateway_settings_edit' );
    
    $this->add_action( 'ms_view_shortcode_invoice_purchase_button', 'purchase_button', 10, 2 );
    $this->add_action( 'ms_view_frontend_payment_purchase_button', 'purchase_button', 10, 2 );
    $this->add_action( 'ms_controller_frontend_signup_gateway_form', 'gateway_form_mgr', 1 );
    $this->add_action( 'ms_controller_frontend_signup_process_purchase', 'process_purchase', 1 );
    ...

    Do I implement the QuantumGateway on Membership Pro the same way?

    No. Protected Content and Membership Pro code bases are different.
    Membership Pro is more straightforward on this regard. You just need to create you gateway class extending from Membership_Gateway class and then register it calling the static method Membership_Gateway::register_gateway().

    Again, apologize for the lack of documentation. We are here to answer further questions.

    Cheers,
    Jose