Main Menu
Sub Menu

Adding New Payment Gateway

Introduce New Payment Gateway:

add_filter("payment_method", "\WPDMPP\Libs\PaymentMethods\wpdmpp_new_payment_method"); 
function wpdmpp_new_payment_method($methods) { 
    $methods[] = "PaymentMethodClassName"; return $methods; 
}

Complete Implementation:

namespace WPDMPP\Libs\PaymentMethods;

add_filter("payment_method", "\WPDMPP\Libs\PaymentMethods\wpdmpp_new_payment_method"); 

function wpdmpp_new_payment_method($methods) { 
    $methods[] = "PaymentMethodClassName"; 
    return $methods; 
}

if (!class_exists('PaymentMethodClassName') && class_exists('\WPDMPP\Libs\CommonVars')) {
    class PaymentMethodClassName extends \WPDMPP\Libs\CommonVars
    {
        var $TestMode;
        var $GatewayUrl = "https://gatewat.url";
        var $GatewayUrl_TestMode = "https://sandbox.gateway.url";        
        var $ReturnUrl;
        var $NotifyUrl;
        var $CancelUrl;         
        var $Enabled;       
        var $VarName;
        var $GatewayName = "Gateway Name";

        function __construct()
        {
                $this->TestMode = $TestMode;            
                $this->Enabled = get_wpdmpp_option('PaymentMethodClassName/enabled');
                $this->ReturnUrl = wpdmpp_orders_page();                
                $this->NotifyUrl = home_url('?action=wpdmpp-payment-notification&class=PaymentMethodClassName');
                $this->CancelUrl = wpdmpp_cart_page();
                $this->ParameterName = get_wpdmpp_option('PaymentMethodClassName/VariableName');
                $this->TestMode = get_wpdmpp_option('PaymentMethodClassName/Mode');
                if($this->TestMode=='1') $this->GatewayUrl = $this->GatewayUrl_TestMode;
                $this->Secret_word = get_wpdmpp_option('PaymentMethodClassName/secret_word');
                $this->Currency = wpdmpp_currency_code();
            }
          
        }


        function configOptions()
        {

            $options = array(

                'Mode'=> array(
                    'label'         =>      __("Payment Gateway Mode:","text-domain"),
                    'type'          =>      'select',
                    'options'       =>      array('1' => 'Live', '0' => 'Test'),
                    'selected'      =>      $this->TestMode
                ),
                'VarName'=> array(
                    'label'         =>      __("Text Label","text-domain"),
                    'type'          =>      'text',                    
                    'placeholder'   =>      '',
                    'value'         =>      $this->VarName
                )
                // Add more variables as your payment gateway settings requires
                
            );

            return $options;


        }

        function showPaymentForm()
        {
            global $current_user;             
            $sbtn = "";
            $hide = "";
            if ($AutoSubmit == 1) $hide = "display:none;'";
            else $sbtn = "<button type='submit'>Pay Now!</button>";
            $this->Amount = number_format($this->Amount, 2);             
            $Form = "
                    Payment Form / Code to redirect to payment gateway... 

        ";
            return $Form;


        }


        function verifyNotification()
        {

         //IPN Code to verify payment and retun data true/false
          $valid = true;
           return $valid;
        }
    }
}

 

Last updated on Feb 5, 2021

Need More Clarification?

For any technical issue, if you are already using pro version please post in pro forum and free version users please post in free forum. Otherwise, if you have any pre-sale or order related query please contact live chat support team. For technical support.

Need Customization?

If you need additional customization on WordPress Download Manager or any type of custom support on WordPress you may contact our customization service.