I am integrating alliedwallet.com quick pay which is third party payment gateway.
It is simple as I configured and forwarding all relevant detail to gateway and once I made payment there and returned back to invoice page its not marking invoice paid.
Here is my configration file.
------------------------------------------
And here is callback file.
----------------------------
Gateway return status is: TransactionStatus and result is for success: Successful
There is no error on success transcation but its not making invoice paid. Can any one point where is issue?
Thanks,
Raza
It is simple as I configured and forwarding all relevant detail to gateway and once I made payment there and returned back to invoice page its not marking invoice paid.
Here is my configration file.
PHP Code:
<?php
/**
* WHMCS Sample Payment Gateway Module
*
* Payment Gateway modules allow you to integrate payment solutions with the
* WHMCS platform.
*
* This sample file demonstrates how a payment gateway module for WHMCS should
* be structured and all supported functionality it can contain.
*
* Within the module itself, all functions must be prefixed with the module
* filename, followed by an underscore, and then the function name. For this
* example file, the filename is "alliedwallet" and therefore all functions
* begin "alliedwallet_".
*
* If your module or third party API does not support a given function, you
* should not define that function within your module. Only the _config
* function is required.
*
* For more information, please refer to the online documentation.
*
* @see http://docs.whmcs.com/Gateway_Module_Developer_Docs
*
* @copyright Copyright (c) WHMCS Limited 2015
* @license http://www.whmcs.com/license/ WHMCS Eula
*/
if (!defined("WHMCS")) {
die("This file cannot be accessed directly");
}
/**
* Define module related meta data.
*
* Values returned here are used to determine module related capabilities and
* settings.
*
* @see http://docs.whmcs.com/Gateway_Module_Meta_Data_Parameters
*
* @return array
*/
function alliedwallet_MetaData()
{
return array(
'DisplayName' => 'Sample Payment Gateway Module',
'APIVersion' => '1.1', // Use API Version 1.1
'DisableLocalCredtCardInput' => true,
'TokenisedStorage' => false,
);
}
/**
* Define gateway configuration options.
*
* The fields you define here determine the configuration options that are
* presented to administrator users when activating and configuring your
* payment gateway module for use.
*
* Supported field types include:
* * text
* * password
* * yesno
* * dropdown
* * radio
* * textarea
*
* Examples of each field type and their possible configuration parameters are
* provided in the sample function below.
*
* @return array
*/
function alliedwallet_config()
{
return array(
// the friendly display name for a payment gateway should be
// defined here for backwards compatibility
'FriendlyName' => array(
'Type' => 'System',
'Value' => 'Allied Wallet',
),
// a text field type allows for single line text input
'accountID' => array(
'FriendlyName' => 'Merchant ID',
'Type' => 'text',
'Size' => '25',
'Default' => '',
'Description' => 'Enter your account ID here',
),
// a text field type allows for single line text input
'siteID' => array(
'FriendlyName' => 'SiteID',
'Type' => 'text',
'Size' => '25',
'Default' => '',
'Description' => 'Enter your site ID here',
),
// a password field type allows for masked text input
'secretKey' => array(
'FriendlyName' => 'Secret Key',
'Type' => 'text',
'Size' => '25',
'Default' => '',
'Description' => 'Enter secret key here',
),
// the yesno field type displays a single checkbox option
'testMode' => array(
'FriendlyName' => 'Test Mode',
'Type' => 'yesno',
'Description' => 'Tick to enable test mode',
),
);
}
/**
* Payment link.
*
* Required by third party payment gateway modules only.
*
* Defines the HTML output displayed on an invoice. Typically consists of an
* HTML form that will take the user to the payment gateway endpoint.
*
* @param array $params Payment Gateway Module Parameters
*
* @see http://docs.whmcs.com/Payment_Gateway_Module_Parameters
*
* @return string
*/
function alliedwallet_link($params)
{
// Gateway Configuration Parameters
$accountId = $params['accountID'];
$siteID = $params['siteID'];
$secretKey = $params['secretKey'];
$testMode = $params['testMode'];
$dropdownField = $params['dropdownField'];
$radioField = $params['radioField'];
$textareaField = $params['textareaField'];
// Invoice Parameters
$invoiceId = $params['invoiceid'];
$description = $params["description"];
$amount = $params['amount'];
$currencyCode = $params['currency'];
// Client Parameters
$firstname = $params['clientdetails']['firstname'];
$lastname = $params['clientdetails']['lastname'];
$email = $params['clientdetails']['email'];
$address1 = $params['clientdetails']['address1'];
$address2 = $params['clientdetails']['address2'];
$city = $params['clientdetails']['city'];
$state = $params['clientdetails']['state'];
$postcode = $params['clientdetails']['postcode'];
$country = $params['clientdetails']['country'];
$phone = $params['clientdetails']['phonenumber'];
// System Parameters
$companyName = $params['companyname'];
$systemUrl = $params['systemurl'];
$returnUrl = $params['returnurl'];
$langPayNow = $params['langpaynow'];
$moduleDisplayName = $params['name'];
$moduleName = $params['paymentmethod'];
$whmcsVersion = $params['whmcsVersion'];
$url = 'https://quickpay.alliedwallet.com';
$postfields = array();
$postfields['MerchantID'] = $accountId;
$postfields['QuickPayToken'] = $secretKey;
$postfields['SiteID'] = $siteID;
$postfields['MembershipRequired'] = 'false';
$postfields['ShippingRequired'] = 'false';
$postfields['ItemName[0]'] = $invoiceId;
$postfields['ItemQuantity[0]'] = '1';
$postfields['ItemDesc[0]'] = $description;
$postfields['ItemAmount[0]'] = $amount;
$postfields['MerchantReference'] = $invoiceId;
$postfields['ItemAmount[0]'] = $amount;
$postfields['AmountTotal'] = $amount;
$postfields['CurrencyID'] = $currencyCode;
$postfields['FirstName'] = $firstname;
$postfields['LastName'] = $lastname;
$postfields['Email'] = $email;
$postfields['Address'] = $address1;
$postfields['Address2'] = $address2;
$postfields['City'] = $city;
$postfields['State'] = $state;
$postfields['PostalCode'] = $postcode;
$postfields['Country'] = $country;
$postfields['Phone'] = $phone;
$postfields['ConfirmURL'] = $systemUrl . '/modules/gateways/callback/' . $moduleName . '.php';
$postfields['ApprovedURL'] = $returnUrl;
$postfields['DeclinedURL'] = $returnUrl;
$htmlOutput = '<form method="post" action="' . $url . '">';
foreach ($postfields as $k => $v) {
$htmlOutput .= '<input type="hidden" name="' . $k . '" value="' . urlencode($v) . '" />';
}
$htmlOutput .= '<input type="submit" value="' . $langPayNow . '" />';
$htmlOutput .= '</form>';
return $htmlOutput;
}
------------------------------------------
And here is callback file.
PHP Code:
<?php
/**
* WHMCS Sample Payment Callback File
*
* This sample file demonstrates how a payment gateway callback should be
* handled within WHMCS.
*
* It demonstrates verifying that the payment gateway module is active,
* validating an Invoice ID, checking for the existence of a Transaction ID,
* Logging the Transaction for debugging and Adding Payment to an Invoice.
*
* For more information, please refer to the online documentation.
*
* @see http://docs.whmcs.com/Gateway_Module_Developer_Docs
*
* @copyright Copyright (c) WHMCS Limited 2015
* @license http://www.whmcs.com/license/ WHMCS Eula
*/
// Require libraries needed for gateway module functions.
require_once __DIR__ . '/../../../init.php';
require_once __DIR__ . '/../../../includes/gatewayfunctions.php';
require_once __DIR__ . '/../../../includes/invoicefunctions.php';
// Detect module name from filename.
$gatewayModuleName = basename(__FILE__, '.php');
// Fetch gateway configuration parameters.
$gatewayParams = getGatewayVariables($gatewayModuleName);
// Die if module is not active.
if (!$gatewayParams['type']) {
die("Module Not Activated");
}
// Retrieve data returned in payment gateway callback
// Varies per payment gateway
$success = $_POST["TransactionStatus"];
$invoiceId = $_POST["MerchantReference"];
$transactionId = $_POST["TransactionID"];
$paymentAmount = $_POST["Amount"];
#$paymentFee = $_POST["x_fee"];
$transactionStatus = $success ? 'Successful' : 'Failure';
/**
* Validate Callback Invoice ID.
*
* Checks invoice ID is a valid invoice number. Note it will count an
* invoice in any status as valid.
*
* Performs a die upon encountering an invalid Invoice ID.
*
* Returns a normalised invoice ID.
*/
$invoiceId = checkCbInvoiceID($invoiceId, $gatewayParams['name']);
/**
* Check Callback Transaction ID.
*
* Performs a check for any existing transactions with the same given
* transaction number.
*
* Performs a die upon encountering a duplicate.
*/
checkCbTransID($transactionId);
/**
* Log Transaction.
*
* Add an entry to the Gateway Log for debugging purposes.
*
* The debug data can be a string or an array. In the case of an
* array it will be
*
* @param string $gatewayName Display label
* @param string|array $debugData Data to log
* @param string $transactionStatus Status
*/
logTransaction($gatewayParams['name'], $_POST, $transactionStatus);
if ($success) {
/**
* Add Invoice Payment.
*
* Applies a payment transaction entry to the given invoice ID.
*
* @param int $invoiceId Invoice ID
* @param string $transactionId Transaction ID
* @param float $paymentAmount Amount paid (defaults to full balance)
* @param float $paymentFee Payment fee (optional)
* @param string $gatewayModule Gateway module name
*/
addInvoicePayment(
$invoiceId,
$transactionId,
$paymentAmount,
$gatewayModuleName
);
}
Gateway return status is: TransactionStatus and result is for success: Successful
There is no error on success transcation but its not making invoice paid. Can any one point where is issue?
Thanks,
Raza