How to Develop a Payment Plugin
This section describes how to create a Payment Plugin from scratch.
Which methods should be implemented?
A plugin implements whichever method it needs to integrate Billing with a payment gateway. Billing detects a plugin as Redirect or Modal, for example, depending on methods the plugin implements. That means that a plugin can be both Redirect and 3D Secure type if it implements Redirect, Auth, Capture and Is3DSecureActive methods. The GetConfig method, however, is Mandatory and must be implemented by all plugins.
The following table shows methods that a plugin must implement to be detected as a certain plugin type:
Method / Plugin Type | Redirect | Modal | Token | 3D Secure support |
---|---|---|---|---|
GetConfig
|
Yes | Yes | Yes | Yes |
Callback
|
Yes | Yes | Yes | Yes |
GoModal
|
No | Yes | No | No |
Redirect
|
Yes | No | No | No |
Refund1
|
No | No | Yes | No |
Sell
|
No | No | Yes | No |
Void1
|
No | No | Yes | No |
Auth
|
No | No | No | Yes |
Capture
|
No | No | No | Yes |
Is3DSecureActive
|
No | No | No | Yes |
1To be detected as a plugin capable of instruct Billing to create a Token, it must implement the Refund
or Void
method, but it is not Mandatory to implement both at the same time.
Developing a Redirect plugin that supports Recurring payment
The Example plugin (the source code) implements the Redirect Workflow, which means that it implements the Redirect method. Moreover, it supports recurring payments (see Supported Payment Methods Types), that is, it is capable of instructing Billing to create a Token (see Tokenizing a Payment Method), which means that it also implements the Sell and Void methods.
Note:
• The Payment Plugin SDK has the built-in support to the following PHP extensions: SimpleXML extension, PHP Data Object (PDO) extension, Multibyte String and SOAP.
• The Payment Plugin SDK provides some utility functions that helps working with internationalization, logs, and XML data. It also provides some named constants, which can be used by any plugin (see Named Constants and Utility Functions).
Using instructions from Location and Naming Convention, the folder Example
was created. The Example.php
file was created under the Example
folder, so was the i18n
folder. The en.string
file was created under the i18n
folder:
The extract from Example.php
file below shows all methods it implements. Note how each method is declared, following the $(PLUGIN_NAME)
_$(METHOD_NAME)
nomenclature.
<?php
function Example_GetConfig() { ... }
function Example_GetSupportedCurrencies() { ... }
function Example_ValidateConfig( $params ) { ... }
function Example_TestConnection( $params ) { ... }
function Example_Redirect( $params ) { ... }
function Example_Callback( $params ) { ... }
function Example_Sell( $params ) { ... }
function Example_Void( $params ) { ... }
?>
During the development, a plugin can be installed (see Plugin Installation > Installing during Development) and its functionalities can be tested (see Verifying the Plugin Operability).