Cool Tool: J!Dump

I just found another gem.
Remember how I was running around in circles trying to get my Joomla! OS Membership Pro Paystack payment plugin code to work? Well something drove me to ask my best friend Google about debugging, and I hit the jackpot.
Joomla! has documentation on how to debug your code at their JoomlaDocs.
I tried out the Joomla! Debug console, but it was not doing what I needed done: dump out variable values for me to see. Eventually I tried the J!Dump option in the list, and I fell in love.

J!Dump will allow you to dump variable, stack traces, and system information into a popup window at run time. This extension works like the PHP command `var_dump` but formats the output in a much more readable fashion. On the github page, the README says:

This utility makes life easy for developers and template designers. You use it to see what’s inside a variable, an array or an object. Instead of using print_r() or var_dump(), you can now use dump(). This will open a popup window with a nice expandable tree, showing the contents of the variable. It will even show a list of available methods for each object. You have to see it to believe it! You can use dump() in your extensions, in the core, in libraries and even in templates.

It has certainly made my life easier since I installed it.
It works with Joomla! 3.x and PHP 7.x which is what I have set up on my server. I’m yet to test it on Laragon, but I bet it would work.

Thank you to the seven contributors to this free open source project!

Building a Payment Plugin for OSMPro

As I am known to do, I take on small plugin projects from time to time. Having small programming code work to keep my mind churning has always helped to distract me from other things that could drag me under.

This time around, I had just finished one Joomla payment plugin for Virtuemart, for the Nigerian payment gateway, Paga, so writing another should have been easier. I was wrong. I was still yet to test the Paga plugin live, as the client was unresponsive, but I felt I could also rush this one in three weeks and be done.

I repeat, I was wrong.

This plugin is for the Nigerian payment gateway, Paystack, a cool new payment solution that everyone in the Tech community is proud to be associated with. Its also heartwarming that the founders are old friends of mine, but don’t let me digress.

Joomla’s plugin system, called extensions, has a very different naming convention compared to WordPress. In Joomla, there are Components (think big complex plugins), modules (think plugins that can be displayed in different positions at the front end), templates (think themes), and plugins (usually do invisible work at the back end). Components can have modules and plugins working with them. There are also extensions exclusively for the front end, and for the back end.

I was to build a Paystack payment plugin for the OS Membership Pro component. Keep in mind that there is no documentation (I had to rely on the skeletal documentation for one of their other plugins which my client claimed he was told was similar). After three months of battling the code, I had something ready for testing, but could not get access to the file server of the client, so I could work on the files directly. No responses from him so I gave up.

Fast forward three more months, and someone at Paystack buzzed me for help. He noticed I was a Joomla! fan, and had developed payment plugins for other components in the past. He needed help with developing one for the OS Membership Pro component, and was wondering if I was game. When he realized I already had something going, he encouraged me to finish, and offer me help 😀

So here are the notes and lessons I learnt the hard way while battling with it. I know I am bound to build another payment plugin for this component, so I figure, having something I can refer to, tomorrow, to make my work easier, online, would be awesome.

  1. Recurring or not: if the plugin you are developing does not support recurring payments, then don’t test it with plans that have recurring subscription activated. I wasted valuable time testing because I did not do this – sounds easy but when you are not that familiar with the component, it’s not.
  2. Naming: the name of the plugin in the xml document must be the same as the name of the php file. That’s the only way it will show up in the front end as an option to be selected for payment.
  3. Blueprint: The PayPal plugin caters to both recurring and single payment modes, so use it as your blueprint for your plugin.
  4. Redirect or Credit Card: If you want to redirect to the payment gateway, use this skeleton they recently put up on their GitHub page . If you want to build a plugin that uses credit card, use this one. I worked on the Redirect option.
  5. Classes and functions: The main class extends MPFPayment. There are four functions -> __construct, processPayment, verifyPayment, and validate. Because of the different nature of the payment form, I also created my own renderRedirectForm function.

I will keep adding to this list.