PDA

View Full Version : WHMCS: How to disable paypal payment gateway if domain is purchased



Fli
05-30-2014, 05:12 PM
This tutorial worked for WHMCS billing system modiffication.

you will need to backup and then change viewcart.tpl file replacing following code on lin 277...


<h2>{$LANG.orderpaymentmethod}</h2>
<p align="center">{foreach key=num item=gateway from=$gateways}<input type="radio" name="paymentmethod" value="{$gateway.sysname}" id="pgbtn{$num}" onclick="{if $gateway.type eq "CC"}showCCForm(){else}hideCCForm(){/if}"{if $selectedgateway eq $gateway.sysname} checked{/if} /><label for="pgbtn{$num}">{$gateway.name}</label> {/foreach}</p>

by this:


<h2>{$LANG.orderpaymentmethod}</h2>

{foreach key=num item=domain from=$domains}
{if $domain.type eq "register"}
{assign var=domainregflag value=true}
{/if}
{/foreach}

<p align="center">{foreach key=num item=gateway from=$gateways}
{if !$loggedin and $gateway.sysname eq "paypal" and $domainregflag and $products|@count eq 0}{else}<input type="radio" name="paymentmethod" value="{$gateway.sysname}" id="pgbtn{$num}" onclick="{if $gateway.type eq "CC"}showCCForm(){else}hideCCForm(){/if}"{if $selectedgateway eq $gateway.sysname} checked{/if} /><label for="pgbtn{$num}">{$gateway.name}</label> {/if}{/foreach}</p>

the Paypal payment option will be removed if ALL of the following statements are true...

1. they are NOT logged in - e.g, they are NOT an existing customer.
2. they have one (or more) new domain registration(s) in the cart.
3. there are no products in the cart.

so if someone comes to your website and tries to register a domain they can't pay using Paypal unless they either add a product (e.g hosting) or log in.

if they are not logged in and have a new domain registration and a domain transfer in the cart, Paypal is disabled... if they remove the new domain registration from the cart, they can then use Paypal to pay for the domain transfer.

If one want to apply restriction also to Payza payment processor, can use code:


<h2>{$LANG.orderpaymentmethod}</h2>

{foreach key=num item=domain from=$domains}
{if $domain.type eq "register"}
{assign var=domainregflag value=true}
{/if}
{/foreach}

<p align="center">{foreach key=num item=gateway from=$gateways}
{if !$loggedin and $gateway.sysname eq "paypal" or $gateway.sysname eq "payza" and $domainregflag}{else}<input type="radio" name="paymentmethod" value="{$gateway.sysname}" id="pgbtn{$num}" onclick="{if $gateway.type eq "CC"}showCCForm(){else}hideCCForm(){/if}"{if $selectedgateway eq $gateway.sysname} checked{/if} /><label for="pgbtn{$num}">{$gateway.name}</label> {/if}{/foreach}</p>

What if i want to disable these payment gateways also for certain product group, ie: i dont want to show paypal payment option on dedicated servers checkout?

In that case try:

{foreach key=num item=domain from=$domains}
{if $domain.type eq "register"}
{assign var=domainregflag value=true}
{/if}
{/foreach}

{foreach key=num item=product from=$products}
{if $product.productinfo.groupname eq "Dedicated Server"}
{assign var=dedicatedflag value=true}
{/if}
{/foreach}

<h2>{$LANG.orderpaymentmethod}</h2>
<p align="center">{foreach key=num item=gateway from=$gateways}{if !$loggedin and ($dedicatedflag or $domainregflag) and ($gateway.sysname eq "paypal" or $gateway.sysname eq "payza")}{else}<input type="radio" name="paymentmethod" value="{$gateway.sysname}" id="pgbtn{$num}" onclick="{if $gateway.type eq "CC"}showCCForm(){else}hideCCForm(){/if}"{if $selectedgateway eq $gateway.sysname} checked{/if} /><label for="pgbtn{$num}">{$gateway.name}</label> {/if}{/foreach}</p>

so paypa, payza gateways wont be shown on checkout if: not loged in AND domain purchase or purchase of product from "Dedicated Server" named group