diff --git a/modules/gateways/hutko.php b/modules/gateways/hutko.php new file mode 100644 index 0000000..bc91fd5 --- /dev/null +++ b/modules/gateways/hutko.php @@ -0,0 +1,126 @@ + '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 '
Error: Currency code missing from invoice.
'; + } + + // 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 = '
'; + foreach ($postfields as $k => $v) { + $htmlOutput .= ''; + } + $htmlOutput .= ''; + $htmlOutput .= '
'; + // + 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; +}