Jump to content

Payment gateway per user? Possible?


ozgurerdogan

Recommended Posts

to take them in reverse order, you can prevent clients from choosing a gateway when paying an invoice, by not ticking the checkbox in General Settings / Invoice

 

http://docs.whmcs.com/Invoice_Tab#Clients_Choose_Gateway

 

Clients Choose Gateway

 

Enabling will display a dropdown menu on the invoice allowing customers to choose which gateway they use to pay each invoice. When disabled each invoice will use the gateway the client chose upon signup.

 

it isn't possible to define which gateways a client can use via the admin area, but you could do so by modifying the template and/or using action hooks.

 

i've posted a number of threads on limiting payment gateways - the latest of which is below...

 

http://forum.whmcs.com/showthread.php?100127-Hide-payment-option&p=416114#post416114

 

it would make the coding slightly easier if you could assign these clients to client groups - http://docs.whmcs.com/Client_Groups

 

e.g, create a client group called "Paypal", assign the clients that can only use Paypal to that group and then use the client group idea in your Smarty code... that will be easier than coding a long list of client IDs !

Link to comment
Share on other sites

Thank you. This will help a lot. But how about dropdown list in invoice.

in viewinvoice.tpl, it's the same principle of using client groups as a shortcut, but you have to come at it from another angle because the dropdown list is actually a Smarty variable - and so you can't edit it in the same way, but you can remove options from the list.

 

so viewinvoice.tpl contains the following code...

 

                        {if $status eq "Unpaid" && $allowchangegateway}
                           <form method="post" action="{$smarty.server.PHP_SELF}?id={$invoiceid}" class="form-inline">
                               {$gatewaydropdown}
                           </form>
                       {else}
                           {$paymentmethod}
                       {/if}

let's assume you have a client group, with an ID value of "1", that you don't want to be able to pay via PayPal, you could replace the above code with...

 

                        {if $status eq "Unpaid" && $allowchangegateway}
                           <form method="post" action="{$smarty.server.PHP_SELF}?id={$invoiceid}" class="form-inline">
                               {if $clientsdetails.groupid eq "1"}
                                   {$gatewaydropdown|replace:'<option value="paypal">PayPal</option>':''}
                               {else}
                                   {$gatewaydropdown}
                               {/if}                                    
                           </form>
                       {else}
                           {$paymentmethod}
                       {/if}

this will remove the "Paypal" option from the dropdown.

 

if you had a client group that you wanted to pay only via Paypal, then you would remove the other payment options from {$gatewaydropdown} by using multiple replaces.

 

{$gatewaydropdown|replace:'<option value="mailin">Mail In Payment</option>':''|replace:'<option value="banktransfer">Bank Transfer</option>':''}

 

any client not in that client group will see all of the gateway options... if you had a number of client groups to which you wanted to assign different gateway options, then you would use multiple {if} statements to cover all the required groups.

 

to be thorough, one other template to look at might be masspay.tpl - you have access to each gateway with this template (via a foreach loop), so you can use code similar to the above link to hide payment gateways based on client groups.

 

                                <select name="paymentmethod" id="paymentmethod" class="form-control">
                                   {foreach from=$gateways item=gateway}
                                       <option value="{$gateway.sysname}">{$gateway.name}</option>
                                   {/foreach}
                               </select>

all the above code is from the v6 templates, but the principle works with v5 too.

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