PesaPal offers a wonderful payment gateway for developers to integrate with mobile payment solutions available in Kenya, namely M-Pesa and Airtel Money (at least as of the composition of this) and also with VISA! Now, unfortunately, they only offer basic integration instructions and no specific modules for major platforms like Joomla. I have therefore taken the liberty to develop a module for virtuemart that I hope you will find helpful. I have submitted it to the JED and I hope they will approve it. The Joomlasphere mentions many issues with approval of free VirtueMart extensions but I hope for the best.
- Virtuemart v1.1.9 - Joomla v1.5.26 - PHP v5.3.10 & MySQL v5.5.20
These scripts are offered freely and in good faith. Please do not pass this off as your own work or try to sell it without due credit. Check back with us at ajagwe.com for updates/fixes. If you want more support/work done to it, you could consider a donation 🙂
If you have any other PesaPal payment module(s) already installed on your Virtuemart setup, then make a copy, as a backup, of the following files (if they exist in your system):
/administrator /components /com_virtuemart /classes /payment /OAuth.php /ps_pesapal.php /ps_pesapal.cfg.php /html /checkout.pesapal.php
- Download the pesapal_payment_module_v1.2.zip from here.
- Unzip the files to a temporary drive on your local computer
- Check that you don’t already have someone else’s pesapal payment module by looking in the folder as per my “Important Note” section above.
- Upload the OAuth.php, xmlhttprequest.php, ps_pesapal.php and ps_pesapal.cfg.php files to the directory (/administrator/components/com_virtuemart/classes/payment)
- Upload checkout.pesapal.php to the directory (/administrator/components/com_virtuemart/html)
- Login to your administration panel (back-end)
- Go to Components > Virtuemart > Store > List Payment Methods > New
- Ensure the “Active” checkbox is enabled (ticked)
- “Payment Method Name” should be PesaPal (doesn’t have to be but it’s easier to remember)
- “Code” is PESAPAL (again just easier to remember)
- Next to “Payment class name”, select ps_pesapal from the drop-down.
- For “Payment method type”, put a dot next to the HTML-form based (e.g. Paypal) option.
- Click on the “SAVE” icon (top-right).
- You should be returned to the “Payment Method List” page, click on the PesaPal entry you just made.
- Click on the Configuration tab (next to Payment Method Form tab)
- There should be a message saying that ps_pesapal.cfg.php is Writeable. If it isn’t then check the permissions on the file using your FTP client.
- Complete the fields just under this message as appropriate.
- Merchant key should be the merchant key provided to you by pesapal. The module defaults to a test merchant key from the pesapal website
- Secret key should be the secret key provided to you by pesapal. The module defaults to a test secret key from the pesapal website
- Return URL should be the root of your website as the module and pesapal will add several parameters to it for checkout confirmation. This is editable to any other URL that you may desire to handle responses from pesapal
- Cancel URL this can be left blank of the same as return URL. Functionality put in place for the day that pesapal adds a cancel link or button in their system
- Order Statuses should be the statuses that Orders change to depending on repsonse from pesapal. Please note that these are editable from Virtumart Orders Menu
- Confirmation Message is the message a user will get upon successful confirmation of a transaction from pesapal
- Error Message is the message a user will get upon report of an error in the transaction from pesapal
- Open the file payment_extra_info.txt (from the temporary folder where you extracted the modules files) and copy its content into the Payment Extra Info field of the form.
- Click on the “SAVE” icon again (top-right).
- Test as appropriate
Now that I’ve learnt to write Virtuemart Payment Modules, if there’s an e-merchant system that you would like to use that no one else has, I’ll be happy to look at a solution. Contact me or Leave a comment below. Also if you have any questions about this payment module, again do not hesitate to contact me.