2

I'm working on a custom WHMCS payment gateway module for the Mollie payment gateway. So far I integrated one-off payments with no issue, but I'm having some trouble implementing recurring payments.

The flow for either a subscription or authorization to charge the customer on-demand differs slightly.

The flow for creating a subscription is:

  1. Create a customer profile in Mollie
  2. Create a mandate by performing an authorization payment - used to link a payment method to a customer (must be a payment of at least €0.01, requires user input)
  3. Add a subscription to a mandate, telling Mollie to charge the associated card x amount every x days/weeks/months

The flow for authorizing the merchant to charge on-demand is:

  1. Create a customer profile in Mollie
  2. Create a mandate by performing an authorization payment - used to link a payment method to a customer (must be a payment of at least €0.01, requires user input)
  3. Merchant sends a payment request to Mollie for every new invoice

The problem that I have is that Mollie supports multiple payment methods per customer. While WHMCS has built their gateway module system around single-method gateways such as Stripe.

What I want to do is replace the credit card management page with a custom page (preferably generated in the module, without modifying any templates) that allows customers to manage their Mollie details. This would include seeing active mandates and adding new ones (again, a mandate is basically an authorization for me to use a specific payment method for subscriptions or on-demand charging).

I could not find any way of doing this in the WHMCS documentation. Is this at all possible, or should I accept that the only way for customers to see the pages generated by my module is for them to go through an invoice first.

Cas
  • 758
  • 14
  • 36
  • Hi Cascer, can I ask you how far you are with this addon and payment module. I am very interested in this as well. – Niki van Stein Dec 02 '16 at 10:22
  • @BasvanStein The one-off module is practically done (I already use it on ducohosting.com). We're just discussing possible licensing options and a good method of gathering user feedback and feature requests before we release it. – Cas Dec 02 '16 at 10:46
  • I am mostly interested in the subscriptions part :). Once you have that part sorted out for WHMCS send me a message. – Niki van Stein Dec 02 '16 at 10:54
  • We're almost done with the on-demand (credit card-style) part, subscription payments are a little harder to deal with. Did you want the on-demand module or subscription-style (e.g: €5 every month) module? – Cas Dec 02 '16 at 11:04
  • The subscription style. – Niki van Stein Dec 02 '16 at 11:06

2 Answers2

2

You are going to need to create two modules that work together, a payment gateway module and an addon module. The addon module will allow you to create client side pages where customers can enter agreements / adjust agreements and then use the _link function to display a form where clients can pick which agreement to use when paying the invoice.

n8whnp
  • 296
  • 1
  • 5
  • Thanks, I never even thought of that! I'll give it a shot. – Cas Nov 22 '16 at 10:14
  • @n8whnp How can I connect you, brother, I want to ask you a question. thank you. – three-blocks Nov 30 '18 at 05:48
  • @three-blocks my github is in my public profile. feel free to drop me a line there or to use gmail. My gmail username is the same as my stackoverflow name. – n8whnp Dec 20 '18 at 21:39
  • @n8whnp How can we add pages using a module? I know how to add them manually, using mypage.php and mypage.tpl files. But unable to find how to add them using an addon... – Abdul Waheed Jun 17 '19 at 19:09
0

Seems perhaps useful to mention for consideration that WHMCS does already support recurring payments with a mature and native UI and integrates it with good invoicing practice. The customer is sent an invoice ahead of the payment, then on the due date, the card is charged and the customer is sent a receipt. Customers can see an audit trail of these invoices in the system.

While the business and charging needs of applications vary immensely due to a variety of driving reasons, I would think that for most people implementing recurring payments using WHMCS's recurring payment is a simple and effective solution. Remember, WHMCS lives for these - as just one example, it works brilliantly well with recurring paymentsfor hosting and domain renewal; the domain is simply not renewed and reminders are sent until paid; and any hosting will expire if not paid and eventually be optionally deleted from the server. It's always going to be harder to craft these sorts of automations with subscription-based payment system - even if a webhook is triggered on successful subscription renewal. (It can be done, it's just harder and less reliable than native - what if the IPN/webhook doesn't arrive reliably, or other issues break things). I'm just advocating that any new readers consider doing this within WHMCS's very capable and time-tested recurring transaction framework for this - I think it's worth at least considering, and hasn't been mentioned above, unless I missed it. I'm also mentioning this because for those who are newer to WHMCS this may not occur as a good idea immediately. WHMCS is all about making recurring transactions easy, letting customers see an invoice trail, etc.

I realise that it is now 2022 and that this discussion was originally held in late 2016, but wanted to add this to the great ideas above for new readers.

Apologies if this is annoying; again, fully realize that legacy decisions and business factors can make it essential to stay with external recurring payments!

Brian C
  • 837
  • 1
  • 10
  • 20
  • The reason for not wanting to go with credit cards is that they weren't used often in the target market. Instead we needed to perform direct debits which required explicit permission from the customer. – Cas Apr 22 '22 at 07:32