Jump to content

Payment Gateway only for certain customer

Recommended Posts

  • 2 weeks later...
On 21/06/2018 at 18:20, MichaelFu said:

is there a way to enable a Payment gateway only for certain customer?

from the settings, No...

On 21/06/2018 at 18:20, MichaelFu said:

for example:

all Customers >> Wire Transfer and PayPal
Customer John Doo >> Wire Transfer and PayPal and AsiaPay

i'd be tempted to do the logic the other way because I think AsiaPay needs to have the 'show on orderform' option ticked for it to be a gateway option at viewinvoice... so it's easier to remove a gateway than add one.


all Customers >> Wire Transfer and PayPal not AsiaPay
Customer John Doo >> Wire Transfer and PayPal and AsiaPay

which as a hook would be...


# ViewInvoice Gateway Hook
# Written by brian!

function hook_view_invoice_gateway($vars) {
	if ($vars['status'] == 'Unpaid' && $vars['userid'] != '28') {
		$gatewaydropdown = $vars['gatewaydropdown'];
		$asiapay = '<option value="asiapay">AsiaPay</option>';
		$gd2 = str_replace($asiapay, '', $gatewaydropdown);
		return array("gatewaydropdown" => $gd2);
add_hook('ClientAreaPageViewInvoice', 1, 'hook_view_invoice_gateway');

you will need to get the client ID value for John Doo (I know you could search for name, but you may have many John Doo - but their client IDs will be unique to each John Doo), which will be the #value on his clientsummary profile in the admin area... and then change the value of '28' in the above hook to whatever it is for John Doo - then John Doo will see all available gateways, everyone else will see all available gateways - except AsiaPay.


for a one-off client, the above should be acceptable... if it turns out to need to apply to multiple clients, I would suggest putting their IDs in an array and using in_array, or assigning those users to a client group and then checking if they are a member of that group when deciding which gateways to show.

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.

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