is kompliziert
hatte den ordner payone komplett gelöscht um die fehlermeldungen zu minimieren
mit wieder hergestelltem payone ordner wird es richtig brutal mit fehlermeldungen
ich nutze aber payone gar nicht im shop
kann ich denn nicht ein general-überschreib-update auf alle zahlungsoptionen machen?
), 'accountbased' => array( 'lastschrift', 'invoice', 'prepay', 'cod', 'payolution_debit', 'payolution_invoice', ), 'installment' => array( 'billsafe', 'commerzfinanz', 'klarna', 'payolution_financing', 'payolution_monthly', ), ); RETURN $payment_types; } public FUNCTION getBankGroups() { $bankgroups_array = array(); $bankgroups_query = xtc_db_query("SELECT * FROM `payone_bankgroups` ORDER BY bank_name"); while ($bankgroups = xtc_db_fetch_array($bankgroups_query)) { $bankgroups_array[$bankgroups['identifier']][$bankgroups['bank_code']] = $bankgroups['bank_name']; } RETURN $bankgroups_array; } public FUNCTION getSepaCountries() { $sepa_countries_array = array(); $sepa_countries_query = xtc_db_query("SELECT * FROM `payone_sepa_countries` ORDER BY countries_name"); while ($sepa_countries = xtc_db_fetch_array($sepa_countries_query)) { $sepa_countries_array[] = $sepa_countries; } RETURN $sepa_countries_array; } protected FUNCTION _getDefaultConfig() { $config = array( 'orders_status' => array( 'tmp' => '1', ), 'global' => array( 'merchant_id' => 'no_id', 'portal_id' => 'no_id', 'subaccount_id' => 'no_id', 'key' => 'no_key', 'operating_mode' => 'test', 'authorization_method' => 'auth', 'send_cart' => 'false', ), 'address_check' => array( 'active' => 'false', 'operating_mode' => 'test', // test | live 'billing_address' => 'none', // NONE | basic | person 'delivery_address' => 'none', // NONE | basic | person 'automatic_correction' => 'no', // no | yes | USER 'error_mode' => 'abort', // abort | reenter | CHECK | continue 'min_cart_value' => '0', 'max_cart_value' => '10000', 'validity' => '3', 'pstatus' => array( 'nopcheck' => 'green', 'fullnameknown' => 'green', 'lastnameknown' => 'green', 'nameunknown' => 'green', 'nameaddrambiguity' => 'green', 'undeliverable' => 'green', 'dead' => 'green', 'postalerror' => 'green', ), ), 'credit_risk' => array( 'active' => 'false', 'operating_mode' => 'test', 'timeofcheck' => 'before', 'typeofcheck' => 'iscorehard', 'newclientdefault' => 'green', 'validity' => '3', 'min_cart_value' => '100', 'max_cart_value' => '5000', 'checkforgenre' => array(), 'error_mode' => 'continue', 'notice' => array( 'active' => 'false', ), 'confirmation' => array( 'active' => 'false', ), 'abtest' => array( 'active' => 'false', 'value' => '3', ), ), ); foreach($this->getStatusNames() AS $sname) { $config['orders_status'][$sname] = '1'; } RETURN $config; } protected FUNCTION _getGenreModuleMapping() { $mapping = array( 'creditcard' => 'cc', 'onlinetransfer' => 'otrans', 'ewallet' => 'wlt', 'accountbased' => 'account', 'installment' => 'installment', ); RETURN $mapping; } public FUNCTION _getKlarnaCountries() { $KlarnaCountries = array('DE', 'AT', 'NL', 'DK', 'FI', 'NO', 'SE'); RETURN $KlarnaCountries; } protected FUNCTION _getPaymentGenreDefaultConfig($genre) { $payment_types = $this->getPaymentTypes(); $valid_genres = array_keys($payment_types); IF (!in_array($genre, $valid_genres)) { throw NEW Exception('invalid payment genre '.$genre); } $default_config = $this->_getDefaultConfig(); $configuration = array( 'genre' => $genre, 'global_override' => 'false', 'global' => $default_config['global'], 'name' => constant('PAYGENRE_'.strtoupper($genre)).' '.uniqid(), 'active' => 'false', 'order' => 0, 'min_cart_value' => 0, 'max_cart_value' => 5000, 'operating_mode' => 'test', 'countries' => array(), 'allow_red' => 'false', 'allow_yellow' => 'false', 'allow_green' => 'true', 'genre_specific' => array(), ); foreach($payment_types[$genre] AS $pt) { $configuration['types'][$pt]['active'] = 'false'; $configuration['types'][$pt]['name'] = 'paymenttype_'.$pt; } switch($genre) { CASE 'creditcard': $configuration['genre_specific']['check_cav'] = 'false'; break; CASE 'accountbased': $configuration['genre_specific']['check_bankdata'] = 'none'; $configuration['genre_specific']['sepa_account_countries'] = array(); $configuration['genre_specific']['sepa_display_ktoblz'] = 'false'; $configuration['genre_specific']['sepa_use_managemandate'] = 'false'; $configuration['genre_specific']['sepa_download_pdf'] = 'false'; break; CASE 'onlinetransfer': CASE 'ewallet': break; CASE 'installment': $configuration['genre_specific']['klarna'] = array( 'storeid' => '', 'countries' => array() ); break; } RETURN $configuration; } public FUNCTION getConfig($identifier = NULL) { IF ($this->checkConfig()) { $configuration_flat = array(); $query = xtc_db_query("SELECT * FROM `payone_config`"); while($row = xtc_db_fetch_array($query)) { $configuration_flat[$row['path']] = $row['value']; } $configuration = $this->_inflateArray($configuration_flat); $default_config = $this->_getDefaultConfig(); $configuration = $this->mergeConfigs($default_config, $configuration); IF (!empty($identifier) && array_key_exists($identifier, $configuration)) { RETURN $configuration[$identifier]; } ELSE { RETURN $configuration; } } ELSE { RETURN array(); } } public FUNCTION getGenresConfig() { $config = $this->getConfig(); $genre_configs = array(); $order_array = array(); foreach($config AS $topkey => $data) { IF (strpos($topkey, 'paymentgenre') === FALSE) { continue; } $order_key = sprintf('%05d_%s', $data['order'], $topkey); $order_array[$order_key] = $topkey; } ksort($order_array); foreach($order_array AS $sort_key => $top_key) { $genre_configs[$top_key] = $config[$top_key]; } RETURN $genre_configs; } public FUNCTION setConfig($configuration) { $flatconfig = $this->_flattenArray($configuration); xtc_db_query("TRUNCATE `payone_config`"); foreach($flatconfig AS $path => $value) { xtc_db_query("INSERT INTO `payone_config` SET `path` = '".xtc_db_input($path)."', `value` = '".xtc_db_input($value)."'"); } //$this->adjustSortOrders(); } public FUNCTION adjustSortOrders() { $gconfig = $this->getGenresConfig(); $module_mapping = $this->_getGenreModuleMapping(); foreach($gconfig AS $gc) { $module = $module_mapping[$gc['genre']]; $query = "UPDATE `configuration` SET `configuration_value` = ".(INT)$gc['order']." WHERE `configuration_key` = 'MODULE_PAYMENT_PAYONE_".strtoupper($module)."_SORT_ORDER'"; xtc_db_query($query); } $modules_order_result = xtc_db_query("SELECT `configuration_key` FROM `configuration` WHERE `configuration_key` LIKE 'module_payment_%_sort_order' order by configuration_value asc"); $payment_modules = array(); while($row = xtc_db_fetch_array($modules_order_result)) { $module = strtolower(preg_replace('/MODULE_PAYMENT_(.*)_SORT_ORDER/', '$1', $row['configuration_key'])); $payment_modules[] = $module.'.php'; } xtc_db_query("UPDATE `configuration` SET `configuration_value` = '".xtc_db_input(implode(';', $payment_modules))."' WHERE `configuration_key` = 'MODULE_PAYMENT_INSTALLED'"); } public FUNCTION mergeConfigs($old_config, $new_config) { $old_keys = array_keys($old_config); IF (is_array($old_keys) && isset($old_keys[0]) && $old_keys[0] === 0) { # special CASE: numerically indexed array, e.g. list OF countries $merged = array_values(array_unique($new_config)); } ELSE { $merged = array(); foreach($old_config AS $key => $value) { IF (isset($new_config[$key]) && empty($new_config[$key]) && !is_numeric($new_config[$key])) { IF (array_key_exists($key, $new_config)) { IF (is_array($value)) { $merged[$key] = array(); } ELSE IF ($value == 'true' || $value == 'false') { $merged[$key] = 'false'; } ELSE { $merged[$key] = ''; } } ELSE { IF ($value == 'true' || $value == 'false') { $merged[$key] = 'false'; } ELSE { $merged[$key] = $value; } } } ELSE { IF (is_array($value)) { $merged[$key] = $this->mergeConfigs($value, $new_config[$key]); } ELSE IF ($value == 'true' || $value == 'false') { $merged[$key] = $new_config[$key] == 'true' ? 'true' : 'false'; } ELSE { $merged[$key] = $new_config[$key]; } } IF ($value == 'true' || $value == 'false') { $merged[$key] = $new_config[$key] == 'true' ? 'true' : 'false'; } } foreach($new_config AS $nkey => $nvalue) { IF (!array_key_exists($nkey, $merged)) { $merged[$nkey] = $nvalue; } } } RETURN $merged; } protected FUNCTION _flattenArray($input, $prefix = '') { $divider = '/'; IF (!empty($prefix)) { $prefix .= $divider; } $output = array(); foreach($input AS $key => $value) { IF (is_array($value)) { IF (empty($value)) { $output[$prefix.$key] = ''; } ELSE { $flattened = $this->_flattenArray($value, $key); foreach($flattened AS $fkey => $fvalue) { $output[$prefix.$fkey] = $fvalue; } } } ELSE { $output[$prefix.$key] = $value; } } RETURN $output; } protected FUNCTION _inflateArray($input) { $divider = '/'; $output = array(); foreach($input AS $key => $value) { $keys = explode($divider, $key); $subarray =& $output; while(COUNT($keys) > 1) { $subkey = array_shift($keys); IF (is_array($subarray) && array_key_exists($subkey, $subarray) && !is_array($subarray[$subkey])) { $subarray[$subkey] = array(); } $subarray =& $subarray[$subkey]; } $final_key = array_shift($keys); $subarray[$final_key] = $value; } RETURN $output; } public FUNCTION dumpConfig() { $t_filename = DIR_FS_CATALOG.'cache/payone-config-'.uniqid().'.cfg'; $t_fh = @fopen($t_filename, 'w'); IF ($t_fh == FALSE) { RETURN FALSE; } $config_array = $this->getConfig(); $config_flat_array = $this->_flattenArray($config_array); foreach($config_flat_array AS $cfg_key => $cfg_value) { fwrite($t_fh, $cfg_key. "\t". $cfg_value ."\n"); } fclose($t_fh); RETURN $t_filename; } public FUNCTION addPaymentGenreConfig($genre) { $genre_config = $this->_getPaymentGenreDefaultConfig($genre); $identifier = 'paymentgenre_'.uniqid(); $configuration = $this->getConfig(); $configuration[$identifier] = $genre_config; $this->setConfig($configuration); } public FUNCTION getPaymentGenreIdentifiers() { $configuration = $this->getConfig(); $config_identifiers = array_keys($configuration); $paymentgenre_identifiers = array(); foreach($config_identifiers AS $ci) { IF (strpos($ci, 'paymentgenre_') === 0) { $paymentgenre_identifiers[] = $ci; } } RETURN $paymentgenre_identifiers; } public FUNCTION getTypesForGenre($genre_identifier) { $pgenre = $this->getConfig($genre_identifier); $types = array(); IF ($pgenre['genre'] == 'creditcard') { $cctypes = array( 'visa' => 'V', 'mastercard' => 'M', 'amex' => 'A', 'cartebleue' => 'B', 'dinersclub' => 'D', 'discover' => 'C', 'jcb' => 'J', 'maestro' => 'O', ); foreach($cctypes AS $cctype => $shorttype) { IF ($pgenre['types'][$cctype]['active'] != 'true') { continue; } $types[] = array( 'typekey' => $cctype, 'shorttype' => $shorttype, 'typename' => $pgenre['types'][$cctype]['name'], ); } } RETURN $types; } public FUNCTION getStandardParameters($request = NULL, $config_override = NULL) { $config = $this->getConfig('global'); IF ($config_override != NULL) { $config = array_merge($config, $config_override); } require_once(DIR_FS_INC.'get_database_version.inc.php'); $db_version = get_database_version(); $params = array( 'mid' => $config['merchant_id'], 'portalid' => $config['portal_id'], 'aid' => $config['subaccount_id'], 'mode' => $config['operating_mode'], 'responsetype' => 'REDIRECT', 'encoding' => 'ISO-8859-1', 'language' => strtolower($_SESSION['language_code']), 'solution_name' => PROJECT_VERSION, 'solution_version' => $db_version['full'], 'integrator_name' => 'Modified', 'integrator_version' => $this->integrator_version, 'api_version' => $this->api_version, ); IF ($request !== NULL) { $params['request'] = $request; } RETURN $params; } public FUNCTION computeHash($params, $key) { $hash_keys = array('access_aboperiod', 'access_aboprice', 'access_canceltime', 'access_expiretime', 'access_period', 'access_price', 'access_starttime', 'access_vat', 'accesscode', 'accessname', 'addresschecktype', 'aid', 'amount', 'backurl', 'booking_date', 'checktype', 'clearingtype', 'consumerscoretype', 'currency', 'customerid', 'document_date', 'due_time', 'eci', 'encoding', 'errorurl', 'exiturl', 'invoice_deliverymode', 'invoiceappendix', 'invoiceid', 'mid', 'mode', 'narrative_text', 'param', 'portalid', 'productid', 'reference', 'request', 'responsetype', 'settleaccount', 'settleperiod', 'settletime', 'storecarddata', 'successurl', 'userid', 'vaccountname', 'vreference'); $varnum_hash_keys = array('de[\d+]', 'id[\d+]', 'no[\d+]', 'pr[\d+]', 'ti[\d+]', 'va[\d+]'); $hash_data = array(); foreach($params AS $pkey => $pvalue) { IF (in_array($pkey, $hash_keys) || preg_match('/^(de|id|no|pr|ti|va)\[\d+\]$/', $pkey) == 1) { $hash_data[$pkey] = $pvalue; } } ksort($hash_data); $hash_string = implode('', $hash_data); $hash_string .= $key; $hash = md5($hash_string); RETURN $hash; } public FUNCTION getFormActionURL() { RETURN $this->_client_api_url; } public FUNCTION retrieveSepaMandate($file_reference) { $global_config = $this->getConfig('global'); $standard_parameters = $this->getStandardParameters(); $builder = NEW Payone_Builder($this->getPayoneConfig()); $service = $builder->buildServiceManagementGetFile(); $request_data = array( 'key' => $global_config['key'], 'file_reference' => $file_reference, 'file_type' => 'SEPA_MANDATE', 'file_format' => 'PDF', ); $params = array_merge($standard_parameters, $request_data); $request = NEW Payone_Api_Request_GetFile($params); $result = $service->getFile($request); IF ($result instanceof Payone_Api_Response_Management_GetFile) { $t_pdf_data = $result->getRawResponse(); $mandate_filename = 'sepa_mandate_'.$_SESSION['customer_id'].'_'.md5($file_reference).'.pdf'; $bytes_written = file_put_contents(DIR_FS_DOWNLOAD_PUBLIC.$mandate_filename, $t_pdf_data); IF ($bytes_written === FALSE) { $this->log('ERROR writing mandate file '.DIR_FS_DOWNLOAD_PUBLIC.$mandate_filename); RETURN FALSE; } ELSE { $this->log('SEPA mandate written to '.$mandate_filename.' ('.$bytes_written.' bytes)'); RETURN $mandate_filename; } } ELSE { RETURN FALSE; } } public FUNCTION getAvailablePaymentGenres() { $config = $this->getGenresConfig(); $available = array(); $cart_value = $_SESSION['cart']->show_total(); $billto_address = $this->_getAddressBookEntry($_SESSION['billto'], $_SESSION['customer_id']); foreach($config AS $topkey => $pgconfig) { IF ($pgconfig['active'] != 'true') { continue; } IF ($pgconfig['min_cart_value'] > $cart_value || $pgconfig['max_cart_value'] < $cart_value) { $this->log("$topkey cart value out of range"); continue; } IF (!is_array($pgconfig['countries']) || !in_array($billto_address['countries_iso_code_2'], $pgconfig['countries'])) { continue; } $available[$topkey] = $pgconfig; } RETURN $available; } protected FUNCTION _getAddressBookEntry($ab_id, $customers_id = NULL) { $query = "SELECT ab.*, c.customers_telephone, DATE(c.customers_dob) AS dob_date, cy.* FROM ".TABLE_ADDRESS_BOOK." ab LEFT JOIN ".TABLE_CUSTOMERS." c ON c.customers_id = ab.customers_id LEFT JOIN ".TABLE_COUNTRIES." cy ON cy.countries_id = ab.entry_country_id WHERE ab.address_book_id = '".(INT)$ab_id."'"; IF ($customers_id !== NULL) { $query .= " AND c.customers_id = '".(INT)$customers_id."'"; } /* we need uncached data here because the database entry may have changed within the current request */ $result = xtc_db_query($query, 'db_link', FALSE); $entry = FALSE; while($row = xtc_db_fetch_array($result)) { $entry = $row; } RETURN $entry; } public FUNCTION getAddressBookEntry($ab_id, $customer_id = NULL) { RETURN $this->_getAddressBookEntry($ab_id, $customer_id); } public FUNCTION getAddressHash($ab_id) { $hash_fields = array( 'entry_gender', 'entry_company', 'entry_firstname', 'entry_lastname', 'entry_street_address', 'entry_suburb', 'entry_postcode', 'entry_city', 'entry_state', 'entry_country_id', 'entry_zone_id', ); $ab_entry = $this->_getAddressBookEntry($ab_id); $hash_input = ''; foreach($hash_fields AS $key) { $value = $ab_entry[$key]; $hash_input .= $value; } $hash = md5($hash_input); RETURN $hash; } public FUNCTION saveTransaction($orders_id, $status, $txid, $userid) { $sql_data_transactions_array = array( 'orders_id' => (INT)$orders_id, 'status' => $status, 'txid' => $txid, 'userid' => $userid, 'created' => 'now()', 'last_modified' => 'now()', ); IF (isset($_SESSION['payone_installment']['installment_type'])) { $sql_data_transactions_array['type'] = $_SESSION['payone_installment']['installment_type']; } ELSEIF (isset($_SESSION['payone_elv']['elv_type'])) { $sql_data_transactions_array['type'] = $_SESSION['payone_elv']['elv_type']; } ELSEIF (isset($_SESSION['payone_invoice']['invoice_type'])) { $sql_data_transactions_array['type'] = $_SESSION['payone_invoice']['invoice_type']; } xtc_db_perform('payone_transactions', $sql_data_transactions_array); $this->log("transaction saved: orders_id $orders_id, status $status, txid $txid, userid $userid"); } public FUNCTION getOrdersData($orders_id) { $data = array(); // TRANSACTION DATA $tx_query = xtc_db_query("SELECT * FROM `payone_transactions` WHERE `orders_id` = '".(INT)$orders_id."'"); $data['transactions'] = array(); while($tx_row = xtc_db_fetch_array($tx_query)) { $data['transactions'][] = $tx_row; } $data['transaction_status'] = $this->getTransactionStatus($orders_id); RETURN $data; } protected FUNCTION sendTransactionStatus($url, $params, $timeout) { IF ($timeout == '' || $timeout < 1) { $timeout = 30; } $urlArray = parse_url($url); $urlHost = $urlArray['host']; $urlPath = ((isset($urlArray['path'])) ? $urlArray['path'] : ''); $urlScheme = ((isset($urlArray['scheme'])) ? $urlArray['scheme'] : 'http'); $urlQuery = ((isset($urlArray['query'])) ? '?' . $urlArray['query'] : ''); $curl = curl_init($urlScheme . "://" . $urlHost . $urlPath . $urlQuery); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($params, NULL, '&')); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_TIMEOUT, (INT)$timeout); $result = curl_exec($curl); IF (curl_getinfo($curl, CURLINFO_HTTP_CODE) != 200) { $this->log("sendTransactionStatus invalid:\n".print_r($result, TRUE)); } ELSEIF (curl_error($curl)) { $this->log("sendTransactionStatus error ".curl_errno($curl) . ": " . curl_error($curl)); } ELSE { $this->log("sendTransactionStatus success:\n".print_r($result, TRUE)); } curl_close($curl); } public FUNCTION saveTransactionStatus($txstatus) { IF (empty($txstatus['reference'])) { $this->log("received TxStatus w/o reference!"); RETURN; } $config = $this->getConfig(); $key_valid = FALSE; IF (md5($config['global']['key']) == $txstatus['key']) { $key_valid = TRUE; } ELSE { $paymentgenre_identifiers = $this->getPaymentGenreIdentifiers(); foreach($paymentgenre_identifiers AS $pg_id) { IF (md5($config[$pg_id]['global']['key']) == $txstatus['key']) { $key_valid = TRUE; } } } IF ($key_valid == TRUE) { $sql_data_status_array = array('orders_id' => (INT)$txstatus['reference'], 'received' => 'now()'); xtc_db_perform('payone_txstatus', $sql_data_status_array); $txstatus_id = xtc_db_insert_id(); foreach($txstatus AS $key => $value) { $sql_data_statusdata_array = array('`payone_txstatus_id`' => $txstatus_id, '`key`' => $key, '`value`' => ((is_array($value)) ? implode('||', $value) : $value) ); xtc_db_perform('payone_txstatus_data', $sql_data_statusdata_array); } $sql_data_transactions_array = array('status' => strtoupper($txstatus['txaction']), 'last_modified' => 'now()'); xtc_db_perform('payone_transactions', $sql_data_transactions_array, 'update', "txid='".$txstatus['txid']."'"); IF (in_array($txstatus['txaction'], $this->getStatusNames())) { $sql_data_orders_array = array('orders_status' => (INT)$config['orders_status'][$txstatus['txaction']], 'last_modified' => 'now()'); xtc_db_perform(TABLE_ORDERS, $sql_data_orders_array, 'update', "orders_id='".(INT)$txstatus['reference']."'"); $sql_data_array = array('orders_id' => (INT)$txstatus['reference'], 'orders_status_id' => (INT)$config['orders_status'][$txstatus['txaction']], 'date_added' => 'now()', 'customer_notified' => '0', 'comments' => STATUS_UPDATED_BY_PAYONE, 'comments_sent' => '0' ); xtc_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array); // send TRANSACTION STATUS IF ($config['orders_status_redirect']['url'][$txstatus['txaction']] != '') { $this->sendTransactionStatus($config['orders_status_redirect']['url'][$txstatus['txaction']], $txstatus, $config['orders_status_redirect']['timeout'][$txstatus['txaction']]); } } } ELSE { $this->log("received TxStatus with an invalid key! TxStatus will not be processed."); } // logging $message_parts = array(); foreach($txstatus AS $name => $value) { $message_parts[] = "$name=$value"; } $message = implode('|', $message_parts); list($msec, $sec) = explode(' ', microtime()); $sql_data_array = array('event_id' => (INT)(($sec + $msec) * 1000), 'date_created' => 'now()', 'log_count' => '0', 'log_level' => '0', 'message' => $message, 'customers_id' => '0'); xtc_db_perform('payone_transactions_log', $sql_data_array); } public FUNCTION getTransactionStatus($orders_id) { // GET metadata FIRST $txstatus = array(); $txstatus_query = xtc_db_query("SELECT * FROM `payone_txstatus` WHERE orders_id = '".(INT)$orders_id."'"); while($txstatus_row = xtc_db_fetch_array($txstatus_query)) { $txstatus_row['data'] = array(); $txstatus[] = $txstatus_row; } // GET details foreach($txstatus AS $idx => $txs) { $txstatusdata_query = xtc_db_query("SELECT * FROM `payone_txstatus_data` WHERE payone_txstatus_id = '".(INT)$txs['payone_txstatus_id']."'"); while($txsd_row = xtc_db_fetch_array($txstatusdata_query)) { $txstatus[$idx]['data'][$txsd_row['key']] = $txsd_row['value']; } } RETURN $txstatus; } public FUNCTION getCaptureData($orders_id) { // a TRANSACTION can be captured IF it IS "appointed" $capture_data = FALSE; // i.e. cannot be captured $orders_data = $this->getOrdersData($orders_id); foreach($orders_data['transaction_status'] AS $tstatus) { IF (strtoupper($tstatus['data']['txaction']) == 'APPOINTED') { $capture_data = array( 'txid' => $tstatus['data']['txid'], 'price' => $tstatus['data']['price'], 'portalid' => $tstatus['data']['portalid'], 'aid' => $tstatus['data']['aid'], 'currency' => $tstatus['data']['currency'], 'sequencenumber' => $tstatus['data']['sequencenumber'], ); } } RETURN $capture_data; } protected FUNCTION _getNextSequencenumber($txid) { $query = "SELECT MAX(`d`.`value`) AS max_sequence FROM `payone_transactions` t LEFT JOIN `payone_txstatus` s ON s.orders_id = t.orders_id LEFT JOIN payone_txstatus_data d ON d.payone_txstatus_id = s.payone_txstatus_id AND d.key = 'sequencenumber' WHERE t.txid = '".(INT)$txid."'"; $result = xtc_db_query($query); $next_seqnum = 0; while($row = xtc_db_fetch_array($result)) { $next_seqnum = $row['max_sequence'] + 1; } RETURN $next_seqnum; } protected FUNCTION _getInvoicingTransaction($data) { global $order; $this->amount = 0; $this->ORDER = $order; $this->invtrans = NEW Payone_Api_Request_Parameter_Invoicing_Transaction(); $p = 0; $products = array(); FOR ($i = 0, $n = sizeof($this->order->products); $i < $n; $i ++) { foreach ($data['positions'] AS $position) { IF ($this->order->products[$i]['opid'] == $position['pid']) { $products[$p] = $this->order->products[$i]; IF ($this->order->products[$i]['qty'] >= $position['qty']) { $products[$p]['qty'] = $position['qty']; } $this->amount += $products[$p]['qty'] * $products[$p]['price']; $p ++; } } } $this->_getInvoicingTransaction_products($products); $p = 0; $totaldata = array('data' => array()); FOR ($i = 0, $n = sizeof($this->order->totals); $i < $n; $i ++) { foreach ($data['totals'] AS $total) { IF ($this->order->totals[$i]['class'] == $total['class']) { $totaldata['data'][$p] = array('TITLE' => $this->order->totals[$i]['title'], 'TEXT' => $this->order->totals[$i]['text'], 'VALUE' => $this->order->totals[$i]['value'], 'CLASS' => $this->order->totals[$i]['class'], ); $this->amount += $totaldata['data'][$p]['VALUE']; $p ++; } } } $this->_getInvoicingTransaction_totals($totaldata); RETURN $this->invtrans; } public FUNCTION _getInvoicingTransaction_products($products) { foreach($products AS $product) { $item = NEW Payone_Api_Request_Parameter_Invoicing_Item(); $item->setIt('goods'); $item->setId($product['id']); $item->setPr(round($product['price'], 2)); $item->setNo($product['qty']); $item->setDe($product['name']); $item->setVa(round($product['tax'], 2)); $this->invtrans->addItem($item); } } public FUNCTION _getInvoicingTransaction_totals($totaldata) { foreach($totaldata['data'] AS $td) { switch ($td['CLASS']) { CASE 'ot_shipping': $item = NEW Payone_Api_Request_Parameter_Invoicing_Item(); $item->setIt('shipment'); $item->setId('SHIPMENT'); $item->setPr(round($td['VALUE'], 2)); $item->setNo(1); $item->setDe(strip_tags($td['TITLE'])); $item->setVa($this->_get_order_total_tax('MODULE_SHIPPING_', $this->order->info['shipping_class'])); $this->invtrans->addItem($item); break; CASE 'ot_payment': $item = NEW Payone_Api_Request_Parameter_Invoicing_Item(); IF ($td['VALUE'] > 0) { $item->setIt('handling'); $item->setId('HANDLING'); } ELSE { $item->setIt('voucher'); $item->setId('VCHRDSCNT'); } $item->setPr(round($td['VALUE'], 2)); $item->setNo(1); $item->setDe(strip_tags($td['TITLE'])); $item->setVa(0); $this->invtrans->addItem($item); break; CASE 'ot_coupon': CASE 'ot_discount': CASE 'ot_gv': CASE 'ot_ps_fee': CASE 'ot_loworderfee': CASE 'ot_cod_fee': CASE 'ot_shippingfee': $item = NEW Payone_Api_Request_Parameter_Invoicing_Item(); IF ($td['VALUE'] > 0) { $item->setIt('handling'); $item->setId('HANDLING'); } ELSE { $item->setIt('voucher'); $item->setId('VCHRDSCNT'); } $item->setPr(round($td['VALUE'], 2)); $item->setNo(1); $item->setDe(strip_tags($td['TITLE'])); $item->setVa($this->_get_order_total_tax('MODULE_ORDER_TOTAL_', $td['CLASS'])); $this->invtrans->addItem($item); break; } } } protected FUNCTION _get_order_total_tax($path, $type) { require_once (DIR_FS_INC.'xtc_get_tax_rate.inc.php'); IF (!isset($this->order->customer['zone_id'])) { $customers_info = $this->_get_customers_infos($this->order->customer['id'], $this->order->delivery['country_iso_2']); } ELSE { $customers_info = array('country_id' => $this->order->customer['country']['id'], 'zone_id' => $this->order->customer['zone_id']); } $class = explode('_', $type); IF (defined(strtoupper($path.$class[0].'_TAX_CLASS'))) { RETURN xtc_get_tax_rate(constant(strtoupper('MODULE_SHIPPING_'.$class[0].'_TAX_CLASS')), $customers_info['country_id'], $customers_info['zone_id']); } ELSE { RETURN '0'; } } protected FUNCTION _get_customers_infos($customers_id, $delivery_country_iso_code_2) { $countries_query = xtc_db_query("select c.countries_id from " . TABLE_COUNTRIES . " c where c.countries_iso_code_2 = '" . $delivery_country_iso_code_2 . "' "); $countries = xtc_db_fetch_array($countries_query); $zone_id = ''; IF ($countries['countries_id'] > 0) { $zones_query = xtc_db_query("select z.zone_id from " . TABLE_ORDERS . " o, " . TABLE_ZONES . " z where o.customers_id = '" . $customers_id . "' and z.zone_country_id = '" . $countries['countries_id'] . "' and z.zone_name = o.delivery_state "); $zones = xtc_db_fetch_array($zones_query); $zone_id = $zones['zone_id']; } $customers_info_array = array('country_id' => $countries['countries_id'], 'zone_id' => $zone_id ); RETURN $customers_info_array; } public FUNCTION captureAmount($data) { $this->log("capturing ".print_r($data, TRUE)); $config = $this->getConfig(); $global_config = $config['global']; $standard_parameters = $this->getStandardParameters('capture', $global_config); unset($standard_parameters['responsetype']); unset($standard_parameters['successurl']); unset($standard_parameters['errorurl']); unset($standard_parameters['hash']); $request_parameters = array( 'aid' => $global_config['subaccount_id'], 'key' => $global_config['key'], ); $params = array_merge($standard_parameters, $request_parameters); $builder = NEW Payone_Builder($this->getPayoneConfig()); $service = $builder->buildServicePaymentCapture(); $request = NEW Payone_Api_Request_Capture($params); $request->setTxid($data['txid']); $request->setPortalid($data['portalid']); $request->setSequencenumber($this->_getNextSequencenumber($data['txid'])); $request->setCurrency($data['currency']); IF (isset($data['positions'])) { $request->setInvoicing($this->_getInvoicingTransaction($data)); $request->setAmount(round($this->amount, 2)); } ELSE { $request->setAmount(round($data['amount'], 2)); } $response = $service->capture($request); IF ($response instanceof Payone_Api_Response_Capture_Approved) { $this->log("SUCCESS capture response:\n".print_r($response, TRUE)); } ELSE IF ($response instanceof Payone_Api_Response_Error) { $this->log("ERROR capture response:\n".print_r($response, TRUE)); } RETURN $response; } public FUNCTION refundAmount($data) { $this->log("refunding amount\n".print_r($data, TRUE)); $config = $this->getConfig(); $global_config = $config['global']; $standard_parameters = $this->getStandardParameters('debit', $global_config); unset($standard_parameters['responsetype']); unset($standard_parameters['successurl']); unset($standard_parameters['errorurl']); unset($standard_parameters['hash']); $request_parameters = array( 'aid' => $global_config['subaccount_id'], 'key' => $global_config['key'], ); $params = array_merge($standard_parameters, $request_parameters); $builder = NEW Payone_Builder($this->getPayoneConfig()); $service = $builder->buildServicePaymentDebit(); $request = NEW Payone_Api_Request_Debit($params); $request->setCurrency($data['currency']); $request->setSequencenumber($this->_getNextSequencenumber($data['txid'])); $request->setTxid($data['txid']); IF (isset($data['positions'])) { $request->setInvoicing($this->_getInvoicingTransaction($data)); $request->setAmount((round($this->amount, 2) * (-1))); } ELSE { $request->setAmount((round($data['amount'], 2) * (-1))); } IF (FALSE && !empty($data['bankaccount'])) { $payment = NEW Payone_Api_Request_Parameter_Refund_PaymentMethod_BankAccount(); $payment->setBankaccount($data['bankaccount']); $payment->setBankbranchcode($data['bankbranchcode']); $payment->setBankcheckdigit($data['bankcheckdigit']); $payment->setBankcode($data['bankcode']); $payment->setBankcountry($data['bankcountry']); $request->setPayment($payment); } $response = $service->debit($request); IF ($response instanceof Payone_Api_Response_Debit_Approved) { $this->log("SUCCESS refunding response:\n".print_r($response, TRUE)); } ELSE IF ($response instanceof Payone_Api_Response_Error) { $this->log("ERROR refunding response:\n".print_r($response, TRUE)); } RETURN $response; } public FUNCTION getBillToCountry() { IF (!(isset($_SESSION['billto']) && is_numeric($_SESSION['billto']))) { RETURN ''; } $ab_id = $_SESSION['billto']; $customer_id = $_SESSION['customer_id']; $query = "SELECT ab.*, c.* FROM ".TABLE_ADDRESS_BOOK." ab left join ".TABLE_COUNTRIES." c on c.countries_id = ab.entry_country_id WHERE ab.address_book_id = '".(INT)$ab_id."' AND ab.customers_id = '".(INT)$customer_id."'"; $result = xtc_db_query($query); $country = ''; while($row = xtc_db_fetch_array($result)) { $country = $row['countries_iso_code_2']; } RETURN $country; } public FUNCTION getClearingData($orders_id) { $result = xtc_db_query("SELECT * FROM `payone_clearingdata` WHERE `orders_id` = '".(INT)$orders_id."'"); $cd = FALSE; while($row = xtc_db_fetch_array($result)) { $cd = $row; } RETURN $cd; } public FUNCTION addressCheck($ab_id, $checktype = 'BA') { $global_config = $this->getConfig('global'); $config = $this->getConfig('address_check'); $cdata = $this->_getAddressBookEntry($ab_id); IF ($cdata === FALSE) { throw NEW Exception('invalid address book entry'); } $standard_parameters = $this->getStandardParameters(); $builder = NEW Payone_Builder($this->getPayoneConfig()); $service = $builder->buildServiceVerificationAddressCheck(); $requestData = array( 'key' => $global_config['key'], 'addresschecktype' => $checktype, // BA|PE|NO (basic | person | no) ); $addressData = array( 'firstname' => $cdata['entry_firstname'], 'lastname' => $cdata['entry_lastname'], 'company' => $cdata['entry_company'], 'street' => $cdata['entry_street_address'], 'zip' => $cdata['entry_postcode'], 'city' => $cdata['entry_city'], 'country' => $cdata['countries_iso_code_2'], 'birthday' => DATE('Ymd', strtotime($cdate['dob_date'])), 'telephonenumber' => $cdata['customers_telephone'], ); $address_hash = md5(implode('', $addressData)); $response = $this->_retrieveCachedAddressCheckResponse($address_hash); IF ($response == FALSE) { $this->log("addressCheck cache miss"); $requestData = array_merge($standard_parameters, $requestData, $addressData); $request = NEW Payone_Api_Request_AddressCheck($requestData); $this->log("addressCheck hash: ".$address_hash."\n"); $this->log("addressCheck request:\n".print_r($request, TRUE)); $response = $service->CHECK($request); $this->log("addressCheck response:\n".print_r($response, TRUE)); } ELSE { $this->log("addressCheck cache hit"); } IF ($response instanceof Payone_Api_Response_AddressCheck_Valid || $response instanceof Payone_Api_Response_AddressCheck_Invalid) { $this->_storeAddressCheckResponse($response, $ab_id, $address_hash); } RETURN $response; } protected FUNCTION _retrieveCachedAddressCheckResponse($address_hash) { $config = $this->getConfig('address_check'); $cache_days = $config['validity']; $query = "SELECT * FROM `payone_ac_cache` WHERE address_hash = '".xtc_db_input($address_hash)."' AND received >= DATE_SUB(NOW(), INTERVAL ".(INT)$cache_days." DAY)"; $cached_response = FALSE; $result = xtc_db_query($query); while($row = xtc_db_fetch_array($result)) { IF (empty($row['errorcode'])) { $cached_response = NEW Payone_Api_Response_AddressCheck_Valid($row); } ELSE { $cached_response = NEW Payone_Api_Response_AddressCheck_Invalid($row); } } RETURN $cached_response; } protected FUNCTION _storeAddressCheckResponse($response, $ab_id, $address_hash) { IF ($response instanceof Payone_Api_Response_AddressCheck_Valid) { $sql_data_array = array( 'address_hash' => $address_hash, 'address_book_id' => (INT)$ab_id, 'secstatus' => (INT)$response->getSecstatus(), 'status' => $response->getStatus(), 'personstatus' => $response->getPersonstatus(), 'street' => $response->getStreet(), 'streetname' => $response->getStreetname(), 'streetnumber' => $response->getStreetnumber(), 'zip' => $response->getZip(), 'city' => $response->getCity(), ); } ELSE IF ($response instanceof Payone_Api_Response_AddressCheck_Invalid) { $sql_data_array = array( 'address_hash' => $address_hash, 'address_book_id' => (INT)$ab_id, 'secstatus' => (INT)$response->getSecstatus(), 'status' => $response->getStatus(), 'errorcode' => $response->getErrorcode(), 'errormessage' => $response->getErrormessage(), 'customermessage' => $response->getCustomerMessage(), ); } xtc_db_query("DELETE FROM `payone_ac_cache` WHERE address_hash = '".xtc_db_input($address_hash)."'"); xtc_db_perform('payone_ac_cache', $sql_data_array); } public FUNCTION scoreCustomer($ab_id) { $global_config = $this->getConfig('global'); $config = $this->getConfig('credit_risk'); $cdata = $this->_getAddressBookEntry($ab_id); IF ($cdata === FALSE) { throw NEW Exception('invalid address book entry'); } switch($config['typeofcheck']) { CASE 'iscorehard': $scoretype = 'IH'; break; CASE 'iscoreall': $scoretype = 'IA'; break; CASE 'iscorebscore'; $scoretype = 'IB'; break; DEFAULT: $scoretype = 'IH'; } $standard_parameters = $this->getStandardParameters(); $builder = NEW Payone_Builder($this->getPayoneConfig()); $service = $builder->buildServiceVerificationConsumerscore(); $requestData = array( 'key' => $global_config['key'], 'addresschecktype' => 'NO', // BA|PE|NO (basic | person | no) 'consumerscoretype' => $scoretype, // IH|IA|IB (hart | alle | alle+boni) ); $addressData = array( 'firstname' => $cdata['entry_firstname'], 'lastname' => $cdata['entry_lastname'], 'company' => $cdata['entry_company'], 'street' => $cdata['entry_street_address'], 'zip' => $cdata['entry_postcode'], 'city' => $cdata['entry_city'], 'country' => $cdata['countries_iso_code_2'], 'birthday' => DATE('Ymd', strtotime($cdate['dob_date'])), 'telephonenumber' => $cdata['customers_telephone'], ); $address_hash = md5(implode('', $addressData)); $response = $this->_retrieveCachedCreditRiskResponse($address_hash, $scoretype); IF ($response == FALSE) { $this->log("creditRisk cache miss"); $requestData = array_merge($standard_parameters, $requestData, $addressData); $request = NEW Payone_Api_Request_Consumerscore($requestData); $this->log("scoreCustomer request:\n".print_r($request, TRUE)); $response = $service->score($request); $this->log("scoreCustomer response:\n".print_r($response, TRUE)); } ELSE { $this->log("creditRisk cache hit"); } IF ($response instanceof Payone_Api_Response_Consumerscore_Valid || $response instanceof Payone_Api_Response_Consumerscore_Invalid) { $this->_storeCreditRiskResponse($response, $ab_id, $address_hash, $scoretype); RETURN $response; } ELSE { RETURN FALSE; } } protected FUNCTION _retrieveCachedCreditRiskResponse($address_hash, $scoretype) { $config = $this->getConfig('credit_risk'); $cache_days = $config['validity']; $query = "SELECT * FROM `payone_cr_cache` WHERE address_hash = '".xtc_db_input($address_hash)."' AND `scoretype` = '".xtc_db_input($scoretype)."' AND `received` >= DATE_SUB(NOW(), INTERVAL ".(INT)$cache_days." DAY)"; $cached_response = FALSE; $result = xtc_db_query($query); while($row = xtc_db_fetch_array($result)) { IF (empty($row['errorcode'])) { $cached_response = NEW Payone_Api_Response_Consumerscore_Valid($row); } ELSE { $cached_response = NEW Payone_Api_Response_Consumerscore_Invalid($row); } } RETURN $cached_response; } protected FUNCTION _storeCreditRiskResponse($response, $ab_id, $address_hash, $scoretype) { IF ($response instanceof Payone_Api_Response_Consumerscore_Valid) { $sql_data_array = array( 'address_hash' => $address_hash, 'address_book_id' => (INT)$ab_id, 'scoretype' => $scoretype, 'secstatus' => (INT)$response->getSecstatus(), 'status' => $response->getStatus(), 'score' => $response->getScore(), 'scorevalue' => $response->getScorevalue(), 'secscore' => $response->getSecscore(), 'personstatus' => $response->getPersonstatus(), 'firstname' => $response->getFirstname(), 'lastname' => $response->getLastname(), 'street' => $response->getStreet(), 'streetname' => $response->getStreetname(), 'streetnumber' => $response->getStreetnumber(), 'zip' => $response->getZip(), 'city' => $response->getCity(), ); } ELSE IF ($response instanceof Payone_Api_Response_Consumerscore_Invalid) { $sql_data_array = array( 'address_hash' => $address_hash, 'address_book_id' => (INT)$ab_id, 'scoretype' => $scoretype, 'secstatus' => (INT)$response->getSecstatus(), 'status' => $response->getStatus(), 'errorcode' => $response->getErrorcode(), 'errormessage' => $response->getErrormessage(), 'customermessage' => $response->getCustomerMessage(), ); } xtc_db_query("DELETE FROM `payone_cr_cache` WHERE address_hash = '".xtc_db_input($address_hash)."'"); xtc_db_perform('payone_cr_cache', $sql_data_array); } public FUNCTION getLogsCount($mode, $date_start = NULL, $date_end = NULL, $search = NULL) { $table = (($mode == 'api') ? 'payone_api_log' : 'payone_transactions_log'); $query = "SELECT COUNT(*) AS logs_count FROM ".$table." l LEFT JOIN ".TABLE_ORDERS." o ON o.customers_id = l.customers_id"; IF ($date_start !== NULL && $date_end !== NULL) { $query .= " WHERE l.date_created BETWEEN '".date('Y-m-d 00:00:00', ($date_start))."' AND '".date('Y-m-d 23:59:59', ($date_end))."'"; } IF ($search != NULL) { IF (stripos($query, 'WHERE') === FALSE) { $query .= " WHERE "; } ELSE { $query .= " AND "; } $query .= " (l.event_id LIKE '%".xtc_db_input($search)."%' OR o.customers_name LIKE '%".xtc_db_input($search)."%')"; } $query .= " GROUP BY event_id"; $result = xtc_db_query($query); $count = 0; while ($row = xtc_db_fetch_array($result)) { $count += 1; } RETURN $count; } public FUNCTION getLogs($mode, $limit, $offset, $date_start = NULL, $date_end = NULL, $search = NULL) { $table = (($mode == 'api') ? 'payone_api_log' : 'payone_transactions_log'); $query = "SELECT l.event_id, l.date_created, l.customers_id, o.customers_name FROM ".$table." l LEFT JOIN ".TABLE_ORDERS." o ON o.customers_id = l.customers_id "; IF ($date_start !== NULL && $date_end !== NULL) { $query .= "WHERE l.date_created BETWEEN '".date('Y-m-d 00:00:00', ($date_start))."' AND '".date('Y-m-d 23:59:59', ($date_end))."' "; } IF ($search != NULL) { IF (stripos($query, 'WHERE') === FALSE) { $query .= " WHERE "; } ELSE { $query .= " AND "; } $query .= " (l.event_id LIKE '%".xtc_db_input($search)."%' OR o.customers_name LIKE '%".xtc_db_input($search)."%')"; } $query .= "GROUP BY l.event_id ORDER BY l.date_created ASC LIMIT ".$limit." OFFSET ".$offset; $result = xtc_db_query($query); $logs = array(); while($row = xtc_db_fetch_array($result)) { $logs[] = $row; } RETURN $logs; } public FUNCTION getLogData($mode, $event_id) { $table = (($mode == 'api') ? 'payone_api_log' : 'payone_transactions_log'); $query = xtc_db_query("SELECT * FROM ".$table." WHERE event_id = ".(INT)$event_id." ORDER BY log_count"); $data = array(); while($row = xtc_db_fetch_array($query)) { $row['message'] = $this->_splitLogMessage($row['message']); $data[] = $row; } RETURN $data; } protected FUNCTION _splitLogMessage($message) { $parts = explode('|', $message); $message = array(); foreach($parts AS $part) { list($name, $value) = explode('=', $part); $message[$name] = $value; } RETURN $message; } public FUNCTION build_html($template, $content) { $module_smarty = NEW Smarty(); $module_smarty->template_dir = DIR_FS_EXTERNAL.'payone/templates/'; $module_smarty->assign('language', $_SESSION['language']); $module_smarty->assign('content_data', $content); $module_smarty->caching = 0; $module = $module_smarty->fetch($template); RETURN $module; } } ?> Fatal error: Class 'PayoneModified' NOT found IN /WWWROOT/251369/htdocs/includes/external/payone/classes/PayonePayment.php ON line 36