Jump to content

How do you retrieve settings for a custom payment gateway?


Recommended Posts

Hello,

Im implmenting a custom Free Trial payment gateway leveraging the example code for payment gateways from GITHUB. Everything works great, but I need to retrieve settings from the payment gateways settings when the viewcart hook fires. I have the code and logic in place, and a basic conditional working, but for it to work to spec, I need to pull back a custom fields called promocodes from the payment gateways config. How do I do this?

//hook to only allow the free trial to show if one of the allowed promo codes have been entered
function filter_freetrial_gateway($vars)
{
    logModuleCall("FREETRIAL", "REMOVE FREE", $vars['gateways'], $vars['gateways'], $vars);

//retrieve the payment gateways settinsg for freetrial and process into array

    //check if the promo code exists in the allowed array - to be implemented
    if (($vars['templatefile']=='viewcart') && ($vars['promotioncode'] != "SEOTRIAL30")){

        // List of gateways to remove
        $disallowed = array('freetrial');

        $gateways = $vars['gateways'];
        
        foreach ($gateways as $k => $item) {
            if (in_array($item['sysname'],$disallowed)) {
                unset($gateways[$k]);
            }
        } 
        return array("gateways" => $gateways);
    }
}
add_hook("ClientAreaPageCart", 1, "filter_freetrial_gateway");

I borrowed the basis of this code from another post here on the community. Just trying to get the last piece in place.

 

Thanks in advance for the assistance.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated