RO Payments is a very versatile mediator between many Joomla extensions and a lot of payment providers. However payment providers keep popping up and there are so many payment providers already that we cannot support all of them. However there is the possibility of building your own payment provider into RO Payments. This article will explain what is needed to add your own payment provider to RO Payments.
Adding a payment service provider is currently considered a core-hack as it requires changing core files. Let us start with the nitty gritty details on what is needed. We assume good understanding of PHP programming.
File Locations
The following file locations are used in this article:
- libraries/Jdideal/Psp
- administrator/components/com_jdidealgateway/models/forms
- components/com_jdidealgateway/layouts/forms
- cli
- components/com_jdidealgateway/controllers
The payment service provider (PSP) files are located in the folder .
The form is located in the folder .
Forms
First step is to create the forms that will show your PSP.
Profile form
Open the file administrator/components/com_jdidealgateway/models/forms/profile.xml. In the profile form we list all the available PSP options. You see here we already have a list of PSPs. Add your entry as the last entry to this list and choose a unique name for the value. This name will be used for the second form.
<field name="psp"
label="COM_ROPAYMENTS_PROFILE_PSP_LABEL"
description="COM_ROPAYMENTS_PROFILE_PSP_DESC"
type="list"
required="false"
default=""
size="1"
class="input-xlarge advancedSelect"
onchange="document.adminForm.task.value='profile.change'; document.adminForm.submit();">
<option value="">COM_ROPAYMENTS_NO_IDEAL_ACTIVE</option>
<option value="advanced">COM_ROPAYMENTS_IDEAL_ADVANCED</option>
<option value="ing-lite">COM_ROPAYMENTS_IDEAL_ING_LITE</option>
<option value="abn-internetkassa">COM_ROPAYMENTS_IDEAL_INTERNETKASSA_ABN</option>
<option value="onlinekassa">COM_ROPAYMENTS_IDEAL_ONLINEKASSA</option>
<option value="kassacompleet">COM_ROPAYMENTS_IDEAL_KASSACOMPLEET</option>
<option value="mollie">COM_ROPAYMENTS_IDEAL_MOLLIE</option>
<option value="targetpay">COM_ROPAYMENTS_IDEAL_TARGETPAY</option>
<option value="sisow">COM_ROPAYMENTS_IDEAL_SISOW</option>
<option value="ogone">COM_ROPAYMENTS_IDEAL_OGONE</option>
<option value="buckaroo">COM_ROPAYMENTS_IDEAL_BUCKAROO</option>
<option value="ems">COM_ROPAYMENTS_IDEAL_EMS</option>
</field>
Details form
After adding the PSP to the profile form a new details form needs to be created. This file will be created in the same folder as where the profile form is found. For example if you added a PSP with the name mycoin then create the file administrator/components/com_jdidealgateway/models/forms/mycoin.xml. The easiest will be to copy an existing PSP form and rename this to your own name.
One important part in these PSP files is the status section, this must be present in your PSP file as well. These statuses determine how an order is going to be updated.
To test if this works, you can create a new profile in RO Payments and you should be able to see your PSP in the dropdown list.
Layout forms
The layout forms are there to either show any additional options to choose by the customer or to redirect to the PSP. In the folder components/com_jdidealgateway/layouts/forms there is the file form.php, this contains basic scaffolding for setting up the payment. You will find a switch statement listing all the PSPs and which layout they use. Add your own case to this switch statement to make sure the form is shown. The majority of PSPs use the psp.php file for their form. You can use this as well unless you have specific needs, in that case you can create your own layout file.
PSP library
The code that talks to your PSP must be placed in the folder libraries/Jdideal/Psp, taking our example this folder will be libraries/Jdideal/Psp/Mycoin. To make RO Payments connect to your PSP library a file named Mycoin.php must be placed in the libraries/Jdideal/Psp folder as well. Here the easiest is again to take a copy of an existing PSP file and rename it. You can keep all the functions and empty them and fill them with your own code.
Making payments
To be able to make payments the customer needs to be redirected to the PSP for the actual payment. The redirect happens in the file components/com_jdidealgateway/controllers/checkideal.raw.php. Here you will find a switch with the different PSPs, add your own case to redirect to your PSP. The function sendPayment() is taken from the PSP library file that was created before and will tell where to send the customer to for the payment.
Updating statuses
From time to time it can happen that a payment is not updated because the callback never happened or never arrived. RO Payments provides a status update script called cli/statusupdate.php which can be setup as a cronjob to periodically check payment statuses. This is only possible if the PSP allows a status check. In this file you will also find a switch where you can add your PSP to allow checking the status automatically. The construction of the URL depends on how the notify.php needs to be build up for your PSP.