Add modules/gateways/hutko.php
This commit is contained in:
126
modules/gateways/hutko.php
Normal file
126
modules/gateways/hutko.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
if (!defined("WHMCS")) {
|
||||
die("This file cannot be accessed directly");
|
||||
}
|
||||
|
||||
require_once dirname(__FILE__) . "/hutko/hutko_helper.php";
|
||||
|
||||
function hutko_MetaData()
|
||||
{
|
||||
return array(
|
||||
'DisplayName' => 'hutko',
|
||||
'APIVersion' => '1.1', // Use API Version 1.1
|
||||
'DisableLocalCredtCardInput' => true,
|
||||
'TokenisedStorage' => false,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function hutko_config()
|
||||
{
|
||||
return array(
|
||||
// the friendly display name for a payment gateway should be
|
||||
// defined here for backwards compatibility
|
||||
'FriendlyName' => array(
|
||||
'Type' => 'System',
|
||||
'Value' => 'hutko',
|
||||
),
|
||||
// a text field type allows for single line text input
|
||||
'accountID' => array(
|
||||
'FriendlyName' => 'Merchant ID',
|
||||
'Type' => 'text',
|
||||
'Size' => '25',
|
||||
'Default' => '',
|
||||
'Description' => 'Enter your Merchant ID here',
|
||||
),
|
||||
// a password field type allows for masked text input
|
||||
'secretKey' => array(
|
||||
'FriendlyName' => 'Secret Key',
|
||||
'Type' => 'password',
|
||||
'Size' => '25',
|
||||
'Default' => '',
|
||||
'Description' => 'Enter secret key here',
|
||||
),
|
||||
|
||||
'cur' => array(
|
||||
'FriendlyName' => 'Select Default Currency',
|
||||
'Type' => 'dropdown',
|
||||
'Options' => array(
|
||||
'UAH' => 'Ukrainian Hryvnia',
|
||||
'USD' => 'US Dollar',
|
||||
'EUR' => 'Euro',
|
||||
'GBP' => 'Pound sterling',
|
||||
'CZK' => 'Koruna česká',
|
||||
|
||||
),
|
||||
'Description' => 'Choose currency',
|
||||
),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function hutko_link($params)
|
||||
{
|
||||
// Invoice Parameters
|
||||
|
||||
$currencyCode = $params['currency'];
|
||||
if (empty($currencyCode)) {
|
||||
return '<div class="alert alert-danger">Error: Currency code missing from invoice.</div>';
|
||||
}
|
||||
|
||||
// System Parameters
|
||||
$systemUrl = $params['systemurl'];
|
||||
$langPayNow = $params['langpaynow'];
|
||||
$moduleName = $params['paymentmethod'];
|
||||
|
||||
$postfields = [];
|
||||
$postfields['order_id'] = $params['invoiceid'] . Hutko_Helper::ORDER_SEPARATOR . time();
|
||||
$postfields['merchant_id'] = $params['accountID'];
|
||||
$postfields['order_desc'] = $params["description"];
|
||||
$postfields['amount'] = round($params['amount'] * 100, 2);
|
||||
$postfields['currency'] = $currencyCode;
|
||||
$postfields['reservation_data'] = Hutko_Helper::buildReservationData($params);
|
||||
$postfields['server_callback_url'] = $systemUrl . '/modules/gateways/callback/' . $moduleName . '.php?callbackMode=server';
|
||||
$postfields['response_url'] = $systemUrl . '/modules/gateways/callback/' . $moduleName . '.php';
|
||||
$postfields['sender_email'] = $params['clientdetails']['email'];
|
||||
$postfields['signature'] = Hutko_Helper::getSignature($postfields, $params['secretKey']);
|
||||
|
||||
$htmlOutput = '<form method="post" action="' . Hutko_Helper::REDIRECT_URL . '">';
|
||||
foreach ($postfields as $k => $v) {
|
||||
$htmlOutput .= '<input type="hidden" name="' . $k . '" value="' . $v . '" />';
|
||||
}
|
||||
$htmlOutput .= '<input type="submit" class="btn btn-action" value="' . $langPayNow . '" />';
|
||||
$htmlOutput .= '</form>';
|
||||
//
|
||||
return $htmlOutput;
|
||||
}
|
||||
|
||||
function hutko_refund($params)
|
||||
{
|
||||
|
||||
try {
|
||||
$apiCall = Hutko_Helper::refund($params);
|
||||
|
||||
if ($apiCall['response']['response_status'] == 'failure') {
|
||||
$result = array(
|
||||
'status' => 'error',
|
||||
'rawdata' => $apiCall['response']['error_message']
|
||||
);
|
||||
} else {
|
||||
$result = array(
|
||||
'status' => 'success',
|
||||
'rawdata' => $apiCall['response'],
|
||||
'transid' => $apiCall['response']['order_id'],
|
||||
'fees' => 0,
|
||||
);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$result = array(
|
||||
'status' => 'error',
|
||||
'rawdata' => $e->getMessage()
|
||||
);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
Reference in New Issue
Block a user