|
Auction Factory - API for 3rd party Payment Gateways integration. |
|
|
|
We will explain this using the Moneybookers Plugin as a sample.
First we create the php file containing the Payment Gateway processing Class. The file and the class must be named identically (of course the file must have a .php extension). The file and classname must start with ‘pay_’ and must be located in the plugins/payment folder of the Auction factory component folder (components/com_bids).
The class must inherit payment_object (located in payment_object.php). Don’t forget to include the /plugins/payment/payment_object.php file at the top of the class file.
Following Class variables are inherited, and have to be adapted: var $classname="payment_object"; var $classdescription="generic Payment method";
You have to replace these in your class with the appropritate values ($classname MUST contain the name of your class!)
The Payment class inherits and can overwrit the following methods:
loadPluginLanguage($filename=null) - loads the specific file with language strings for this gateway
- you can have a standard file named like the class only with .en.php extension for english for instance. For instance pay_moneybookers.en.php is english, pay_moneybookers.de.php is german. If you use this naming convention the files will be included automatically, no need to overwrite this function.
ipn($d) - processes the Gateway IPN (the $d param will be an array with the request values - $_REQUEST)
checkout($d) - prepares and displays the payment form; most Gateways will not have to overwrite this one.
show_payment_form($order_id,$item_description, $itemname,$quantity,$price,$currency,$return_url=null) - this function MUST be overwritten. It is the Gateway specific part. Here you display the HTML needed for the payment form. Specific to each Payment processor.
Parameters are: $order_id – unique identifier for the transaction. $item_description – the description of the product (payment item) the user is paying for. You should display this in order to confirm this with the user. $ itemname – this is the PAYMENT ITEM internal name. YOU have to pass it on, so that it gets back per IPN. If no IPN is needed, then you can ignore it. $quantity – the amount of item the user purchases; most time it is one. $price – the item price. $currency – the currency you set up in payment item admin. $return_url – the url to pass the gateway as return url after payment was processed. (IT IS NOT THE IPN URL).
show_admin_config() - this function MUST be overwritten. It displays the ADMIN form for configuring the Processor. for instance you can ask the moneybookers email.
- very important- the form must look like this:
<form action="index2.php" method="post" name="adminForm"> [HERE YOUR CUSTOM VARIABLES] <input type="hidden" name="option" value="com_bids"/> <input type="hidden" name="task" value="savepaymentconfig"/> <input type="hidden" name="paymenttype" value="<?php echo $this->classname;?>"/> </form>
save_admin_config() - in this function you save the variables from the config form in the database.
- you must use the PARAMS field of the #__bid_paysystems table in the row for your payment system (where classname='$this->classname')
- We recommand to format the params like standard joomal parameters (variablename=value\n)
- Have a look at the moneybookers class to see an example.
getLogo() - overwrite this if you want to place the Processor logo somewhere else then in /plugins/payment/{$this->classname}.gif
- you can specify an external image.
|