Payment Gateway API

Payment Gateways in Tickera are class based and can be added as a WordPress plugins. This guide provides an intro to the payment gateway development for Tickera event ticketing system.

Common Payment Gateway Types

  1. Form Based
  2. Direct

Form based gateways post data off-site (to the payment gateways websites) like Mijireh, PayPal Standard, 2Checkout.com, etc meaning that you don't have to worry about the security much. Direct gateways however, in most cases, require implementation of some extra security layers, SSL certificates, tokenization, etc. and may also require a level of PCI compliance.

Creating a Payment Gateway Plugin

As in any other plugin, you should define plugin headers first:

Payment gateways should be created as additional plugins that hook into Tickera. Within the plugin you should create your class after Tickera payment gateways are loaded. For example:

It is important that your gateway extends Tickera's base gateway class

 

Methods

Most methods are inherited from the TC_Gateway_API class, however, some are required in your custom gateway.

 

init()

Within your init method (which is like constructor), you should define following variables:

You should also define here other variables needed by gateway like supported currencies, API access keys etc

 

payment_form( $cart ) 

You can add HTML form here for direct payment gateway types

 

or use it, for instance, to process canceled order messages, etc.

 

process_payment( $cart )

In this method, you should process payment (for direct payment gateways)

 

or generate form fields and post it to payment gateway, example from 2checkout.com payment gateway:

 

order_confirmation( $order, $payment_info, $cart_info )

This method executes after payment process ends. You can usually omit this method for the direct payment gateways since whole the logic, payment process and confirmation is already done in the process_payment method. You will use it most likely in all form based payment gateways to confirm whether the payment is completed or not. Bear in mind that you'll need to post to payment gateway website a return URL which should be $tc->get_confirmation_slug( true, $order_id ). You can see that parameter in the previous example for the 2checkout.com payment_process method.

 

ipn()

This method triggers when a payment gateway server posts a message to Tickera store about payment statuses. You'll use it most likely only with form-based payment gateways if they have option for setting IPN / Webhook URL on the fly. If so, you should just pass $this->ipn_url, which is a URL automatically created by the base class internal method _generate_ipn_url(), then intercept the message and change the status of the order for instance. Example:

 

gateway_admin_settings( $settings, $visible )

You can add admin fields required for a payment gateway with this method, example:

Base class methods and helpers

get_global_currencies()

This method is used to retrieve all the currencies from Tickera system, for example:

 

add_error($error_message)

This method adds an error message and redirects user to the payment page, example:

 

is_payment_page()

Retrieves whether current page is payment page or not. It's useful when you want to enqueue_script on that particular page for instance. For example:

 

is_active()

This method determines if the current payment gateway is active or not. Example:

 

total()

This method returns cart total value

 

subtotal()

This method returns cart subtotal value

 

total_fees()

This method returns cart total fees value

 

total_taxes()

This method returns cart total taxes value

 

buyer_info( $part )

This method returns part of the buyer info. Possible $part values: full_name, first_name, last_name, email. Example:

 

get_option($option_name = '', $default_value = '')

This method returns value of the payment gateway option. Example:

 

 


Leave Us A Message!