//APPLY UTF-8 ENCODING TO ALL REQUEST (STRING VALUE)
 foreach ($request as $key => $value) {
     if (is_string($value)) {
         $request[$key] = utf8_encode($value);
     } elseif (is_array($value)) {
         foreach ($value as $val_key => $val_value) {
             if (is_string($val_value)) {
                 $request[$key][$val_key] = utf8_encode($val_value);
             }
         }
     }
 }
 //PROCESS REQUEST
 $class_plog = new payone_logger();
 $process_time = date('Y-m-d H-i:s');
 $fconnect = new financegateConnect();
 $fconnect->setApiUrl(PAYONE_API_URL);
 $response = $fconnect->processByArray($request);
 $result = $order_id;
 if (!is_array($response)) {
     $result .= ',0';
     //$result = "<b>Error in Connection</b>";
 } else {
     if ($response['status'] == 'APPROVED') {
         $result .= ',1';
         $payi->markSubmitted($response);
         if ($response['userid'] != '') {
             tep_db_query("UPDATE jng_sp_customers SET payone_userid = " . tep_db_prepare_input($response['userid']));
         }
     } else {
         $result .= ',0';
Beispiel #2
0
 function payoneCustomerConsumerScore($order_id, $is_sp = true)
 {
     use_class('jng_sp_orders');
     use_class('jng_sp_customers');
     $class_orders = new jng_sp_orders();
     $class_cust = new jng_sp_customers();
     $process_method = PAYONE_REQUEST_CONSUMERSCORE;
     $result = null;
     if ($is_sp) {
         $q = "SELECT c.`customer_firstname` firstname,c.`customer_lastname` lastname\n                    , o.`customer_billing_address` street, o.`customer_billing_postcode` zip, o.`customer_billing_city` city, o.`customer_billing_country` country, o.`customer_billing_phone` telephonenumber\n                    FROM jng_sp_orders o\n                    INNER JOIN jng_sp_customers c ON c.`customer_id` = o.`customer_billing_id`\n                    WHERE o.`jng_sp_orders_id` = {$order_id}";
     } else {
         $q = $q = "SELECT o.`delivery_name`, o.`delivery_company` company, o.`delivery_street_address` street, o.`delivery_postcode` zip, o.`delivery_city` city, o.`delivery_country` country\n                    , c.`customers_telephone` telephonenumber\n                    FROM orders o\n                    INNER JOIN customers c ON c.`customers_id` = o.`customers_id`\n                    WHERE o.`orders_id` =  {$order_id}";
     }
     $dbq = tep_db_query($q);
     $r = array();
     $r = tep_db_fetch_array($dbq);
     if (count($r) > 1) {
         $request = array();
         //--STANDARD PARAMETERS
         $request['mid'] = PAYONE_MERCHANT_ID;
         $request['portalid'] = PAYONE_PORTAL_ID;
         $request['key'] = md5(PAYONE_PORTAL_KEY);
         $request['mode'] = PAYONE_MODE;
         $request['request'] = $process_method;
         $request['encoding'] = 'UTF-8';
         $request['aid'] = $is_sp ? PAYONE_SUBACCOUNT_ID_OTTODE : PAYONE_SUBACCOUNT_ID_JNG;
         //PREPARE PARAMETERS
         $request['addresschecktype'] = 'BA';
         //BA : Addresscheck Basic; PE : Addresscheck Person (cannot used, must have another settings)
         $request['consumerscoretype'] = 'IB';
         //IH : Infoscore (hard criteria); IA : Infoscore (all criteria); IB : Infoscore (all criteria + boni score)
         if ($is_sp) {
             $request['firstname'] = $r['firstname'];
             $request['lastname'] = $r['lastname'];
         } else {
             list($request['firstname']) = split(" ", $r['billing_name']);
             $request['lastname'] = trim(substr($r['billing_name'], strlen($request['firstname']), strlen($r['billing_name']) - strlen($request['firstname'])));
         }
         if ($r['company'] != '') {
             $request['company'] = $r['company'];
         }
         $request['street'] = $r['street'];
         $request['zip'] = $r['zip'];
         $request['city'] = $r['city'];
         $request['country'] = getISO3166CountryCode($r['country']);
         if ($r['telephonenumber'] != '') {
             $request['telephonenumber'] = $r['telephonenumber'];
         }
         //                echo "<pre>";return var_dump($request);die();
         use_class('payone_logger');
         use_class('payone/financegateConnect');
         $class_plog = new payone_logger();
         $fconnect = new financegateConnect();
         $process_time = date('Y-m-d H:i:s');
         $fconnect->setApiUrl(PAYONE_API_URL);
         $response = $fconnect->processByArray($request);
         $class_plog->add('S', $process_time, $process_method, $request, $response);
         $result = $returns['txid'];
         if (is_array($response)) {
             //                    $result = $response['status'];
             $result = $response;
         }
     }
     return $result;
 }
tep_db_connect();
use_class('payone/financegateConnect');
use_class('payone_logger');
$class_plog = new payone_logger();
if (isset($_GET['id'])) {
    $success_ids = array();
    $fail_ids = array();
    $bad_ids = array();
    $log_ids = explode(',', $_GET['id']);
    foreach ($log_ids as $log_id) {
        $id = tep_db_prepare_input($log_id);
        $log = $class_plog->retrieveDetailData($id);
        if ($log['log_process'] == 'R') {
            $request = unserialize($log['log_process_data_submit']);
            $request['mid'] = PAYONE_MERCHANT_ID;
            $fconnect = new financegateConnect();
            $fconnect->setApiUrl('http://www.manobo.de/gateway/payone_status_updates.php');
            $response = $fconnect->processByArray($request);
            if ($response[0] == 'TSOK') {
                $success_ids[] = $id;
            } else {
                $fail_ids[] = $id;
            }
        } else {
            $bad_ids[] = $id;
        }
    }
}
$total_success = count($success_ids);
$total_fail = count($fail_ids);
$total_bad = count($bad_ids);
 /**
  * Check credit worthiness using Payone API
  * @global payone_logger $class_plog
  * @return boolean
  */
 public function checkCreditWorthiness()
 {
     global $class_plog;
     if (count($address_country) == 2) {
         $country_code = strtoupper($this->order_country);
     } else {
         $country_code = getISO3166CountryCode($this->order_country);
     }
     $process_method = PAYONE_REQUEST_CONSUMERSCORE;
     $request = array();
     //--STANDARD PARAMETERS
     $request['mid'] = PAYONE_MERCHANT_ID;
     $request['portalid'] = PAYONE_PORTAL_ID;
     $request['key'] = md5(PAYONE_PORTAL_KEY);
     $request['mode'] = PAYONE_MODE;
     $request['request'] = $process_method;
     $request['encoding'] = 'UTF-8';
     $request['aid'] = $this->order_type == Order::ORDER_TYPE_SALES_PARTNER ? PAYONE_SUBACCOUNT_ID_OTTODE : PAYONE_SUBACCOUNT_ID_JNG;
     //PREPARE PARAMETERS
     $request['addresschecktype'] = 'BA';
     $request['consumerscoretype'] = 'IB';
     $request['firstname'] = $this->order_firstname;
     $request['lastname'] = $this->order_lastname;
     $request['street'] = $this->order_address;
     $request['zip'] = $this->order_zipcode;
     $request['city'] = $this->order_city;
     $request['country'] = $country_code;
     $fconnect = new financegateConnect();
     $process_time = date('Y-m-d H:i:s');
     $fconnect->setApiUrl(PAYONE_API_URL);
     $response = $fconnect->processByArray($request);
     unset($fconnect);
     $class_plog->add('S', $process_time, $process_method, $request, $response);
     //$response = array('score' => 'G');
     if (is_array($response)) {
         switch ($response['score']) {
             case 'G':
                 $score = FraudRiskChecker::ORDER_SCORE_GREEN;
                 $source = null;
                 break;
             case 'Y':
                 $score = FraudRiskChecker::ORDER_SCORE_YELLOW;
                 $source = FraudRiskChecker::SOURCE_CREDITCHECK_YELLOW;
                 break;
             case 'R':
                 $score = FraudRiskChecker::ORDER_SCORE_RED;
                 $source = FraudRiskChecker::SOURCE_CREDITCHECK_RED;
                 break;
         }
         if (!is_null($source)) {
             FraudRiskChecker::addNewCustomer($this->order_type, $this->customer_id, $source);
         }
         $this->check_score = $score;
     } else {
         $score = false;
     }
     return $score;
 }