Search for Resources and Solutions

Midrub Payments Structure

The new Midrub Payments is interesting, smart and useful. I've got as idea the Midrub's Apps concept to develop the structure of the new Midrub Payments system and this means it will be for quality at same level like on middle companies.

The structure was developed to support MVC and each gateway could have both views files and simple redirects to the gateway service. New structure will allow to make simple payments and subscriptions. For this reason will be multiuse.

The payments folder has the location in application/base because it will be used for both user's sections and frontend's section. The gateways are located in the folder application/base/payments/collection.

Each Payments's gateway should follow this interface:



interface Payments {

    /**
     * The public method check_availability checks if the gateway is available
     *
     * @return boolean true or false
     */
    public function check_availability();
    
    /**
     * The public method connect redirects user to the gateway's page
     * 
     * @since 0.0.8.0
     * 
     * @return void
     */
    public function connect();

    /**
     * The public method save saves saves returned user's data
     * 
     * @since 0.0.8.0
     * 
     * @return void
     */
    public function save();

    /**
     * The public method pay makes a payment
     * 
     * @param array $args contains the payment details
     * 
     * @since 0.0.8.0
     * 
     * @return void
     */
    public function pay($args);    
    
    /**
     * The public method ajax processes the ajax's requests
     * 
     * @since 0.0.8.0
     * 
     * @return void
     */
    public function ajax();

    /**
     * The public method create_subscription creates a subscription
     * 
     * @param array $args contains the parameters to create subscription
     * 
     * @since 0.0.8.0
     * 
     * @return void
     */
    public function create_subscription($args);    

    /**
     * The public method updates_subscription updates a subscription
     * 
     * @param array $args contains the parameters to update a subscription
     * 
     * @since 0.0.8.0
     * 
     * @return void
     */
    public function updates_subscription($args);    
    
    /**
     * The public method delete_subscription deletes a subscription
     * 
     * @param integer $subscription_id contains the subscription's id
     * 
     * @since 0.0.8.0
     * 
     * @return void
     */
    public function delete_subscription($subscription_id);

    /**
     * The public method hooks contains the gateway's hooks
     * 
     * @param string $category contains the hooks category
     * 
     * @since 0.0.8.0
     * 
     * @return void
     */
    public function load_hooks($category);

    /**
     * The public method guest contains the gateway's access for guests
     * 
     * @since 0.0.8.0
     * 
     * @return void
     */
    public function guest();
    
    /**
     * The public method gateway_info contains the gateway's info
     * 
     * @since 0.0.8.0
     * 
     * @return array with gateway's info
     */
    public function gateway_info();
    
}

The method gateway_info has an important role here because it don't provides only the gateway informations but even informations about how the gateway should be used based on it's features(For example not all payment supports subscriptions or generation of token).

In the Development's category i will explain how to create a new payment system.

Was this article helpful?