set_gateway - register your payments gateway in the list
If you want to add your payment gateway in Midrub, you need to know about the method set_gateway.
The method set_gateway has an essential role in Midrub Payments and it registers a gateway in the payments gateways list. Once called the method set_gateway from your gateway, it will be available in Midrub -> Administrator -> Settings -> Gateways and wherever where is requested.
How should be used the method set_gateway?
- In the Payments Gateway class you have the method load_hooks (see here https://www.midrub.com/articles/midrub-payments-structure)
- The method load_hooks works in same way like work in the Midrub Apps or Components but it is called only when we need it because a Payments Gateway shouldn't add features in Components or Apps. And to the save resources it isn't called when we don't need it.
- Inside the method load_hooks you have to call the set_gateway function. You can use even the parameter $categories to call the set_gateway function only when you need.
This are the parameters of the set_gateway function:
set_gateway( 'baintree', array( 'gateway_name' => $CI->lang->line('baintree'), 'gateway_icon' => '', 'gateway_color' => '#202020', 'fields' => array ( array ( 'type' => 'checkbox_input', 'slug' => 'baintree', 'label' => $CI->lang->line('baintree_enable'), 'label_description' => $CI->lang->line('baintree_enable_description') ), array ( 'type' => 'text_input', 'slug' => 'baintree_merchant_id', 'label' => $CI->lang->line('baintree_merchant_id'), 'label_description' => $CI->lang->line('baintree_merchant_id_description') ), array ( 'type' => 'text_input', 'slug' => 'baintree_public_key', 'label' => $CI->lang->line('baintree_public_key'), 'label_description' => $CI->lang->line('baintree_public_key_description') ), array ( 'type' => 'text_input', 'slug' => 'baintree_private_key', 'label' => $CI->lang->line('baintree_private_key'), 'label_description' => $CI->lang->line('baintree_private_key_description') ) ) ) );
Let's see for what is used each parameter:
- baintree - gateway slug, should be the gateway directory's name to avoid confusion.
- gateway_name - you can add your name and even translate it. It will be displayed to admin and user.
- gateway_icon - optional but could be requested in a user's app.
- gateway_color - used to make different the gateway in the list.
- fields - contains all fields in the admin's panel and in the example below you can see a real example of it's use(slug is the most important and it is saved in the table options).
The fields at this moment supports only two types: text_input and check_box input.
You can see how this works in the video below:
Please remember, all options like recurring, remember and any other won't be added here. In other articles i will provide details about where to use the options and how.
- How to enable or disable the widgets in the Midrub Dashboard Component
- How to create and use coupons codes in Midrub
- How works the referral program in Midrub
- How to configure the affiliate program in Midrub
- How works 3D secure for Braintree payments
- How to create and use the Stripe's webhooks
- How to manage the subscriptions on Braintree
- Send automatic templates in Facebook Messenger
- Apply coupons codes for the plan upgrade or renew
- How works the fields and options in the Midrub Payments system