Array('Name' => 'Atos Origin', 'ClassName' => 'kAtosOriginGW', 'ClassFile' => 'atosorigin.php', 'RequireCCFields' => 0), 'ConfigFields' => Array( 'request_binary' => Array('Name' => 'API Request Executable', 'Type' => 'text', 'ValueList' => '', 'Default' => ''), 'response_binary' => Array('Name' => 'API Response Executable', 'Type' => 'text', 'ValueList' => '', 'Default' => ''), 'pathfile' => Array('Name' => 'Pathfile', 'Type' => 'text', 'ValueList' => '', 'Default' => ''), 'merchant_id' => Array('Name' => 'Merchant ID', 'Type' => 'text', 'ValueList' => '', 'Default' => ''), 'merchant_country' => Array('Name' => 'Merchant Country Code', 'Type' => 'text', 'ValueList' => '', 'Default' => ''), 'currency_code' => Array('Name' => 'Currency Code', 'Type' => 'text', 'ValueList' => '', 'Default' => '978'), 'shipping_control' => Array('Name' => 'Shipping Control', 'Type' => 'select', 'ValueList' => '3=la_CreditDirect,4=la_CreditPreAuthorize', 'Default' => '3'), ) ); return $data; } /** * Returns payment form submit url * * @param Array $gw_params gateway params from payment type config * @return string */ function getFormAction($gw_params) { return $gw_params['submit_url']; } /** * 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) { $params['pathfile'] = $gw_params['pathfile']; $params['merchant_id'] = $gw_params['merchant_id']; $params['merchant_country'] = $gw_params['merchant_country']; $params['currency_code'] = $gw_params['currency_code']; $params['currency_code'] = $gw_params['currency_code']; $params['normal_return_url'] = $this->Application->HREF($tag_params['return_template'],'',Array('pass'=>'m')); $params['cancel_return_url'] = $this->Application->HREF($tag_params['cancel_template'],'',Array('pass'=>'m')); $params['automatic_response_url'] = $this->getNotificationUrl('units/gateways/gw_classes/notify_scripts/atosorigin_notify.php'); $txt_amount = sprintf("%.2f", $item_data['TotalAmount']); $params['amount'] = str_replace( Array('.', ','), '', $txt_amount); $params['caddie'] = $this->Application->GetSID() . ',' . MD5($item_data['OrderId']); $params['order_id'] = $item_data['OrderId']; $params['customer_ip_address'] = $_SERVER['REMOTE_ADDR']; $params['customer_id'] = $item_data['PortalUserId']; $billing_email = $item_data['BillingEmail']; if (!$billing_email) { $billing_email = $this->Conn->GetOne(' SELECT Email FROM '.$this->Application->getUnitOption('u', 'TableName').' WHERE PortalUserId = '.$this->Application->RecallVar('user_id')); } $params['customer_email'] = $billing_email; $params_str = ''; foreach ($params as $key => $val) { $params_str .= ' '.$key . '="'.$val.'"'; } $run_line = $gw_params['request_binary'].' '.$params_str; // $run_line = escapeshellcmd($run_line); // echo $run_line; exec ($run_line, $rets); $ret = $rets[0]; $ret = preg_replace('/^(.*)!!/is', '', $ret); $ret = rtrim($ret, '!'); return ''.$ret.'
'; } function NeedPlaceButton($item_data, $tag_params, $gw_params) { return false; } function processNotification($gw_params) { $params['pathfile'] = $gw_params['pathfile']; $params['message'] = $_POST['DATA']; $params_str = ''; foreach ($params as $key => $val) { $params_str .= ' '.$key . '="'.$val.'"'; } $run_line = $gw_params['response_binary'].' '.$params_str; exec ($run_line, $rets); $ret = $rets[0]; $result = $this->parseGWResponce($ret, $gw_params); list ($sid, $auth_code) = explode(',', $result['caddie']); $session = $this->Application->recallObject('Session'); $session->SID = $sid; $order_id = $this->Conn->GetOne('SELECT OrderId FROM '.TABLE_PREFIX.'Orders WHERE md5(OrderId) = '.$this->Conn->qstr($auth_code)); $this->Application->SetVar('ord_id', $order_id); $order = $this->Application->recallObject('ord'); $order->Load($order_id); return $result['response_code'] === '00' ? 1 : 0; } function parseGWResponce($str, $gw_params) { $response = explode ("!", $str); $result = Array ( 'code' => $response[1], 'error' => $response[2], 'merchant_id' => $response[3], 'merchant_country' => $response[4], 'amount' => $response[5], 'transaction_id' => $response[6], 'payment_means' => $response[7], 'transmission_date' => $response[8], 'payment_time' => $response[9], 'payment_date' => $response[10], 'response_code' => $response[11], 'payment_certificate' => $response[12], 'authorisation_id' => $response[13], 'currency_code' => $response[14], 'card_number' => $response[15], 'cvv_flag' => $response[16], 'cvv_response_code' => $response[17], 'bank_response_code' => $response[18], 'complementary_code' => $response[19], 'complementary_info' => $response[20], 'return_context' => $response[21], 'caddie' => $response[22], 'receipt_complement' => $response[23], 'merchant_language' => $response[24], 'language' => $response[25], 'customer_id' => $response[26], 'order_id' => $response[27], 'customer_email' => $response[28], 'customer_ip_address' => $response[29], 'capture_day' => $response[30], 'capture_mode' => $response[31], 'data' => $response[32], ); $this->parsed_responce = $result; return $result; } function getGWResponce() { return serialize($this->parsed_responce); } function getErrorMsg() { $msg = $this->parsed_responce['error']; if (!$msg) { if ($this->parsed_responce['response_code'] != '00') { $msg = 'Transaction failed'; } } return $msg; } }