Conn =& $this->Application->GetADODBConnection(); } /** * Returns payment form submit url * * @return string */ function getFormAction($gw_params) { return $this->Application->ProcessParsedTag('m', 'FormAction', Array() ); } /** * Processed input data and convets it to fields understandable by gateway * * @param Array $item_data * @param Array $tag_params additional params for gateway passed through tag * @param Array $gw_params gateway params from payment type config * @return Array */ function getHiddenFields($item_data, $tag_params, $gw_params) { return Array( 'events[ord]' => 'OnCompleteOrder', 'success_template' => $tag_params['return_template'], 'failure_template' => $tag_params['cancel_template']); } function NeedPlaceButton($item_data, $tag_params, $gw_params) { return true; } /** * Process notification about payment from payment gateway * */ function processNotification() { } /** * Perform PREAUTH/SALE type transaction direct from php script wihtout redirecting to 3rd-party website * * @param Array $item_data * @param Array $gw_params * @return bool */ function DirectPayment($item_data, $gw_params) { return true; } /** * Perform SALE type transaction direct from php script wihtout redirecting to 3rd-party website * * @param Array $item_data * @param Array $gw_params * @return bool */ function Charge($item_data, $gw_params) { return true; } /** * Returns gateway responce from last operation * * @return string */ function getGWResponce() { return $this->gw_responce; } /** * Parse previosly saved gw responce into associative array * * @param string $gw_responce * @return Array */ function parseGWResponce($gw_responce, $gw_params) { return $this->gw_responce; } /** * Returns true if we should use testing mode * * @return bool */ function IsTestMode() { return defined('DEBUG_MODE') && constOn('DBG_PAYMENT_GW'); } /** * Convery primary currency to selected (if they are the same, converter will just return) * * @param double $value * @param string $iso * @param bool $format_value * @return double */ function ConvertCurrency($value, $iso, $format_value = true) { $converter =& $this->Application->recallObject('kCurrencyRates'); $value = $converter->Convert($value, 'PRIMARY', $iso); return $format_value ? sprintf('%.2f', $value) : $value; } function InstallData() { return array(); } function Install() { if ($this->IsInstalled()) return; $data = $this->InstallData(); if (!$data) return; $query = sprintf('INSERT INTO '.TABLE_PREFIX.'Gateways (Name, ClassName, ClassFile, RequireCCFields) VALUES (%s, %s, %s, %s)', $this->Conn->qstr(getArrayValue($data, 'Gateway', 'Name')), $this->Conn->qstr(getArrayValue($data, 'Gateway', 'ClassName')), $this->Conn->qstr(getArrayValue($data, 'Gateway', 'ClassFile')), $this->Conn->qstr(getArrayValue($data, 'Gateway', 'RequireCCFields')) ); $this->Conn->Query($query); $gw_id = $this->Conn->getInsertID(); foreach ($data['ConfigFields'] as $field => $properties) { $query = sprintf('INSERT INTO '.TABLE_PREFIX.'GatewayConfigFields (SystemFieldName, FieldName, ElementType, ValueList, GatewayId) VALUES (%s, %s, %s, %s, %s)', $this->Conn->qstr($field), $this->Conn->qstr($properties['Name']), $this->Conn->qstr($properties['Type']), $this->Conn->qstr($properties['ValueList']), $gw_id ); $this->Conn->Query($query); $fld_id = $this->Conn->getInsertID(); $query = sprintf('INSERT INTO '.TABLE_PREFIX.'GatewayConfigValues (GWConfigFieldId, PaymentTypeId, Value) VALUES (%s, %s, %s)', $fld_id, $gw_id, $this->Conn->qstr($properties['Default']) ); $this->Conn->Query($query); } } function IsInstalled() { $data = $this->InstallData(); if (!$data) return true; $sql ='SELECT GatewayId FROM '.TABLE_PREFIX.'Gateways WHERE ClassName = '.$this->Conn->qstr(getArrayValue($data, 'Gateway', 'ClassName')); return $this->Conn->GetOne($sql); } function getErrorMsg() { return ''; } function gettestccnumbers() { return array(); } } ?>