There are generally 2 types of payment extension methods:
- Gateway Hosted (aka: Redirect, offsite, SIM, Simple). This means the customer is redirected to the secure payment gateway site to enter their payment details, then returned back to your store's success page.
Examples of payments that use this method: Paypal, PayPoint, FirstData Connect, Moneybookers
- Merchant Hosted (aka: API, XML, onsite, AIM, Advanced). This means you collect credit card details directly on your site and the customer never leaves your site. This requires you to have your own SSL certificate.
Examples of payments that use this method: Authorize.net AIM, Paypal Pro, SagePay Direct
The method you choose must be supported by the gateway you are integrating with.
After deciding what method you want, choose one of the example payment extensions listed above as your basis. For this example I will use the Paypal Pro files as my basis for a new extension called "My Pay". Regardless of the fact that Paypal Pro uses the "Merchant Hosted" method, the process of getting the files ready is the same. Only the internal code of the catalog controller file really changes for the method.
1. Clone the Files
Payment extensions in their MVC layout have a minimum of 7 files:
- Code: Select all
Copy all the pp_pro files and name the new ones "my_pay".
Be sure to use the correct extension (php or tpl) where appropriate.
Also, be sure you have follow the same folder structure.
** ALWAYS USE "default" THEME FOR PAYMENT TPL FILES **
2. Global Replaces:
In most cases, you can usually use a good editor like notepad++ to do a "Replace in Files" and simply run that twice for lower and uppercase wording separately:
- replace the word "pp_pro" with "my_pay"
- replace the word "PPPro" with "MyPay"
The upper case only applies to the main class extends (e.g. ControllerPaymentPPPro). In some cases where there are underscores in the main name, like "pp_pro", note that the uppercase version will NOT likely have the underscore. e.g. replace "pp_pro" with "my_pay" but replace "PPPro" with "MyPay"
3. Setup the Admin side
I always start on the admin side first...
- Setup the username/password/secret keys etc fields that the extension will need to access the API
- Setup any special settings for things like transaction type, test/production mode, etc
The admin/controller/payment/my_pay.php file handles all the form and variable control.
The admin/language/english/payment/my_pay.php file shows the text values for the different fields. You can clone and translate this file for any language.
The admin/view/template/payment/my_pay.tpl file is the html file that shows the actual form for configuring the extension settings. These all work together to form the page. You should be able to follow the existing pp_pro code and modify only parts of it to make it work for my_pay
4. Setup the Catalog side
After the admin is setup and working, it is easier to test as you code on the catalog side.
The catalog/language/english/payment/my_pay.php file will have the special error scenarios and the title of the
shipping extension as you want to show it in which ever languages you support.
The catalog/model/payment/my_pay.php file will have checks for geozone and any other special cases you want to add like subtotal must be a certain amount or the store must have a certain currency installed. Usually this is almost never changed and using the existing clone with just the replacing of the name is all that is needed in this file.
The catalog/controller/payment/my_pay.php file is for all the code logic. Use your payment gateway's API document to set up what you need for the extension here. It will of course require you know some advanced php at this point.
That's it. Step 4 is where most of the work gets done, but with the first 3 steps done, it makes it easier to test as you go.
If you have other advice to make this tutorial clearer and easier to understand, or if you think I missed a step, please PM me with tips.
- Posts: 18811
- Joined: Mon Jul 21, 2008 2:02 pm
Who is online
Users browsing this forum: No registered users and 1 guest