Jump to content

Disallow ordering domains via PayPal


postcd

Recommended Posts

Hello,

 

i want to prevent people paying paypal and registering domains and then chargeback.

I got these ideas how to prevent:

 

1. some domain setting that it is not setup manually when paypal paid

2. some viewcart.tpl template edit? What is the smarty code to hide paypal payment option if domain purchase is selected?

3. Setting paypal gateway to manual approval all orders?

 

Please what are your ideas and advice? any tutorial on how to achieve please?

 

thank you

 

PS: relevant feature request: https://requests.whmcs.com/responses/allow-all-initial-paypal-purchases-manual-approval

Edited by postcd
Link to comment
Share on other sites

I think if you wanted to go down the road of editing viewcart.tpl, you would simply need to add an {if} statement to the gateway output... e.g for Comparison (~line #232)...

 

<p class="paymentmethods">{foreach key=num item=gateway from=$gateways}
{if $gateway.sysname eq "paypal" and $domains|@count gt 0 and $products|@count eq 0}{else}<label><input type="radio" name="paymentmethod" value="{$gateway.sysname}" onclick="{if $gateway.type eq "CC"}showCCForm(){else}hideCCForm(){/if}"{if $selectedgateway eq $gateway.sysname} checked{/if} />{$gateway.name}</label><br />{/if}
{/foreach}</p>

I have assumed that you want to block only those buying domains using Paypal but without adding a product (e.g hosting).. if you add a domain to the cart, Paypal will not be an option... but if you then add a product, Paypal is enabled again.

 

if you want to remove Paypal as an option for someone buying a domain regardless of whether they buy a product, then just remove the $products option from the above code...

 

I think this should work, but test it thoroughly - it currently just checks the $domains and $products arrays to see if they're empty or not.

Edited by brian!
Link to comment
Share on other sites

just as a followup - if you want this to apply when registering domains, but not transfers... you can tweak viewcart.tpl to do this... again, this is Comparison... ~line 81

 

<strong>{if $domain.type eq "register"}{assign var=domainregflag value=1} {$LANG.orderdomainregistration}{else}{$LANG.orderdomaintransfer}{/if}</strong> - {$domain.domain} - {$domain.regperiod} {$LANG.orderyears}<br />

if there is a domain registration in the cart, then it creates a variable $domainregflag and gives it a value of 1.

 

then later in the section we previously modified, at ~line 232, we can now tweak it to check only for a domain registration in the cart with no other products...

 

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

Link to comment
Share on other sites

as postcd is using the Vertical Steps order form template, the previous code needs to be modified in order to work.

 

therefore, you would need to change the following in viewcart.tpl at line 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>

replace the above with...

 

<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 now 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 the site 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.

 

hopefully i've covered all the possible options! :twisted:

Edited by brian!
Link to comment
Share on other sites

  • 5 months later...

This was greatly helpfull Brian, Thank You.

 

I thied Your rules and wanted to add second payment gateway for which will be excluded on domain purchase, this is a working result:

 

{if !$loggedin and $gateway.sysname eq "paypal" or $gateway.sysname eq "payza" and $domainregflag}

 

but what if i want to also disallow these 2 payment gateways if product from group "Dedicated Servers" is being ordered?

 

I tried:

{if $gateway.sysname eq "paypal" or $gateway.sysname eq "payza" or $product.productinfo.groupname eq "Dedicated Servers" and $domainregflag}

 

and order it different ways, but when i add "$product.productinfo.groupname eq "Dedicated Servers"" it start showing paypal/payza on domain purchases or dont show it at all on non-domain purchases.

 

Please any idea how to include that product group restriction for "Dedicated servers" into that workign rule?

 

{if !$loggedin and $gateway.sysname eq "paypal" or $gateway.sysname eq "payza" and $domainregflag}

Link to comment
Share on other sites

This was greatly helpfull Brian, Thank You.

 

I tried Your rules and wanted to add second payment gateway for which will be excluded on domain purchase, this is a working result:

 

{if !$loggedin and $gateway.sysname eq "paypal" or $gateway.sysname eq "payza" and $domainregflag}

personally, I would bracket this IF statement to make the intent simpler and avoid weird and unwanted results...

 

{if !$loggedin and $domainregflag and ($gateway.sysname eq "paypal" or $gateway.sysname eq "payza")}

 

but what if i want to also disallow these 2 payment gateways if product from group "Dedicated Servers" is being ordered?

 

I tried:

{if $gateway.sysname eq "paypal" or $gateway.sysname eq "payza" or $product.productinfo.groupname eq "Dedicated Servers" and $domainregflag}

 

and order it different ways, but when i add "$product.productinfo.groupname eq "Dedicated Servers"" it start showing paypal/payza on domain purchases or dont show it at all on non-domain purchases.

 

Please any idea how to include that product group restriction for "Dedicated servers" into that workign rule?

 

{if !$loggedin and $gateway.sysname eq "paypal" or $gateway.sysname eq "payza" and $domainregflag}

I would suggest making two changes.. firstly, to bracket the statement as outlined above so that it's more logical... something along the lines of...

 

{if !$loggedin and ($domainregflag or $product.productinfo.groupname eq "Dedicated Servers") and ($gateway.sysname eq "paypal" or $gateway.sysname eq "payza")}

now don't bother trying the above code as it won't work - it's purely an example of how to split the if statement to make it clearer as to what you want to do ! :)

 

the second change you need to make is to get around the above line not working - it fails because the $product array would only show the last entry in the cart - that's no good as we need to check the entire cart to ensure there isn't a dedicated server product in there..

 

so using the same procedure that we previously used to create $domainregflag which identified if there was a domain registration in the cart, we can create another smarty variable that will do the same for a product from the "Dedicated Server" group in the cart.

 

{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>

this uses the following IF statement...

 

{if !$loggedin and ($dedicatedflag or $domainregflag) and ($gateway.sysname eq "paypal" or $gateway.sysname eq "payza")}

so logically that reads as..

 

If the user is not logged in, AND (there is either a domain registration OR a dedicated server group product in the cart), AND (payment method is PayPal OR Payza)... then do something - or in this case, do nothing.

I should also mention that if you want to add more product groups or individual products to $dedicatedflag, then you just need to expand the IF statement with OR for products groups, or add an ELSEIF if adding single products.

 

{if $product.productinfo.groupname eq "Dedicated Server" or $product.productinfo.groupname eq "SSL Certs"}

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