Third Party Gateway

Follow the steps below to create a third party gateway module.

A Third Party Gateway module is one where a customer leaves the site to pay and returns when the payment process is complete. Examples include PayPal Standard, 2Checkout

Implementation guide

  1. Delete the yourmodulename_capture function from the module template since this is only required for Merchant Gateway modules.
  2. Define and return the HTML code that will forward the user to the payment gateway to complete the payment process inside the yourmodulename_link function. This is typically done by way of an HTML form utilizing the POST method.
  3. Optionally if your payment gateway supports sending notifications upon successful receipt of payments, create a Callback File to receive and handle those.
  4. If your payment gateway supports refunds, implement support for Refunds.

Variables

The following parameters are passed to the _link function along with all defined configuration parameters and their values.

Invoice Variables

$params['invoiceid'] # Invoice ID Number
$params['description'] # Description (eg. Company Name - Invoice #xxx)
$params['amount'] # Format: xxx.xx
$params['currency'] # Currency Code (eg. GBD, USD, etc...)

Client Variables

$params['clientdetails']['firstname'] # Client's First Name
$params['clientdetails']['lastname'] # Client's Last Name
$params['clientdetails']['email'] # Client's Email Address
$params['clientdetails']['address1'] # Client's Address
$params['clientdetails']['address2']
$params['clientdetails']['city']
$params['clientdetails']['state']
$params['clientdetails']['postcode']
$params['clientdetails']['country']
$params['clientdetails']['phonenumber']

System Variables

$params['companyname'] # your Company Name setting in WHMCS
$params['systemurl'] # the url to the WHMCS Client Area
$params['returnurl'] # the return url to the invoice
$params['langpaynow'] # Language string for "Pay Now"
$params['name'] # Module display name
$params['paymentmethod'] # Module name
$params['whmcsVersion'] # WHMCS Version Number

Response Format

The _link function should return an HTML code block that can be rendered to the user. This should typically take the format of an HTML form.

Simple Example

Below is a very simple demonstration of a link function that forwards the end user to https://www.example.com/checkout using a form post containing the invoice data. For a more complete example, please refer to the Sample Third Party Gateway module on Github.

function yourmodulename_link($params) {
    return '<form method="post" action="https://www.example.com/checkout">
        <input type="invoice_number" value="' . $params['invoiceid'] . '" />
        <input type="description" value="' . $params['description'] . '" />
        <input type="amount" value="' . $params['amount'] . '" />
        <input type="currency" value="' . $params['currency'] . '" />
        <input type="submit" value="' . $params['langpaynow'] . '" />
        </form>';
}