Jump to content

Custom Direct Debit Payment Action


Go to solution Solved by brian!,

Recommended Posts

I want to customise the way the Direct Debit option works.

We have a 3rd party DD platform (gocardless) that interacts with Xero to process payments. GoCardless provides a unique link for each customer to set up their DD, so I have that link as a custom field in WHMCS.
I want for WHMCS to open that custom field link when the "Pay Now" button is clicked with DD selected as payment method.
Does anyone know how to achieve that?
image.png.6b2204039a16d377e09fa83f76054235.png

Link to comment
Share on other sites

  • Solution
10 hours ago, John Kennedy said:

Does anyone know how to achieve that?

with a hook or template tweak...

in the above example, i'm just swapping the images used... but the principle would work with changing other aspects, or defining it to equal your custom field URL... though it's difficult to advise when I don't know what the default value of that button is, or the URL you want to use... but the template will have access to the client custom field, so it will be possible....

as a blind guess, it should be something along these lines of changing {$paymentbutton} to ...

{if $paymentmethod == "PayPal"}<a href="{$clientsdetails.customfields2}" class="btn btn-default" role="button">Pay Now</a>{else}{$paymentbutton}{/if}

obviously, it won't be PayPal, so you'll have to get the value of $paymentmethod... and it's unlikely to be customfields2, so you'll also have to find the correct client custom field... so adding a {debug} to the end of the code in viewinvoice.tpl will give you a popup window of variables and arrays... that will give you the two values you need to insert into the above code and then it's just a case of testing and tweaking the button design. :idea:

Link to comment
Share on other sites

Thanks brian!
Worked like a charm after bit of tinkering.
 

{if $paymentmethod == "Direct Debit"}<a href="{$clientsdetails.customfields3}" class="btn btn-default" role="button">Set Up DD</a>{else}{$paymentbutton}{/if}

One thing of note however, for anyone looking to set up similar: do not set the custom field with the link as "URL/Link" leave it as "Text Box" or you'll be generating the following:
 

<a href="<a href="{your.custom.link}" target="_blank">{your.custom.link}</a>" target="_blank"><a href="{your.custom.link}" target="_blank">{your.custom.link}</a></a>

But that's if you want to have a button instead of a direct link.

Link to comment
Share on other sites

Hi John,

22 hours ago, John Kennedy said:

Thanks brian!
Worked like a charm after bit of tinkering.

i'm glad my educated guess set you on the right track! :idea:

22 hours ago, John Kennedy said:

One thing of note however, for anyone looking to set up similar: do not set the custom field with the link as "URL/Link" leave it as "Text Box" or you'll be generating the following:


<a href="<a href="{your.custom.link}" target="_blank">{your.custom.link}</a>" target="_blank"><a href="{your.custom.link}" target="_blank">{your.custom.link}</a></a>

But that's if you want to have a button instead of a direct link.

technically, you could leave it using a URL/Link option (e.g if you need to use the customfield elsewhere as a pure link) and just adjust the Smarty code in viewinvoice.tpl...

{if $paymentmethod == "Direct Debit"}{$clientsdetails.customfields3|replace:'target="_blank">':'class="btn btn-default" role="button">Set Up DD</a>'|replace:"`$clientsdetails.customfields3|strip_tags:false`":''}{else}{$paymentbutton}{/if}

however, if the invoice page is the only place you're going to use this customfield, then choosing the text box option would be the simpler solution. :)

Link to comment
Share on other sites

10 hours ago, John Kennedy said:

I'm guessing I need to modify a different template to update that to behave the same way as on individual invoices?

masspay.tpl ?

personally, i've always disabled Mass Pay as an option as i've never trusted it to work 100% without causing more hassle than it's worth.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • 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