Professional Documents
Culture Documents
Premium
Forum
Demo
Documentation
Contact
abelblanco
Premium
Your profile
Subscribed threads
Favorite threads
Threads started
Edit your profile
Sign out
This tutorial is mostly targeted at developers as a bit programming knowledge is required to add a
new gateway. It works with all gateways that use a form (mostly appears as button) submit to get the
information and process the payment with the guest from there on.
It only works with easyReservations 3.3 and above.
Basic setup
To start we create a new wordpress plugin by going in the folder /wp-content/plugins/ and creating a
new folder with any name.
Then create a new file named like the folder with the extension .php. In this tutorial it will be example
and example.php.
Open it with your editor and copy the standard plugin header from the wordpress codex.
You can change the values, but they only matter to find and activate it in the plugins list later on.
1 function register_my_custom_gateway($gateways){
2 $gateways['my_gateway'] = array(
easyreservations.org/kb/add-custom-payment-gateway/ 1/7
21/11/2019 Add custom payment gateway » easyReservations Wordpress Plugin
3 'name' => 'Custom Gateway',
4 'form_name' => 'gateway_form',
5 'amount_name' => 'amount'
6 );
7 return $gateways;
8 }
9 add_filter('reservations_register_gateway', 'register_my_custom_gateway', 10, 1);
The key of the array, in the example my_gateway, is only a identifier and wont be used later on. The
name is only used if you activate multiple gateways to choose from. In form_name and amount_name
enter the html names of the payment form and the name of the amount (price) field in it. You’ll see
them later in the tutorial.
If you want to add options to the settings you have to enter the options name to the array with the
key “options”.
1 function generate_my_gateway_payment_form($res,$id,$title,$price,$nonce){
2 //Open form with link to gateway; the name of this should be the value of form_name at gatewa
3 $form = '<form name="gateway_form" action="http://link-to-custom-gateway.com" method="post" i
4
5 //Add a image as button to click on
6 $form.= '<input type="image" src="http://link-to-image.png" border="0" name="submit" alt="Pay
7
8 //Create array with the fields required by gateway
9 $array = array(
10 //The id required for the ipn function is the variable $id
11 'invoice' => $id,
12
13 //Description is the variable $title
14 'item_name' => $title,
15
16 //Field for price; It's key should be the value of amount_name at gateway registration
17 'amount' => $price,
18
19 //Link to your ipn script if you create one
20 'notify_url' => WP_PLUGIN_URL.'/example/example_ipn.php',
21
22 //If the gateway supports a custom field use it for the nonce and check it in the ipn
23 'custom' => $nonce,
24
25 //Some examples that are required in most gateways in some form
26 'business' => 'my_shop_identifier',
27 'cancel_return' => 'http://my-site.com/cancel/',
28 'currency_code' => 'USD',
29 'return' => 'http://my-site.com/thanks/'
30 );
31
easyreservations.org/kb/add-custom-payment-gateway/ 2/7
21/11/2019 Add custom payment gateway » easyReservations Wordpress Plugin
31
32 //Generate hidden fields from the array
33 $form .= easyreservations_generate_hidden_fields($array);
34 //Close form
35 $form .= '</form>';
36
37 return $form;
38 }
39 add_filter('reservations_generate_gateway_button', 'generate_my_gateway_payment_form', 10, 5);
After replacing the URLs and correctly naming and adding the required fields your done with the basic
implementation.
On this point it is fully usable. Your guest can pay and you get the money, but the reservation wont
get updated in easyreservations.
No matter if you want to proceed or that’s enough, this is a good point to test everything and get the
last errors out.
1 easyreservations_ipn_callback($_POST['invoice'], $_POST['amount']);
Where invoice is the same as sent to the gateway and amount is the amount paid.
Don’t forget to enter the URL to your IPN script to the payment forms generation.
Settings
If you want to add a options panel to the settings there’a an action to insert it on the right spot:
1 function my_gateways_settings(){
2 //Generate and output your options here
3 }
4 add_action('reservations_gateway_settings', 'my_gateways_settings');
The option to activate it should be saved as “modus”. Use the wordpress options to save them and
don’t forget to add it’s name to the gateway registration array with the key “options”.
easyreservations.org/kb/add-custom-payment-gateway/ 3/7
21/11/2019 Add custom payment gateway » easyReservations Wordpress Plugin
If you’re done and want to share your results with other users of easyReservations feel free to send me
the script to support@easyreservations.org and I’ll see if I get it integrated.
While I can’t give any financial reward it has the benefit that I’ll keep it up to date and compatible with
all future updates of easyReservations and probably improve it with the time.
Documentation
Plugin
Premium
Install & Update
Payment
Add custom payment gateway
Search
Appearance
Synchronization
Invoice
htmlMails
Hourly calendar
Multilingual
Export
Coupons
Extended calendar
Statistics
Troubleshooting
Datasheets
easyreservations.org/kb/add-custom-payment-gateway/ 4/7
21/11/2019 Add custom payment gateway » easyReservations Wordpress Plugin
easyreservations.org/kb/add-custom-payment-gateway/ 5/7
21/11/2019 Add custom payment gateway » easyReservations Wordpress Plugin
Home
Premium
AGB
License
Privacy
easyreservations.org/kb/add-custom-payment-gateway/ 6/7
21/11/2019 Add custom payment gateway » easyReservations Wordpress Plugin
Impress
easyreservations.org/kb/add-custom-payment-gateway/ 7/7