function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if (!function_exists('curl_init')) { $this->app->enqueueMessage('The eSelect payment plugin needs the CURL library installed but it seems that it is not available on your server. Please contact your web hosting to set it up.', 'error'); $do = false; return false; } $this->ccLoad(); ob_start(); $dbg = ''; $amount = number_format($order->cart->full_total->prices[0]->price_value_with_tax, 2, '.', ''); require_once dirname(__FILE__) . DS . 'eselect_lib.php'; $txnArray = array('type' => 'purchase', 'order_id' => uniqid(), 'cust_id' => $this->user->user_id, 'amount' => $amount, 'pan' => $this->cc_number, 'expdate' => $this->cc_month . $this->cc_year, 'crypt_type' => '7', 'dynamic_descriptor' => ''); $mpgTxn = new mpgTransaction($txnArray); if ($this->payment_params->ask_ccv) { $cvdTemplate = array('cvd_indicator' => 1, 'cvd_value' => $this->cc_CCV); $mpgCvdInfo = new mpgCvdInfo($cvdTemplate); $mpgTxn->setCvdInfo($mpgCvdInfo); } $mpgRequest = new mpgRequest($mpgTxn); $mpgHttpPost = new mpgHttpsPost($this->payment_params->store_id, $this->payment_params->api_token, $mpgRequest, (int) $this->payment_params->debug != 0); $mpgResponse = $mpgHttpPost->getMpgResponse(); $ret = $mpgResponse->getResponseCode(); if ($ret !== null && $ret != 'null') { $ret = (int) $ret; if ($ret < 50 && $mpgResponse->getComplete() == 'true') { ob_get_clean(); ob_start(); $this->modifyOrder($order, $this->payment_params->verified_status, true, true); } else { $responseMsg = $mpgResponse->getMessage(); if (!empty($responseMsg)) { $this->app->enqueueMessage($responseMsg); } else { $this->app->enqueueMessage('Eselect/Moneris Response Error'); } $do = false; } } else { if (!empty($mpgHttpPost->curl_err)) { $this->app->enqueueMessage($mpgHttpPost->curl_err_msg); } else { $msg = $mpgResponse->getMessage(); if (empty($msg)) { $this->app->enqueueMessage('Eselect/Moneris Generic Error'); } else { $this->app->enqueueMessage('Eselect/Moneris: ' . $msg); } } $do = false; } if ($do == false) { return true; } $this->ccClear(); return true; }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if (empty($this->payment_params->twpg_id)) { $this->app->enqueueMessage('Модуль оплаты не настроен'); $do = false; } }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if (empty($this->payment_params->tpe) || empty($this->payment_params->societe) || empty($this->payment_params->key)) { $this->app->enqueueMessage('Please check your "CM-CIC" plugin configuration'); $do = false; } }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if (empty($this->payment_params->secret_Key) || empty($this->payment_params->merchant_Key)) { $this->app->enqueueMessage('Please check your "Amazon" plugin configuration'); $do = false; } }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if ((empty($this->payment_params->email) || empty($this->payment_params->url)) && $this->plugin_data->payment_id == $order->order_payment_id) { $this->app->enqueueMessage('Please check your "PayPal" plugin configuration'); $do = false; } }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if (empty($this->payment_params->secret_key) || empty($this->payment_params->application_id)) { $this->app->enqueueMessage('Missing merchant identifier! Please check your "Netgiro" plugin configuration.'); $do = false; } }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if ($order->order_payment_method == 'purchaseorder') { $history = new stdClass(); $history->type = 'purchase order'; $history->notified = 0; $history->data = JText::_('PURCHASE_ORDER_NUMBER') . @$_SESSION['hikashop_purchase_order_number']; $this->modifyOrder($order, $this->payment_params->order_status, $history, false); } }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if (!function_exists('curl_init')) { $this->app->enqueueMessage('The Payment Express payment plugin needs the CURL library installed but it seems that it is not available on your server. Please contact your web hosting to set it up.', 'error'); return false; } if (empty($this->payment_params->terminal_id) || empty($this->payment_params->secret_key)) { $this->app->enqueueMessage('Please check your "WorldNet" plugin configuration : the Terminal ID and the secret key need to be configured.'); $do = false; } }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if ($this->payment_params->debug) { if (empty($this->payment_params->key)) { $this->app->enqueueMessage('Please fill out the field API Key on your plugin configuration'); $do = false; } if (empty($this->payment_params->salt)) { $this->app->enqueueMessage('Please fill out the field Hash salt on your plugin configuration'); $do = false; } } }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if (empty($this->payment_params->merchantid) || empty($this->payment_params->type) || empty($this->payment_params->secret)) { $this->app->enqueueMessage('Please check your Cardstream plugin configuration', 'error'); $do = false; } /* if (!function_exists('curl_init')) { $this->app->enqueueMessage('The Cardstream direct integration requires the CURL library installed but it seems that it is not available on your server. Please contact your web hosting to set it up.', 'error'); return false; } */ if ($this->payment_params->type != 'direct') { return true; } }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } $this->ccLoad(); if ($order->order_payment_method == 'creditcard') { $order->credit_card_info = $this; $obj = new stdClass(); $obj->cc_number = substr($this->cc_number, 0, 8); $obj->cc_month = $this->cc_month; $obj->cc_year = $this->cc_year; $obj->cc_type = @$this->cc_type; $history = new stdClass(); $history->type = 'credit card'; $history->notified = 0; $history->data = base64_encode(serialize($obj)); $this->modifyOrder($order, $this->payment_params->order_status, $history, false); } }
function onAfterOrderConfirm(&$order, &$methods, $method_id) { parent::onAfterOrderConfirm($order, $methods, $method_id); if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if (!function_exists('curl_init')) { $this->app->enqueueMessage('The Authorize.net payment plugin in AIM mode needs the CURL library installed but it seems that it is not available on your server. Please contact your web hosting to set it up.', 'error'); $do = false; return false; } if (empty($this->payment_params->merchant_id)) { $this->app->enqueueMessage('You have to configure a customer merchant for the westpac plugin payment first : check your plugin\'s parameters, on your website backend', 'error'); return false; } if (empty($this->payment_params->username)) { $this->app->enqueueMessage('You have to configure your username for the westpac plugin payment first : check your plugin\'s parameters, on your website backend', 'error'); return false; } if (empty($this->payment_params->password)) { $this->app->enqueueMessage('You have to configure your password for the westpac plugin payment first : check your plugin\'s parameters, on your website backend', 'error'); return false; } if (empty($this->payment_params->certFile) || $this->payment_params->certFile == '.pem expected') { $this->app->enqueueMessage('You have to define the certificat file path for the westpac Api plugin payment first : check your plugin\'s parameters, on your website backend', 'error'); return false; } include dirname(__FILE__) . DS . 'westpacapi_qvalent.php'; $capath = JPath::clean(HIKASHOP_ROOT . 'plugins' . DS . 'hikashoppayment' . DS . 'westpacApi' . DS . 'cacerts.crt'); $initParams = "certificateFile=" . $this->payment_params->certFile . "&" . "caFile=" . $capath . "&" . 'logDirectory=' . HIKASHOP_ROOT . 'media' . DS . 'com_hikashop' . DS . 'upload' . DS . 'safe' . DS . 'logs' . DS; $paywayAPI = new Qvalent_PayWayAPI(); $paywayAPI->initialise($initParams); $amount = round($order->cart->full_total->prices[0]->price_value_with_tax, 2) * 100; $this->ccLoad(); $vars = array('order.type' => "capture", 'customer.merchant' => trim($this->payment_params->merchant_id), 'customer.username' => trim($this->payment_params->username), 'customer.password' => trim($this->payment_params->password), 'customer.orderNumber' => $order->order_id, 'customer.originalOrderNumber' => $order->order_id, 'card.PAN' => $this->cc_number, 'card.CVN' => $this->cc_CCV, 'card.expiryYear' => $this->cc_year, 'card.expiryMonth' => $this->cc_month, 'card.currency' => 'AUD', 'order.amount' => $amount, 'order.ECI' => 'SSL'); if ($this->payment_params->testingmode) { $vars['customer.merchant'] = 'TEST'; } if ($this->payment_params->debug) { $this->writeToLog("\n Data (vars) send to westpac in Api Mode: \n\n\n"); $this->writeToLog(print_r($vars, true)); } $requestText = $paywayAPI->formatRequestParameters($vars); $responseText = $paywayAPI->processCreditCard($requestText); $post_response = $paywayAPI->parseResponseParameters($responseText); if ($this->payment_params->debug) { $this->writeToLog("\n Data (post response) receive from westpac in Api Mode: \n\n\n"); $this->writeToLog(print_r($post_response, true)); } $this->ccClear(); if ($post_response['response.summaryCode'] == '0') { $order_status = $this->payment_params->verified_status; $this->modifyOrder($order->order_id, $order_status, true, true); return $this->showPage('thankyou'); } else { $order_status = $this->payment_params->invalid_status; $this->modifyOrder($order->order_id, $order_status, true, true); $cancel_url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=order&task=cancel_order&order_id=' . $order->order_id . $this->url_itemid; $error = "Report by Westpac </br>Error : " . $post_response['response.text']; $this->app->redirect($cancel_url, $error); return true; } }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if (!empty($this->payment_params->vpc_mode) && $this->payment_params->vpc_mode != 'dps') { return true; } if (!function_exists('curl_init')) { $this->app->enqueueMessage('The MIGS payment plugin needs the CURL library installed but it seems that it is not available on your server. Please contact your web hosting to set it up.', 'error'); return false; } $this->ccLoad(); if (!empty($this->payment_params->currency)) { $this->accepted_currencies = array(strtoupper($this->payment_params->currency)); } ob_start(); $dbg = ''; $amount = round($order->cart->full_total->prices[0]->price_value_with_tax * 100); $order_id = uniqid(''); $uuid = $order_id . '-1'; $vars = array('vpc_Version' => '1', 'vpc_Command' => 'pay', 'vpc_AccessCode' => $this->payment_params->access_code, 'vpc_MerchTxnRef' => $uuid, 'vpc_Merchant' => $this->payment_params->merchant_id, 'vpc_OrderInfo' => $order_id, 'vpc_Amount' => $amount, 'vpc_CardNum' => $this->cc_number, 'vpc_CardExp' => $this->cc_year . $this->cc_month); if ($this->payment_params->ask_ccv) { $vars['vpc_CardSecurityCode'] = $this->cc_CCV; } $postdata = array(); foreach ($vars as $k => $v) { $postdata[] = urlencode($k) . '=' . urlencode($v); } $postdata = implode('&', $postdata); $httpsHikashop = str_replace('http://', 'https://', HIKASHOP_LIVE); $url = 'https://migs.mastercard.com.au/vpcdps'; if (!empty($this->payment_params->url)) { $url = rtrim($this->payment_params->url, '/'); if (strpos($url, 'http') === false) { $url = 'https://' . $url; } } $session = curl_init($url); curl_setopt($session, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($session, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($session, CURLOPT_VERBOSE, 1); curl_setopt($session, CURLOPT_POST, 1); curl_setopt($session, CURLOPT_POSTFIELDS, $postdata); curl_setopt($session, CURLOPT_RETURNTRANSFER, 1); $ret = curl_exec($session); $error = curl_errno($session); $err_msg = curl_error($session); curl_close($session); if (!empty($ret)) { if ($this->payment_params->debug) { echo print_r($ret, true) . "\n\n\n"; } $result = 0; if (strpos($ret, '&') !== false) { $res = explode('&', $ret); $ret = array(); foreach ($res as $r) { list($k, $v) = explode('=', $r, 2); $ret[urldecode($k)] = urldecode($v); } $result = 1; $errorMsg = ''; if ($ret['vpc_TxnResponseCode'] == 0 || $ret['vpc_TxnResponseCode'] == '0') { $result = 2; } else { $errorMsg = $this->getResponseMessage($ret['vpc_TxnResponseCode']); } $transactionId = @$ret['vpc_TransactionNo']; $approvalCode = @$ret['vpc_AuthorizeId']; $responseMsg = $ret['vpc_Message']; } if ($result > 0) { if ($result == 2) { $do = true; $dbg .= ob_get_clean(); if (!empty($dbg)) { $dbg .= "\r\n"; } ob_start(); $history = new stdClass(); $email = new stdClass(); $history->notified = 0; $history->amount = number_format($order->cart->full_total->prices[0]->price_value_with_tax, 2, '.', '') . $this->accepted_currencies[0]; $history->data = $dbg . 'Authorization Code: ' . @$approvalCode . "\r\n" . 'Transaction ID: ' . @$transactionId; $order_status = $this->payment_params->verified_status; $url = HIKASHOP_LIVE . 'administrator/index.php?option=com_hikashop&ctrl=order&task=listing'; $order_text = "\r\n" . JText::sprintf('NOTIFICATION_OF_ORDER_ON_WEBSITE', '', HIKASHOP_LIVE); $order_text .= "\r\n" . str_replace('<br/>', "\r\n", JText::sprintf('ACCESS_ORDER_WITH_LINK', $url)); $email->subject = JText::sprintf('PAYMENT_NOTIFICATION', 'MIGS', 'Accepted'); $email->body = str_replace('<br/>', "\r\n", JText::sprintf('PAYMENT_NOTIFICATION_STATUS', 'MIGS', 'Accepted')) . ' ' . JText::sprintf('ORDER_STATUS_CHANGED', $order_status) . "\r\n\r\n" . $order_text; $this->modifyOrder($order, $order_status, $history, $email); } else { if (!empty($responseMsg)) { $this->app->enqueueMessage($responseMsg); } else { $this->app->enqueueMessage('Error'); } if (!empty($errorMsg)) { $this->app->enqueueMessage($errorMsg); } $do = false; } } else { $this->app->enqueueMessage('An error occurred.'); $do = false; } } else { $do = false; } if ($error != 0) { $this->app->enqueueMessage('There was an error during the connection with the MIGS payment gateway'); if ($this->payment_params->debug) { echo 'Curl Err [' . $error . '] : ' . $err_msg . "\n\n\n"; } } $this->writeToLog($dbg); if ($error != 0) { return true; } $this->ccClear(); return true; }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if ($this->payment_params->api != 'aim') { return true; } if (!function_exists('curl_init')) { $this->app->enqueueMessage('The Authorize.net payment plugin in AIM mode needs the CURL library installed but it seems that it is not available on your server. Please contact your web hosting to set it up.', 'error'); $do = false; return false; } $vars = $this->_loadStandardVars($order); $vars["x_delim_data"] = "TRUE"; $vars["x_delim_char"] = "|"; $this->ccLoad(); if ($this->payment_params->ask_ccv) { $vars["x_card_code"] = $this->cc_CCV; } $vars["x_card_num"] = $this->cc_number; $vars["x_exp_date"] = $this->cc_month . $this->cc_year; $vars["x_tran_key"] = $this->payment_params->transaction_key; $post_string = ""; foreach ($vars as $key => $value) { if (is_array($value)) { foreach ($value as $v) { $post_string .= $key . '=' . urlencode($v) . '&'; } } else { $post_string .= $key . '=' . urlencode($value) . '&'; } } $post_string = rtrim($post_string, '& '); $request = curl_init($this->payment_params->url); curl_setopt($request, CURLOPT_HEADER, 0); curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($request, CURLOPT_POSTFIELDS, $post_string); curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); $post_response = curl_exec($request); if (empty($post_response)) { $this->app->enqueueMessage('The connection to the payment plateform did not succeed. It is often caused by the hosting company blocking external connections so you should contact him for further guidance. The cURL error message was: ' . curl_error($request), 'error'); $do = false; return false; } curl_close($request); $response_array = explode("|", $post_response); $response_code = (int) @$response_array[0]; $response_subcode = @$response_array[1]; $response_reason_code = @$response_array[2]; $response_reason_text = @$response_array[3]; $transaction_id = @$response_array[6]; $history = new stdClass(); $history->notified = 0; $history->amount = round($order->cart->full_total->prices[0]->price_value_with_tax, 2) . 'USD'; $history->data = ''; if (!empty($transaction_id)) { $history->data = 'Authorize.net transaction id: ' . $transaction_id . "\r\n\r\n"; } switch ($response_code) { case 2: $this->app->enqueueMessage(JText::_('TRANSACTION_DECLINED_WRONG_CARD')); $this->ccClear(); $do = false; break; case 3: default: $this->app->enqueueMessage(JText::sprintf('TRANSACTION_PROCESSING_ERROR', $response_reason_code . ' ' . $response_reason_text)); $this->ccClear(); $do = false; break; case 1: $this->modifyOrder($order, $this->payment_params->verified_status, $history, false); break; case 4: $this->modifyOrder($order, $this->payment_params->pending_status, $history, false); break; } $this->vars = $vars; return true; }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if (!function_exists('curl_init')) { $this->app->enqueueMessage('The Payment Express payment plugin needs the CURL library installed but it seems that it is not available on your server. Please contact your web hosting to set it up.', 'error'); return false; } $this->ccLoad(); ob_start(); $dbg = ''; $amount = number_format($order->cart->full_total->prices[0]->price_value_with_tax, 2, '.', ''); $vars = '<Txn>'; $vars .= '<PostUsername>' . $this->payment_params->username . '</PostUsername>'; $vars .= '<PostPassword>' . $this->payment_params->password . '</PostPassword>'; $vars .= '<Amount>' . $amount . '</Amount>'; $vars .= '<InputCurrency>' . $this->currency->currency_code . '</InputCurrency>'; if (!empty($this->cc_CCV)) { $vars .= '<Cvc2>' . $this->cc_CCV . '</Cvc2>'; } if (!empty($this->cc_owner)) { $vars .= '<CardHolderName>' . $this->cc_owner . '</CardHolderName>'; } $vars .= '<CardNumber>' . $this->cc_number . '</CardNumber>'; $vars .= '<DateExpiry>' . $this->cc_month . $this->cc_year . '</DateExpiry>'; $vars .= '<TxnType>Purchase</TxnType>'; if (empty($order->order_number) && !empty($order->order_id)) { $order->order_number = hikashop_encode($order); } if (!empty($order->order_number)) { $vars .= '<MerchantReference>' . $order->order_number . '</MerchantReference>'; } $vars .= '</Txn>'; $domain = 'https://sec.paymentexpress.com/pxpost.aspx'; $session = curl_init($domain); curl_setopt($session, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($session, CURLOPT_VERBOSE, 1); curl_setopt($session, CURLOPT_SSLVERSION, defined('CURL_SSLVERSION_TLSv1') ? CURL_SSLVERSION_TLSv1 : 1); curl_setopt($session, CURLOPT_POST, 1); curl_setopt($session, CURLOPT_POSTFIELDS, $vars); curl_setopt($session, CURLOPT_RETURNTRANSFER, 1); $ret = curl_exec($session); $error = curl_errno($session); $err_msg = curl_error($session); curl_close($session); if (!empty($ret)) { if ($this->payment_params->debug) { echo print_r($ret, true) . "\n\n\n"; } $error_msg = ''; if (preg_match('#<Success>([0-9])</Success>#', $ret, $res) !== false && $res[1]) { $approvalCode = ''; if (preg_match('#<AuthCode>([0-9]+)</AuthCode>#', $ret, $res) !== false) { $approvalCode = $res[1]; } $transactionId = ''; if (preg_match('#<TransactionId>([0-9]+)</TransactionId>#', $ret, $res) !== false) { $transactionId = $res[1]; } $do = true; $dbg .= ob_get_clean(); if (!empty($dbg)) { $dbg .= "\r\n"; } ob_start(); $history = new stdClass(); $email = new stdClass(); $history->notified = 0; $history->amount = $amount . $this->currency->currency_code; $history->data = $dbg . 'Authorization Code: ' . $approvalCode . "\r\n" . 'Transaction ID: ' . $transactionId; $order_status = $this->payment_params->verified_status; $url = HIKASHOP_LIVE . 'administrator/index.php?option=com_hikashop&ctrl=order&task=listing'; $order_text = "\r\n" . JText::sprintf('NOTIFICATION_OF_ORDER_ON_WEBSITE', '', HIKASHOP_LIVE); $order_text .= "\r\n" . str_replace('<br/>', "\r\n", JText::sprintf('ACCESS_ORDER_WITH_LINK', $url)); $email->subject = JText::sprintf('PAYMENT_NOTIFICATION', 'Payment express', 'Accepted'); $email->body = str_replace('<br/>', "\r\n", JText::sprintf('PAYMENT_NOTIFICATION_STATUS', 'Payment express', 'Accepted')) . ' ' . JText::sprintf('ORDER_STATUS_CHANGED', $order_status) . "\r\n\r\n" . $order_text; $this->modifyorder($order, $order_status, $history, $email); } else { if (preg_match('#<ReCo>([0-9]+)</ReCo>#', $ret, $res)) { $error = $res[1] . ' '; } if (preg_match('#<ResponseText>(.*)</ResponseText>#', $ret, $res)) { $error_msg = $res[1] . ' '; } if (preg_match('#<HelpText>(.*)</HelpText>#', $ret, $res)) { $error_msg .= $res[1]; } $responseMsg = $error . $error_msg; if (!empty($responseMsg)) { $this->app->enqueueMessage('Error : ' . $responseMsg); } else { $this->app->enqueueMessage('Error'); } $do = false; } } else { $this->app->enqueueMessage('There was an error during the connection with the Payment Express gateway'); if ($this->payment_params->debug) { echo 'Curl Err [' . $error . '] : ' . $err_msg . "\n\n\n"; } $do = false; } $this->writeToLog($dbg); if (!$do) { return true; } $this->ccClear(); return true; }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if (!in_array($this->currency->currency_code, $this->accepted_currencies)) { $app->enqueueMessage('The iPayDNA payment plugin doest not support your currency: "' . htmlentities($this->currency->currency_code) . '"', 'error'); return false; } $this->ccLoad(); $amount = number_format($order->cart->full_total->prices[0]->price_value_with_tax, 2, '.', ''); if (!empty($this->payment_params->currency)) { $db = JFactory::getDBO(); $db->setQuery("SELECT currency_id as `id` FROM #__hikashop_currency WHERE currency_code='" . $this->payment_params->currency . "';"); $dstCurrency = $db->loadObjectList(); if (isset($dstCurrency) && @$dstCurrency[0]->id > 0) { if ($dstCurrency[0]->id != $order->order_currency_id) { $currencyClass = hikashop_get('class.currency'); $price = $currencyClass->convertUniquePrice($order->cart->full_total->prices[0]->price_value_with_tax, $order->order_currency_id, $dstCurrency[0]->id); $dstCurrencies = null; $dstCurrencies = $currencyClass->getCurrencies($dstCurrency[0]->id, $dstCurrencies); $tmpCurrency = $dstCurrencies[$dstCurrency[0]->id]; $amount = number_format($price, 2, '.', ''); $currency = $tmpCurrency; } else { $amount = number_format($order->cart->full_total->prices[0]->price_value_with_tax, 2, '.', ''); } } } $vars = '<' . '?xml version="1.0" encoding="UTF-8"?' . '>' . "\r\n" . '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" ' . 'xmlns:ns1="http://acquirer.process.training.aquarius" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' . 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" ' . 'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'; if (isset($order->order_id)) { $uuid = $order->order_id; } else { $uuid = uniqid(''); } $state = ''; $state2 = ''; $vars .= '<SOAP-ENV:Body><ns1:payment>' . '<customerpaymentpagetext xsi:type="xsd:string">' . $this->payment_params->tid . '</customerpaymentpagetext>' . '<orderdescription xsi:type="xsd:string">' . $uuid . '</orderdescription>' . '<orderDetail xsi:type="xsd:string">HikaShop order ' . $this->user->user_id . '</orderDetail>' . '<currencytext xsi:type="xsd:string">' . $this->currency->currency_code . '</currencytext>' . '<purchaseamount xsi:type="xsd:string">' . $amount . '</purchaseamount>' . '<taxamount xsi:type="xsd:string">0.00</taxamount>' . '<shippingamount xsi:type="xsd:string">0.00</shippingamount>' . '<dutyamount xsi:type="xsd:string">0.00</dutyamount>' . '<cardholdername xsi:type="xsd:string">' . $this->cc_owner . '</cardholdername>' . '<cardno xsi:type="xsd:string">' . $this->cc_number . '</cardno>' . '<cardtypetext xsi:type="xsd:string">' . $this->cc_type . '</cardtypetext>' . '<securitycode xsi:type="xsd:string">' . $this->cc_CCV . '</securitycode>' . '<cardexpiremonth xsi:type="xsd:string">' . $this->cc_month . '</cardexpiremonth>' . '<cardexpireyear xsi:type="xsd:string">20' . $this->cc_year . '</cardexpireyear>' . '<cardissuemonth xsi:type="xsd:string">0</cardissuemonth>' . '<cardissueyear xsi:type="xsd:string">0</cardissueyear>' . '<issuername xsi:type="xsd:string"></issuername>' . '<firstname xsi:type="xsd:string">' . substr(@$order->cart->billing_address->address_firstname, 0, 100) . '</firstname>' . '<lastname xsi:type="xsd:string">' . substr(@$order->cart->billing_address->address_lastname, 0, 100) . '</lastname>' . '<company xsi:type="xsd:string"></company>' . '<address xsi:type="xsd:string">' . substr($order->cart->billing_address->address_street, 0, 250) . '</address>' . '<city xsi:type="xsd:string">' . substr(@$order->cart->billing_address->address_city, 0, 50) . '</city>' . '<state xsi:type="xsd:string">' . $state . '</state>' . '<zip xsi:type="xsd:string">' . substr(@$order->cart->billing_address->address_post_code, 0, 50) . '</zip>' . '<country xsi:type="xsd:string">' . @$order->cart->billing_address->address_country->zone_code_2 . '</country>' . '<email xsi:type="xsd:string">' . substr($this->user->user_email, 0, 250) . '</email>' . '<phone xsi:type="xsd:string">0</phone>' . '<shipfirstname xsi:type="xsd:string">' . substr(@$order->cart->shipping_address->address_firstname, 0, 100) . '</shipfirstname>' . '<shiplastname xsi:type="xsd:string">' . substr(@$order->cart->shipping_address->address_lastname, 0, 100) . '</shiplastname>' . '<shipaddress xsi:type="xsd:string">' . substr($order->cart->shipping_address->address_street, 0, 250) . '</shipaddress>' . '<shipcity xsi:type="xsd:string">' . substr(@$order->cart->shipping_address->address_city, 0, 50) . '</shipcity>' . '<shipstate xsi:type="xsd:string">' . $state2 . '</shipstate>' . '<shipzip xsi:type="xsd:string">' . substr(@$order->cart->shipping_address->address_post_code, 0, 50) . '</shipzip>' . '<shipcountry xsi:type="xsd:string">' . @$order->cart->shipping_address->address_country->zone_code_2 . '</shipcountry>' . '<cardHolderIP xsi:type="xsd:string">127.0.0.1</cardHolderIP>' . '</ns1:payment></SOAP-ENV:Body></SOAP-ENV:Envelope>'; $url = $this->payment_params->url; $header = array('Content-type: text/xml; charset=utf-8', 'Accept: text/xml', 'Cache-Control: no-cache', 'Pragma: no-cache', 'SOAPAction: ""', 'Content-length: ' . strlen($vars)); $session = curl_init('https://' . $url); curl_setopt($session, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($session, CURLOPT_VERBOSE, 1); curl_setopt($session, CURLOPT_POST, 1); curl_setopt($session, CURLOPT_HTTPHEADER, $header); curl_setopt($session, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($session, CURLOPT_POSTFIELDS, $vars); curl_setopt($session, CURLOPT_RETURNTRANSFER, 1); $ret = curl_exec($session); $error = curl_errno($session); $err_msg = curl_error($session); curl_close($session); if (!empty($ret)) { if ($this->payment_params->debug) { echo print_r($ret, true) . "\n\n\n"; } $result = array(); if (strpos($ret, 'TRANSACTIONSTATUSTEXT') !== false) { if (preg_match_all('#<var name=\'(.+)\'><[a-zA-Z]+>(.*)</[a-zA-Z]+></var>#iU', $ret, $res, PREG_SET_ORDER)) { foreach ($res as $r) { $result[$r[1]] = $r[2]; } } } if (isset($result['TRANSACTIONSTATUSTEXT']) && $result['TRANSACTIONSTATUSTEXT'] == 'SUCCESSFUL') { $do = true; $dbg .= ob_get_clean(); if (!empty($dbg)) { $dbg .= "\r\n"; } ob_start(); $history = new stdClass(); $history->notified = 0; $history->amount = $amount . $this->accepted_currencies[0]; $history->data = $dbg . 'Authorization Code: ' . @$result['AUTHORIZATIONCODE'] . "\r\n" . 'Order Reference: ' . @$result['ORDERREFERENCE'] . "\r\n" . 'Unique ID: ' . $uuid; $this->modifyOrder($order, $order->order_status, $history, true); } else { $errMsg = 'An error occurred.'; if (!empty($result['ERRORMESSAGE'])) { $errMsg = 'An error occurred: [' . @$result['ERRORCODE'] . '] ' . $result['ERRORMESSAGE']; } $this->app->enqueueMessage($errMsg); $do = false; } } else { $do = false; } if ($error != 0) { $this->app->enqueueMessage('There was an error during the connection with the iPayDNA payment gateway'); if ($this->payment_params->debug) { echo 'Curl Err [' . $error . '] : ' . $err_msg . "\n\n\n"; } } $this->writeToLog(null); if ($error == 0) { $this->ccClear(); } return true; }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if (@$this->payment_params->api != 'direct') { return true; } if (!function_exists('curl_init')) { $this->app->enqueueMessage('The CardSave payment plugin needs the CURL library installed but it seems that it is not available on your server. Please contact your web hosting to set it up.', 'error'); return false; } $this->ccLoad(); $address1 = ''; $address2 = ''; $address3 = ''; $address4 = ''; if (!empty($order->cart->billing_address->address_street)) { $address1 = $address2 = $address3 = $address4 = ''; if (!empty($order->cart->billing_address->address_street2)) { $address2 = substr($order->cart->billing_address->address_street2, 0, 100); } if (strlen($order->cart->billing_address->address_street) > 100) { $address1 = substr($order->cart->billing_address->address_street, 0, 100); if (empty($address2)) { $address2 = @substr($order->cart->billing_address->address_street, 100, 50); } if (empty($address3)) { $address3 = @substr($order->cart->billing_address->address_street, 150, 50); } if (empty($address4)) { $address4 = @substr($order->cart->billing_address->address_street, 200, 50); } } else { $address1 = $order->cart->billing_address->address_street; } } $country_code_2 = @$order->cart->billing_address->address_country->zone_code_3; if (isset($order->order_id)) { $uuid = $order->order_id; } else { $uuid = uniqid(''); } $gwId = 1; $cpt = 0; $domain = $this->payment_params->gw_entrypoint; $port = (int) $this->payment_params->gw_port; if ($port == 443 || $port == 0) { $port = ''; } else { $port = ':' . $port; } $amount = (int) round($order->cart->full_total->prices[0]->price_value_with_tax * 100); $currencyCode = (int) $this->sync_currencies[$this->currency->currency_code]; $xml = '<' . '?xml version="1.0" encoding="utf-8"?' . '>'; $xml .= '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'; $xml .= '<soap:Body><CardDetailsTransaction xmlns="https://www.thepaymentgateway.net/"><PaymentMessage>'; $xml .= '<MerchantAuthentication MerchantID="' . $this->payment_params->merchantid . '" Password="******" />'; $xml .= '<TransactionDetails Amount="' . $amount . '" CurrencyCode="' . $currencyCode . '">'; $xml .= '<MessageDetails TransactionType="' . ($this->payment_params->instant_capture ? 'SALE' : 'PREAUTH') . '" />'; $xml .= '<OrderID>' . $uuid . '</OrderID>'; $xml .= '</TransactionDetails><CardDetails><CardName>' . $this->cc_owner . '</CardName><CardNumber>' . $this->cc_number . '</CardNumber>'; $xml .= '<ExpiryDate Month="' . $this->cc_month . '" Year="' . $this->cc_year . '"/>'; if ($this->payment_params->ask_ccv) { $xml .= '<CV2>' . $this->cc_CCV . '</CV2>'; } $xml .= '</CardDetails><CustomerDetails><BillingAddress><Address1>' . $address1 . '</Address1>'; if (!empty($adress2)) { $xml .= '<Address2>' . $address2 . '</Address2>'; } if (!empty($adress3)) { $xml .= '<Address3>' . $address3 . '</Address3>'; } if (!empty($adress4)) { $xml .= '<Address4>' . $address4 . '</Address4>'; } $xml .= '<City>' . substr(@$order->cart->billing_address->address_city, 0, 50) . '</City><State>' . substr(@$order->cart->billing_address->address_state->zone_name, 0, 50) . '</State>'; $xml .= '<PostCode>' . substr(@$order->cart->billing_address->address_post_code, 0, 50) . '</PostCode><CountryCode>' . $this->country_codes[$country_code_2] . '</CountryCode>'; $xml .= '</BillingAddress><EmailAddress>' . substr($this->user->user_email, 0, 100) . '</EmailAddress></CustomerDetails>'; $xml .= '</PaymentMessage></CardDetailsTransaction></soap:Body></soap:Envelope>'; $session = null; do { $soapSuccess = false; $url = 'https://gw' . $gwId . '.' . $domain . $port . '/'; $session = curl_init(); if ($session === false) { $do = false; break; } $headers = array('SOAPAction:https://www.thepaymentgateway.net/CardDetailsTransaction', 'Content-Type: text/xml; charset = utf-8', 'Connection: close'); curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_HTTPHEADER, $headers); curl_setopt($session, CURLOPT_POST, true); curl_setopt($session, CURLOPT_URL, $url); curl_setopt($session, CURLOPT_POSTFIELDS, $xml); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); curl_setopt($session, CURLOPT_ENCODING, 'UTF-8'); curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false); $ret = curl_exec($session); $err = curl_errno($session); $retHead = curl_getinfo($session); curl_close($session); $session = null; $history = new stdClass(); $email = new stdClass(); if ($err == 0) { $status = null; $soapStatus = null; if (preg_match('#<StatusCode>([0-9]+)</StatusCode>#iU', $ret, $soapStatus)) { $status = (int) $soapStatus[1]; $auth = null; $crossref = null; if (preg_match('#<AuthCode>([a-zA-Z0-9]+)</AuthCode>#iU', $ret, $auth)) { $auth = $auth[1]; } if (preg_match('#<TransactionOutputData.*CrossReference="([a-zA-Z0-9]+)".*>#iU', $ret, $crossref)) { $crossref = $crossref[1]; } if ($status == 0 && $soapStatus[1] != '0') { $status = 50; } if ($status != 50) { $soapSuccess = true; switch ($status) { case 0: $history->amount = $order->cart->full_total->prices[0]->price_value_with_tax . $this->currency->currency_code; $history->data = 'UUID: ' . $uuid . "\n" . 'CrossReference: ' . $crossref . "\n" . ob_get_clean(); $order_status = $this->payment_params->verified_status; $history->notified = 1; $payment_status = 'confirmed'; $url = HIKASHOP_LIVE . 'administrator/index.php?option=com_hikashop&ctrl=order&task=listing'; $order_text = "\r\n" . JText::sprintf('NOTIFICATION_OF_ORDER_ON_WEBSITE', '', HIKASHOP_LIVE); $order_text .= "\r\n" . str_replace('<br/>', "\r\n", JText::sprintf('ACCESS_ORDER_WITH_LINK', $url)); $email->subject = JText::sprintf('PAYMENT_NOTIFICATION', 'CardSave', 'Accepted'); $email->body = str_replace('<br/>', "\r\n", JText::sprintf('PAYMENT_NOTIFICATION_STATUS', 'CardSave', 'Accepted')) . ' ' . JText::sprintf('ORDER_STATUS_CHANGED', $order_status) . "\r\n\r\n" . $order_text; $this->modifyOrder($order, $order_status, $history, $email); break; case 3: if (preg_match('#<ThreeDSecureOutputData>.*<PaREQ>(.+)</PaREQ>.*<ACSURL>(.+)</ACSURL>.*</ThreeDSecureOutputData>#iU', $ret, $soap3DSec)) { $PaREQ = $soap3DSec[1]; $ACSurl = $soap3DSec[2]; } else { $this->app->enqueueMessage('Incorrect 3DSecure data.'); $do = false; break; } $data = array('UUID' => $uuid, 'XREF' => $crossref); $history->notified = 0; $history->amount = $order->cart->full_total->prices[0]->price_value_with_tax . $this->currency->currency_code; $history->data = serialize($data); $history->type = '3dsecure'; $this->app->setUserState(HIKASHOP_COMPONENT . '.ThreeDS_ref', $crossref); $this->app->setUserState(HIKASHOP_COMPONENT . '.ThreeDS_url', $ACSurl); $this->app->setUserState(HIKASHOP_COMPONENT . '.ThreeDS_req', $PaREQ); $this->modifyOrder($order, null, $history, false); break; case 5: $this->app->enqueueMessage('Transaction declined.'); $do = false; break; case 20: if (preg_match('#<PreviousTransactionResult>.*<StatusCode>([0-9]+)</StatusCode>#iU', $ret, $soapStatus2)) { if ($soapStatus2[1] == '0') { $this->app->enqueueMessage('Transaction already validate.'); } else { if (preg_match('#<Message>(.*)</Message>.*</PreviousTransactionResult>#iU', $ret, $msg)) { $this->app->enqueueMessage($msg[1]); $do = false; } else { $this->app->enqueueMessage('Duplicate transaction'); $do = false; } } } else { $this->app->enqueueMessage('Duplicate transaction.'); $do = false; } break; case 30: default: if (preg_match('#<Message>(.*)</Message>#iU', $ret, $msg)) { $msg = $msg[1]; } else { $msg = ''; } $this->app->enqueueMessage('CardSave Error (' . $status . ') :' . $msg); $do = false; break; } } } } if ($session) { curl_close($session); } if (!$soapSuccess) { $cpt++; if ($cpt >= 2) { $cpt = 0; $gwId++; if ($gwId > 3) { $this->app->enqueueMessage('Impossible to contact the CardSave payment gateway.'); $do = false; $soapSuccess = true; break; } } } } while (!$soapSuccess && $gwId < 4 && $cpt < 3); $this->ccClear(); return true; }
function onBeforeOrderCreate(&$order, &$do) { if (!empty($order->order_type) && $order->order_type != 'sale') { return true; } if (empty($order->order_payment_params)) { $order->order_payment_params = new stdClass(); } if (empty($order->order_payment_params->userpoints)) { $order->order_payment_params->userpoints = new stdClass(); } if (empty($order->order_payment_params->userpoints->use_points)) { $order->order_payment_params->userpoints->use_points = 0; } if (empty($order->order_payment_params->userpoints->earn_points)) { $order->order_payment_params->userpoints->earn_points = array(); } $earnPoints = $this->getPointsEarned($order, 'all'); if (!empty($earnPoints)) { foreach ($earnPoints as $mode => $pts) { if (empty($order->order_payment_params->userpoints->earn_points[$mode])) { $order->order_payment_params->userpoints->earn_points[$mode] = 0; } $order->order_payment_params->userpoints->earn_points[$mode] += $pts; } } if ((empty($order->order_payment_method) || $order->order_payment_method != $this->name) && !empty($order->cart->additional)) { $ids = array(); parent::listPlugins($this->name, $ids, false); foreach ($ids as $id) { parent::pluginParams($id); if (empty($this->payment_params)) { continue; } if ($this->payment_params->virtual_coupon) { $checkPoints = $points = $this->checkPoints($order); $usePts = -1; foreach ($order->cart->additional as $additional) { if ($additional->name != 'USERPOINTS_USE_POINTS') { continue; } $matches = array(); if (preg_match('#-([0-9]+)#', $additional->value, $matches)) { $usePts = (int) $matches[1]; } else { $usePts = substr($additional->value, 0, strpos($additional->value, ' ')); $usePts = (int) trim(str_replace('-', '', $usePts)); } break; } if ($checkPoints > $usePts) { $order->order_payment_params->userpoints->earn_points[$this->plugin_params->points_mode] += $usePts - $checkPoints; $points = $usePts; } if ($usePts > 0) { $points = $usePts; } if ($points !== false && $points > 0) { $order->order_payment_params->userpoints->use_points += $points; $order->order_payment_params->userpoints->use_mode = $this->plugin_params->points_mode; } break; } } return true; } if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if (!empty($order->cart->coupon->discount_code) && (preg_match('#^POINTS_[a-zA-Z0-9]{30}$#', $order->cart->coupon->discount_code) || preg_match('#^POINTS_([-a-zA-Z0-9]+)_[a-zA-Z0-9]{25}$#', $order->cart->coupon->discount_code))) { if (@$this->payment_params->partialpayment === 0 && $order->cart->full_total->prices[0]->price_value_without_discount != $order->cart->coupon->discount_value) { $do = false; echo JText::_('ERROR_POINTS'); return true; } } $check = $this->checkPoints($order); $userPoints = $this->getUserPoints(null, $this->payment_params->points_mode); $fullOrderPoints = $this->finalPriceToPoints($order, $userPoints); if (($this->payment_params->partialpayment == 1 || $this->payment_params->allowshipping == 0) && ($check !== false && $check > 0) && $check < $fullOrderPoints && $userPoints) { $discountClass = hikashop_get('class.discount'); $cartClass = hikashop_get('class.cart'); $config =& hikashop_config(); $currency = hikashop_getCurrency(); $app = JFactory::getApplication(); $newCoupon = new stdClass(); $newCoupon->discount_type = 'coupon'; $newCoupon->discount_currency_id = $currency; $newCoupon->discount_flat_amount = $check * $this->payment_params->value; $newCoupon->discount_quota = 1; jimport('joomla.user.helper'); if (!empty($this->payment_params->givebackpoints)) { $newCoupon->discount_code = 'POINTS_' . $this->payment_params->points_mode . '_'; $newCoupon->discount_code .= JUserHelper::genRandomPassword(25); } else { $newCoupon->discount_code = 'POINTS_'; $newCoupon->discount_code .= JUserHelper::genRandomPassword(30); } $newCoupon->discount_published = 1; $discountClass->save($newCoupon); $coupon = $newCoupon; if (!empty($coupon)) { $cartClass->update($coupon->discount_code, 1, 0, 'coupon'); $cartClass->loadCart(0, true); } $app->setUserState(HIKASHOP_COMPONENT . '.payment_method', null); $app->setUserState(HIKASHOP_COMPONENT . '.payment_id', null); $app->setUserState(HIKASHOP_COMPONENT . '.payment_data', null); $do = false; if (empty($order->customer)) { $userClass = hikashop_get('class.user'); $order->customer = $userClass->get($order->order_user_id); } $this->addPoints(-$check, $order, JText::_('HIKASHOP_COUPON') . ' ' . $coupon->discount_code); } }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if (!function_exists('curl_init')) { $this->app->enqueueMessage('The Virtual Merchant payment plugin needs the CURL library installed but it seems that it is not available on your server. Please contact your web hosting to set it up.', 'error'); return false; } $this->ccLoad(); $amount = number_format($order->cart->full_total->prices[0]->price_value_with_tax, 2, '.', ''); $vars = '<txn>' . '<ssl_merchant_id>' . $this->payment_params->merchant_id . '</ssl_merchant_id>' . '<ssl_user_id>' . $this->payment_params->user_id . '</ssl_user_id>' . '<ssl_pin>' . $this->payment_params->pin . '</ssl_pin>' . '<ssl_test_mode>' . (@$this->payment_params->test_mode ? 'True' : 'False') . '</ssl_test_mode>' . '<ssl_transaction_type>CCSALE</ssl_transaction_type>' . '<ssl_show_form >False</ssl_show_form >' . '<ssl_card_number>' . str_replace(array('<', '>'), array('<', '>'), $this->cc_number) . '</ssl_card_number>' . '<ssl_exp_date>' . $this->cc_month . $this->cc_year . '</ssl_exp_date>' . '<ssl_amount>' . $amount . '</ssl_amount>' . '<ssl_salestax>0.00</ssl_salestax>' . '<ssl_cvv2cvc2_indicator>' . ($this->payment_params->ask_ccv ? '1' : '0') . '</ssl_cvv2cvc2_indicator>' . '<ssl_cvv2cvc2>' . str_replace(array('<', '>'), array('<', '>'), $this->cc_CCV) . '</ssl_cvv2cvc2>' . '<ssl_customer_code>' . $this->user->user_id . '</ssl_customer_code>' . '<ssl_first_name>' . str_replace(array('<', '>'), array('<', '>'), $order->cart->billing_address->address_firstname) . '</ssl_first_name>' . '<ssl_last_name>' . str_replace(array('<', '>'), array('<', '>'), $order->cart->billing_address->address_lastname) . '</ssl_last_name>'; if (!empty($this->payment_params->multi_currency)) { $vars .= '<ssl_transaction_currency>' . $this->currency->currency_code . '</ssl_transaction_currency>'; } if ($this->payment_params->use_avs) { $addr1 = @$order->cart->billing_address->address_street; if (strlen(urlencode($addr1)) > 20) { $vars .= '<ssl_avs_address>' . urlencode(substr($addr1, 0, 20)) . '</ssl_avs_address>' . '<ssl_address2>' . urlencode(substr($addr1, 20, 30)) . '</ssl_address2>'; } else { $vars .= '<ssl_avs_address>' . urlencode($addr1) . '</ssl_avs_address>'; } $vars .= '<ssl_city>' . urlencode(@$order->cart->billing_address->address_city) . '</ssl_city>' . '<ssl_state>' . urlencode(@$order->cart->billing_address->address_state->zone_name) . '</ssl_state>' . '<ssl_avs_zip>' . urlencode(@$order->cart->billing_address->address_post_code) . '</ssl_avs_zip>' . '<ssl_country>' . urlencode(@$order->cart->billing_address->address_country->zone_name_english) . '</ssl_country>'; } $vars .= '<ssl_email>' . str_replace(array('<', '>'), array('<', '>'), $this->user->user_email) . '</ssl_email>' . '</txn>'; if ($this->payment_params->debug) { echo htmlentities(str_replace(array($this->cc_number, $this->cc_CCV), array('**************', '***'), $vars)) . "\n\n\n"; } $session = curl_init(); curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($session, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($session, CURLOPT_POST, 1); curl_setopt($session, CURLOPT_RETURNTRANSFER, 1); curl_setopt($session, CURLOPT_VERBOSE, 1); curl_setopt($session, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($session, CURLOPT_FAILONERROR, true); $httpsHikashop = str_replace('http://', 'https://', HIKASHOP_LIVE); if ($this->payment_params->sandbox) { $url = 'demo.myvirtualmerchant.com/VirtualMerchantDemo/processxml.do'; } else { $url = 'www.myvirtualmerchant.com/VirtualMerchant/processxml.do'; } curl_setopt($session, CURLOPT_URL, 'https://' . $url); curl_setopt($session, CURLOPT_REFERER, $httpsHikashop); curl_setopt($session, CURLOPT_POSTFIELDS, 'xmldata=' . urlencode($vars)); $ret = curl_exec($session); $error = curl_errno($session); curl_close($session); if (!$error) { $p0 = strpos($ret, '<txn>'); if ($p0 !== false) { $ret = substr($ret, $p0); } $data = str_replace(array('<txn>', '</txn>'), '', trim($ret)); $ret = array(); while ($data) { $p0 = strpos($data, '<'); $p1 = strpos($data, '>'); if ($p0 === false || $p1 === false) { break; } $key = substr($data, $p0 + 1, $p1 - 1); $data = substr($data, $p0 + 1); if (substr($key, -1) == '/') { $ret[$key] = ''; } else { $l = strlen($key); $p1 = strpos($data, '</' . $key . '>'); if ($p1 !== false) { $ret[$key] = substr($data, $l + 1, $p1 - $l - 1); $data = substr($data, $p1 + $l + 3); } } } if ($this->payment_params->debug) { echo print_r($ret, true) . "\n\n\n"; } if (isset($ret['ssl_result'])) { if ($ret['ssl_result'] == '0') { $dbg = ob_get_clean(); if (!empty($dbg)) { $dbg .= "\r\n"; } ob_start(); $history = new stdClass(); $email = new stdClass(); $history->notified = 0; $history->amount = $amount . $this->payment_params->currency; $history->data = $dbg . 'Authorization Code: ' . $ret['ssl_approval_code'] . "\r\n" . 'Transaction ID: ' . $ret['ssl_txn_id']; $order_status = $this->payment_params->verified_status; $url = HIKASHOP_LIVE . 'administrator/index.php?option=com_hikashop&ctrl=order&task=listing'; $order_text = "\r\n" . JText::sprintf('NOTIFICATION_OF_ORDER_ON_WEBSITE', '', HIKASHOP_LIVE); $order_text .= "\r\n" . str_replace('<br/>', "\r\n", JText::sprintf('ACCESS_ORDER_WITH_LINK', $url)); $email->subject = JText::sprintf('PAYMENT_NOTIFICATION', 'VirtualMerchant', 'Accepted'); $email->body = str_replace('<br/>', "\r\n", JText::sprintf('PAYMENT_NOTIFICATION_STATUS', 'VirtualMerchant', 'Accepted')) . ' ' . JText::sprintf('ORDER_STATUS_CHANGED', $order_status) . "\r\n\r\n" . $order_text; $this->modifyOrder($order, $order_status, $history, $email); } else { if (empty($ret['errorMessage'])) { $ret['errorMessage'] = 'An error occurred with the payment'; } $this->app->enqueueMessage('Error Code #' . $ret['errorCode'] . ': ' . $ret['errorMessage']); $do = false; } } else { $this->app->enqueueMessage('An error occurred.'); $do = false; } $this->ccClear(); } else { $this->app->enqueueMessage('An error occurred. ' . $error); $do = false; } return true; }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if (!function_exists('curl_init')) { $this->app->enqueueMessage('The Innovative Gateway payment plugin needs the CURL library installed but it seems that it is not available on your server. Please contact your web hosting to set it up.', 'error'); $do = false; return false; } $this->ccLoad(); ob_start(); $dbg = ''; $vars = array(); $vars['target_app'] = 'WebCharge_v5.06'; $vars['response_mode'] = 'simple'; $vars['response_fmt'] = 'delimited'; $vars['upg_auth'] = 'zxcvlkjh'; $vars['delimited_fmt_field_delimiter'] = '='; $vars['delimited_fmt_include_fields'] = 'true'; $vars['delimited_fmt_value_delimiter'] = '|'; $vars['username'] = $this->payment_params->login; $vars['pw'] = $this->payment_params->password; if ($vars['username'] == 'gatewaytest') { $vars['test_override_errors'] = 'yes'; } $vars['trantype'] = 'sale'; // Options: preauth, postauth, sale, credit, void $vars['reference'] = ''; // Blank for new sales.. $vars['trans_id'] = ''; // Blank for new sales... $vars['authamount'] = ''; // Only valid for POSTAUTH and is equal to the original preauth amount. $vars['cardtype'] = !empty($this->cc_type) ? $this->cc_type : 'visa'; $vars['ccnumber'] = $this->cc_number; // Credit Card information if ($this->payment_params->ask_ccv) { $vars['ccidentifier1'] = $this->cc_CCV; } $vars['month'] = $this->cc_month; // Must be TWO DIGIT month. $vars['year'] = $this->cc_year; // Must be TWO or FOUR DIGIT year. $vars['ccname'] = $this->cc_owner; $vars['fulltotal'] = number_format($order->cart->full_total->prices[0]->price_value_with_tax, 2, '.', ''); // Total amount WITHOUT dollar sign. $vars['baddress'] = @$order->cart->billing_address->address_street; $vars['baddress1'] = ''; $vars['bcity'] = @$order->cart->billing_address->address_city; $vars['bstate'] = @$order->cart->billing_address->address_state->zone_code_3; $vars['bzip'] = @$order->cart->billing_address->address_post_code; $vars['bcountry'] = @$order->cart->billing_address->address_country->zone_code_2; // TWO DIGIT COUNTRY (United States = 'US') $vars['email'] = $this->user->user_email; $domain = 'transactions.innovativegateway.com'; $url = '/servlet/com.gateway.aai.Aai'; if ($this->payment_params->debug) { echo print_r($vars, true) . "\n\n\n"; } $data = ''; foreach ($vars as $k => $v) { if ($data != '') { $data .= '&'; } $data .= $k . "=" . urlencode($v); } $session = curl_init('https://' . $domain . $url); curl_setopt($session, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($session, CURLOPT_VERBOSE, 1); curl_setopt($session, CURLOPT_POST, 1); curl_setopt($session, CURLOPT_POSTFIELDS, $data); curl_setopt($session, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($session, CURLOPT_RETURNTRANSFER, 1); curl_setopt($session, CURLOPT_TIMEOUT, 120); $ret = curl_exec($session); $error = curl_errno($session); $err_msg = curl_error($session); curl_close($session); if (!empty($ret)) { if ($this->payment_params->debug) { echo print_r($ret, true) . "\n\n\n"; } $result = explode('|', $ret); $ret = array(); foreach ($result as $v) { if (!empty($v)) { $t = explode('=', $v, 2); if (isset($t[1])) { $ret[strtolower($t[0])] = strip_tags($t[1]); } else { $ret[strtolower($t[0])] = ''; } } } if (!empty($ret['approval'])) { $do = true; $dbg .= ob_get_clean(); if (!empty($dbg)) { $dbg .= "\r\n"; } ob_start(); $this->modifyOrder($order, $this->payment_params->verified_status, true, true); } else { if (isset($ret['error'])) { $this->app->enqueueMessage($ret['error']); } else { $this->app->enqueueMessage('Error'); } $do = false; } } else { $do = false; } if ($error != 0) { $this->app->enqueueMessage('There was an error during the connection with the Innovative Gateway payment gateway'); if ($this->payment_params->debug) { echo 'Curl Err [' . $error . '] : ' . $err_msg . "\n\n\n"; } } $this->writeToLog($data); if ($error != 0) { return true; } $this->ccClear(); return true; }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if (!function_exists('curl_init')) { $this->app->enqueueMessage('The iveri payment plugin needs the CURL library installed but it seems that it is not available on your server. Please contact your web hosting to set it up.', 'error'); $do = false; return false; } $this->ccLoad(); $address_type = 'billing_address'; $address1 = ''; $address2 = ''; $address3 = ''; if (!empty($order->cart->{$address_type}->address_street)) { if (strlen($order->cart->{$address_type}->address_street) > 20) { $address1 = substr($order->cart->{$address_type}->address_street, 0, 20); $address2 = @substr($order->cart->{$address_type}->address_street, 20, 20); $address3 = @substr($order->cart->{$address_type}->address_street, 40, 20); } else { $address1 = $order->cart->{$address_type}->address_street; } } $country_code_2 = @$order->cart->{$address_type}->address_country->zone_code_3; if (isset($order->order_id)) { $uuid = $order->order_id; } else { $uuid = uniqid(''); } $this->appId = '{' . trim($this->payment_params->applicationid, " {}\t\r\n") . '}'; $prefix = empty($this->payment_params->invoice_prefix) ? 'inv' : $this->payment_params->invoice_prefix; $amount = (int) round($order->cart->full_total->prices[0]->price_value_with_tax * 100); $vars = array('Lite_Version' => '2.0', 'Lite_Merchant_ApplicationId' => $this->appId, 'Lite_Order_Amount' => $amount, 'Lite_Order_Terminal' => 'web', 'Lite_Website_Successful_Url' => 'http://127.0.0.1/success', 'Lite_Website_Fail_Url' => 'http://127.0.0.1/fail', 'Lite_Website_TryLater_Url' => 'http://127.0.0.1/trylater', 'Lite_Website_Error_Url' => 'http://127.0.0.1/error', 'Lite_Order_LineItems_Product_1' => 'Your order', 'Lite_Order_LineItems_Amount_1' => $amount, 'Lite_Order_LineItems_Quantity_1' => 1, 'Lite_ConsumerOrderID_PreFix' => $prefix, 'Lite_Authorisation' => 'false', 'Ecom_TransactionComplete' => 'false', 'Ecom_SchemaVersion' => '', 'Ecom_Payment_Card_Protocols' => 'iVeri', 'Ecom_Payment_Card_StartDate_Day' => '00', 'Ecom_Payment_Card_StartDate_Month' => '04', 'Ecom_Payment_Card_StartDate_Year' => '2000', 'Ecom_Payment_Card_ExpDate_Day' => '00', 'Ecom_BillTo_Postal_Name_First' => substr(@$order->cart->{$address_type}->address_firstname, 0, 20), 'Ecom_BillTo_Postal_Name_Last' => substr(@$order->cart->{$address_type}->address_lastname, 0, 20), 'Ecom_BillTo_Postal_Street_Line1' => $address1, 'Ecom_BillTo_Postal_Street_Line2' => $address2, 'Ecom_BillTo_Postal_Street_Line3' => $address3, 'Ecom_BillTo_Postal_City' => substr(@$order->cart->{$address_type}->address_city, 0, 22), 'Ecom_BillTo_Postal_PostalCode' => substr(@$order->cart->{$address_type}->address_post_code, 0, 20), 'Ecom_BillTo_Postal_CountryCode' => @$order->cart->{$address_type}->address_country->zone_code_2, 'Ecom_BillTo_Online_Email' => substr($this->user->user_email, 0, 40), 'Ecom_ShipTo_Postal_Name_First' => substr(@$order->cart->{$address_type}->address_firstname, 0, 20), 'Ecom_ShipTo_Postal_Name_Last' => substr(@$order->cart->{$address_type}->address_firstname, 0, 20), 'Ecom_ShipTo_Postal_Street_Line1' => $address1, 'Ecom_ShipTo_Postal_Street_Line2' => $address2, 'Ecom_ShipTo_Postal_Street_Line3' => $address3, 'Ecom_ShipTo_Postal_City' => substr(@$order->cart->{$address_type}->address_city, 0, 22), 'Ecom_ShipTo_Postal_PostalCode' => substr(@$order->cart->{$address_type}->address_post_code, 0, 14), 'Ecom_ShipTo_Postal_CountryCode' => @$order->cart->{$address_type}->address_country->zone_code_2, 'Ecom_Payment_Card_Name' => $this->cc_owner, 'Ecom_Payment_Card_Number' => $this->cc_number, 'Ecom_Payment_Card_Verification' => @$this->cc_CCV, 'Ecom_Payment_Card_ExpDate_Month' => $this->cc_month, 'Ecom_Payment_Card_ExpDate_Year' => $this->cc_year, 'Ecom_ConsumerOrderID' => $uuid); $session = curl_init(); curl_setopt($session, CURLOPT_FRESH_CONNECT, true); curl_setopt($session, CURLOPT_HEADER, 0); curl_setopt($session, CURLOPT_POST, 1); curl_setopt($session, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($session, CURLOPT_FAILONERROR, true); curl_setopt($session, CURLOPT_RETURNTRANSFER, 1); curl_setopt($session, CURLOPT_COOKIEFILE, ""); curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($session, CURLOPT_SSL_VERIFYHOST, false); $httpsHikashop = str_replace('http://', 'https://', HIKASHOP_LIVE); $domain = $this->payment_params->domain; $url = '/Lite/Transactions/New/Authorise.aspx'; curl_setopt($session, CURLOPT_URL, 'https://' . $domain . $url); curl_setopt($session, CURLOPT_REFERER, $httpsHikashop); curl_setopt($session, CURLOPT_POSTFIELDS, $vars); $result = curl_exec($session); $error = curl_error($session); $inputs = $this->getHiddenInputValues($result, true); if (!empty($error) || !isset($inputs['__viewstate'])) { $this->app->enqueueMessage('Error while connecting to the Payment Gateway.'); $do = false; } else { $inputs = $this->getHiddenInputValues($result); curl_setopt($session, CURLOPT_REFERER, 'https://' . $domain . $url); curl_setopt($session, CURLOPT_POSTFIELDS, $inputs); $result = curl_exec($session); $error = curl_error($session); $inputs = $this->getHiddenInputValues($result, true); if (empty($error) && isset($inputs['lite_payment_card_status'])) { $err = $inputs['lite_payment_card_status']; if ($err == 0) { $this->modifyOrder($order, $this->payment_params->verified_status, true, true); } else { if ($err == 1 || $err == 2 || $err == 5 || $err == 9) { $this->app->enqueueMessage('The transaction could not be processed.'); $do = false; } else { if ($err == 14) { $this->app->enqueueMessage('Invalid card number.'); $do = false; } else { if ($err == 255) { $this->app->enqueueMessage('The transaction could not be processed due incorrect or missing information.'); $do = false; } else { $this->app->enqueueMessage('The transaction has been declined.'); $do = false; } } } } } else { $this->app->enqueueMessage('An error occurred.'); $do = false; } } curl_close($session); $this->ccClear(); return true; }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } $this->ccLoad(); $amount = round($order->cart->full_total->prices[0]->price_value_with_tax, (int) $this->currency->currency_locale['int_frac_digits']); $vars = array('USER' => $this->payment_params->login, 'PWD' => $this->payment_params->password, 'SIGNATURE' => $this->payment_params->signature, 'VERSION' => '51.0', 'METHOD' => 'DoDirectPayment', 'PAYMENTACTION' => $this->payment_params->instant_capture ? 'Sale' : 'Authorization', 'AMT' => $amount, 'ACCT' => $this->cc_number, 'EXPDATE' => $this->cc_month . '20' . $this->cc_year, 'FIRSTNAME' => $order->cart->billing_address->address_firstname, 'LASTNAME' => $order->cart->billing_address->address_lastname, 'CURRENCYCODE' => $this->currency->currency_code, 'EMAIL' => $this->user->user_email, 'STREET' => @$order->cart->billing_address->address_street, 'STREET2' => @$order->cart->billing_address->address_street2, 'CITY' => @$order->cart->billing_address->address_city, 'STATE' => @$order->cart->billing_address->address_state->zone_name, 'COUNTRYCODE' => @$order->cart->billing_address->address_country->zone_code_2, 'ZIP' => @$order->cart->billing_address->address_post_code, 'BUTTONSOURCE' => 'HikariSoftware_Cart_DP'); if (@$this->payment_params->send_order_id) { $database = JFactory::getDBO(); $database->setQuery('SELECT MAX(order_id) FROM #__hikashop_order;'); $max = (int) $database->loadResult(); $vars['INVNUM'] = $max + 1; } if (!empty($order->cart->billing_address->address_street2)) { $vars['STREET2'] = substr($order->cart->billing_address->address_street2, 0, 99); } if (!empty($order->cart->shipping_address)) { $vars['SHIPTONAME'] = @$order->cart->shipping_address->address_firstname . ' ' . @$order->cart->shipping_address->address_lastname; $vars['SHIPTOSTREET'] = @$order->cart->shipping_address->address_street; $vars['SHIPTOSTREET2'] = @$order->cart->shipping_address->address_street2; $vars['SHIPTOCITY'] = @$order->cart->shipping_address->address_city; if (in_array(@$order->cart->shipping_address->address_country->zone_code_2, array('US'))) { $vars['SHIPTOSTATE'] = @$order->cart->shipping_address->address_state->zone_code_3; } else { $vars['SHIPTOSTATE'] = @$order->cart->shipping_address->address_state->zone_name; } $vars['SHIPTOCOUNTRY'] = @$order->cart->shipping_address->address_country->zone_code_2; $vars['SHIPTOZIP'] = @$order->cart->shipping_address->address_post_code; $vars['SHIPTOPHONENUM'] = @$order->cart->shipping_address->address_phone; } if (!isset($this->payment_params->details)) { $this->payment_params->details = 1; } if (!empty($this->payment_params->details)) { $i = 1; $tax = 0; $config =& hikashop_config(); $group = $config->get('group_options', 0); foreach ($order->cart->products as $product) { if ($group && $product->order_product_option_parent_id) { continue; } if ($product->order_product_quantity < 1) { continue; } $vars["L_NAME" . $i] = substr(strip_tags($product->order_product_name), 0, 127); $vars["L_NUMBER" . $i] = $product->order_product_code; $vars["L_AMT" . $i] = round($product->order_product_price, (int) $this->currency->currency_locale['int_frac_digits']); $vars["L_QTY" . $i] = $product->order_product_quantity; $vars["L_TAXAMT" . $i] = round($product->order_product_tax, (int) $this->currency->currency_locale['int_frac_digits']); $tax += round($product->order_product_tax, (int) $this->currency->currency_locale['int_frac_digits']) * $product->order_product_quantity; $i++; } if (bccomp($tax, 0, 5)) { $vars['TAXAMT'] = round($tax + $order->order_shipping_tax + $order->order_payment_tax - $order->order_discount_tax, (int) $this->currency->currency_locale['int_frac_digits']); } if (!empty($order->cart->coupon)) { $vars["SHIPDISCAMT"] = round($order->order_discount_price, (int) $this->currency->currency_locale['int_frac_digits']); } if (!empty($order->order_payment_price) && bccomp($order->order_payment_price, 0, 5)) { $vars["L_NAME" . $i] = JText::_('HIKASHOP_PAYMENT'); $vars["L_NUMBER" . $i] = 'payment'; $vars["L_AMT" . $i] = round($order->order_payment_price - $order->order_payment_tax, (int) $this->currency->currency_locale['int_frac_digits']); $vars["L_QTY" . $i] = 1; $vars["L_TAXAMT" . $i] = round($order->order_payment_tax, (int) $this->currency->currency_locale['int_frac_digits']); $i++; } if (!empty($order->order_shipping_price) && bccomp($order->order_shipping_price, 0, 5)) { $vars['SHIPPINGAMT'] = round($order->order_shipping_price, (int) $this->currency->currency_locale['int_frac_digits']); } $vars['ITEMAMT'] = $vars['AMT'] - (@$vars['TAXAMT'] + @$vars['SHIPPINGAMT']); } if ($this->payment_params->ask_ccv) { $vars['CVV2'] = $this->cc_CCV; } if ($this->payment_params->debug) { echo print_r($vars, true) . "\n\n\n"; } $session = curl_init(); curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($session, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($session, CURLOPT_POST, 1); curl_setopt($session, CURLOPT_RETURNTRANSFER, 1); curl_setopt($session, CURLOPT_VERBOSE, 1); curl_setopt($session, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($session, CURLOPT_FAILONERROR, true); $httpsHikashop = str_replace('http://', 'https://', HIKASHOP_LIVE); $url = 'api-3t.paypal.com/nvp'; if ($this->payment_params->environnement != 'production') { $url = 'api-3t.' . $this->payment_params->environnement . '.paypal.com/nvp'; } if ($this->payment_params->debug) { echo print_r($url, true) . "\n\n\n"; } $tmp = array(); foreach ($vars as $k => $v) { $tmp[] = $k . '=' . urlencode(trim($v)); } $tmp = implode('&', $tmp); curl_setopt($session, CURLOPT_URL, 'https://' . $url); curl_setopt($session, CURLOPT_REFERER, $httpsHikashop); curl_setopt($session, CURLOPT_POSTFIELDS, $tmp); $ret = curl_exec($session); $error = curl_errno($session); if (!$error) { $params = explode('&', $ret); $ret = array(); foreach ($params as $p) { $t = explode('=', $p); $ret[strtoupper($t[0])] = $t[1]; } if ($this->payment_params->debug) { echo print_r($ret, true) . "\n\n\n"; } $responseCode = null; if (isset($ret['ACK'])) { $responseCode = strtoupper($ret['ACK']); } if (isset($responseCode)) { if ($responseCode == 'SUCCESS' || $responseCode == 'SUCCESSWITHWARNING') { $history = array('notified' => (int) @$this->payment_params->send_notification, 'data' => 'PayPal transaction id: ' . $ret['TRANSACTIONID']); $this->modifyOrder($order, $this->payment_params->verified_status, $history, true); } else { $message = 'Error'; if (!empty($ret['ERRORCODE'])) { $message .= ' ' . $ret['ERRORCODE']; } elseif (!empty($ret['L_ERRORCODE0'])) { $message .= ' ' . $ret['L_ERRORCODE0']; } if (!empty($ret['LONGMESSAGE'])) { $message .= ': ' . urldecode($ret['LONGMESSAGE']); } elseif (!empty($ret['L_LONGMESSAGE0'])) { $message .= ': ' . urldecode($ret['L_LONGMESSAGE0']); } $this->app->enqueueMessage($message); $do = false; } } else { $this->app->enqueueMessage('An error occurred. No response code in PayPal Pro server\'s response'); $do = false; } } else { $this->app->enqueueMessage('An error occurred. The connection to the PayPal Pro server could not be established: ' . curl_error($session)); $do = false; } curl_close($session); $this->ccClear(); return true; }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } $this->ccLoad(); ob_start(); $dbg = ''; $uuid = uniqid(''); $amount = number_format($order->cart->full_total->prices[0]->price_value_with_tax, 2, '.', ''); $vars = array("dc_logon" => $this->payment_params->login, "dc_password" => $this->payment_params->password, "dc_version" => "1.2", "dc_transaction_type" => "AUTHORIZATION_CAPTURE", "dc_transaction_amount" => $amount, "dc_address" => @$order->cart->billing_address->address_street, "dc_city" => @$order->cart->billing_address->address_city, "dc_state" => @$order->cart->billing_address->address_state->zone_name, "dc_zipcode" => @$order->cart->billing_address->address_post_code, "dc_name" => $this->cc_owner, "dc_number" => $this->cc_number, "dc_expiration_month" => $this->cc_month, "dc_expiration_year" => $this->cc_year, "dc_verification_number" => $this->cc_CCV, "dc_schedule_create" => '', "dc_schedule_limit" => '', "dc_schedule_periodic_number" => '', "dc_schedule_periodic_type" => '', "dc_schedule_start" => '', "dc_transaction_id" => ''); if ($this->payment_params->security) { $vars['dc_security'] = $this->payment_params->security_avs . '|' . ($this->payment_params->security_cvv ? 'M' : 'I') . '|' . ($this->payment_params->security_preauth ? 'true' : 'false') . '|' . ($this->payment_params->security_avsforce ? 'true' : 'false') . '|' . ($this->payment_params->security_cvvforce ? 'true' : 'false'); } $tmp = array(); foreach ($vars as $k => $v) { $tmp[] = $k . '=' . urlencode(trim($v)); } $vars = implode('&', $tmp); $session = curl_init(); curl_setopt($session, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($session, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($session, CURLOPT_POST, 1); curl_setopt($session, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($session, CURLOPT_RETURNTRANSFER, 1); $httpsHikashop = str_replace('http://', 'https://', HIKASHOP_LIVE); $domain = $this->payment_params->domain; $url = '/quick_link'; curl_setopt($session, CURLOPT_URL, 'https://' . $domain . $url); curl_setopt($session, CURLOPT_POSTFIELDS, $vars); $ret = curl_exec($session); $error = curl_errno($session); $err_msg = curl_error($session); curl_close($session); if (!empty($ret)) { $ret = explode(chr(28), $ret); $result = array(); if (is_array($ret)) { foreach ($ret as $kv) { list($k, $v) = explode("=", $kv); $result[$k] = $v; } } if ($this->payment_params->debug) { echo print_r($result, true) . "\n\n\n"; } if (isset($result['dc_response_code'])) { $rc = $result['dc_response_code']; if ($rc == '00' || $rc == '85') { $do = true; $dbg .= ob_get_clean(); if (!empty($dbg)) { $dbg .= "\r\n"; } ob_start(); $history = new stdClass(); $history->notified = 0; $history->amount = $amount . $this->accepted_currencies[0]; $history->data = $dbg . 'Authorization Code: ' . @$result['dc_approval_code'] . "\r\n" . 'Transaction ID: ' . @$result['dc_transaction_id']; $this->modifyOrder($order, $this->payment_params->verified_status, $history, true); } else { if (isset($this->error_msg[$rc])) { $this->app->enqueueMessage($this->error_msg[$rc]); } else { $this->app->enqueueMessage('Error'); } if (isset($result['dc_response_message'])) { $this->app->enqueueMessage($result['dc_response_message']); } $do = false; } } else { $this->app->enqueueMessage('An error occurred.'); $do = false; } } else { $do = false; } if ($error != 0) { $this->app->enqueueMessage('There was an error during the connection with the PayJunction payment gateway'); if ($this->payment_params->debug) { echo 'Curl Err [' . $error . '] : ' . $err_msg . "\n\n\n"; } } $dbg .= ob_get_clean(); $this->writeToLog($dbg); if ($error != 0) { return true; } $this->ccClear(); return true; }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if (!function_exists('curl_init')) { $this->app->enqueueMessage('The First Data payment plugin needs the CURL library installed but it seems that it is not available on your server. Please contact your web hosting to set it up.', 'error'); return false; } $this->ccLoad(); ob_start(); $dbg = ''; $amount = number_format($order->cart->full_total->prices[0]->price_value_with_tax, 2, '.', ''); $vars = '<' . '?xml version="1.0" encoding="UTF-8"?' . '>' . "\r\n" . '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header /><SOAP-ENV:Body>'; $vars .= '<fdggwsapi:FDGGWSApiOrderRequest xmlns:v1="http://secure.linkpt.net/fdggwsapi/schemas_us/v1" xmlns:fdggwsapi="http://secure.linkpt.net/fdggwsapi/schemas_us/fdggwsapi">'; $vars .= '<v1:Transaction><v1:CreditCardTxType><v1:Type>sale</v1:Type></v1:CreditCardTxType><v1:CreditCardData><v1:CardNumber>'; $vars .= $this->cc_number; $vars .= '</v1:CardNumber><v1:ExpMonth>' . $this->cc_month . '</v1:ExpMonth>'; $vars .= '<v1:ExpYear>' . substr($this->cc_year, -2) . '</v1:ExpYear>'; if ($this->payment_params->ask_ccv) { $vars .= '<v1:CardCodeValue>' . $this->cc_CCV . '</v1:CardCodeValue>'; } $vars .= '</v1:CreditCardData><v1:Payment><v1:ChargeTotal>' . $amount . '</v1:ChargeTotal></v1:Payment>'; $vars .= '<v1:TransactionDetails><v1:UserID>' . $this->user->user_id . '</v1:UserID></v1:TransactionDetails>'; $vars .= '<v1:Billing><v1:Name>' . $this->cc_owner . '</v1:Name><v1:Address1>' . @$order->cart->billing_address->address_street . '</v1:Address1><v1:City>' . @$order->cart->billing_address->address_city . '</v1:City><v1:State>' . @$order->cart->billing_address->address_state->zone_name . '</v1:State><v1:Zip>' . @$order->cart->billing_address->address_post_code . '</v1:Zip><v1:Country>' . @$order->cart->billing_address->address_country->zone_name . '</v1:Country></v1:Billing>'; $vars .= '</v1:Transaction></fdggwsapi:FDGGWSApiOrderRequest>'; $vars .= '</SOAP-ENV:Body></SOAP-ENV:Envelope>'; $credentials = 'WS' . $this->payment_params->login . '._.1:' . $this->payment_params->password; $httpsHikashop = str_replace('http://', 'https://', HIKASHOP_LIVE); $domain = rtrim($this->payment_params->domain, '/'); // ws.firstdataglobalgateway.com $url = '/fdggwsapi/services/order.wsdl'; $session = curl_init('https://' . $domain . $url); curl_setopt($session, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($session, CURLOPT_VERBOSE, 1); curl_setopt($session, CURLOPT_POST, 1); curl_setopt($session, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); curl_setopt($session, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($session, CURLOPT_USERPWD, $credentials); curl_setopt($session, CURLOPT_POSTFIELDS, $vars); curl_setopt($session, CURLOPT_RETURNTRANSFER, 1); curl_setopt($session, CURLOPT_SSLCERT, $this->payment_params->pem_file); curl_setopt($session, CURLOPT_SSLKEY, $this->payment_params->key_file); curl_setopt($session, CURLOPT_SSLKEYPASSWD, $this->payment_params->key_passwd); $ret = curl_exec($session); $error = curl_errno($session); $err_msg = curl_error($session); curl_close($session); if (!empty($ret)) { if ($this->payment_params->debug) { echo print_r($ret, true) . "\n\n\n"; } $result = 0; if (strpos($ret, '<fdggwsapi:FDGGWSApiOrderResponse') !== false) { $result = 1; if (preg_match('#<fdggwsapi:TransactionResult>(.*)</fdggwsapi:TransactionResult>#iU', $ret, $res)) { $resultMsg = strtoupper(trim($res[1])); if ($resultMsg == 'APPROVED') { $result = 2; } } if ($result) { if (preg_match('#<fdggwsapi:TransactionID>(.*)</fdggwsapi:TransactionID>#iU', $ret, $res)) { $transactionId = trim($res[1]); } if (preg_match('#<fdggwsapi:ApprovalCode>(.*)</fdggwsapi:ApprovalCode>#iU', $ret, $res)) { $approvalCode = trim($res[1]); } } if (preg_match('#<fdggwsapi:ErrorMessage>(.*)</fdggwsapi:ErrorMessage>#iU', $ret, $res)) { $errorMsg = trim($res[1]); } if (preg_match('#<fdggwsapi:AuthenticationResponseCode>(.*)</fdggwsapi:AuthenticationResponseCode>#iU', $ret, $res)) { $responseMsg = trim($res[1]); } } if ($result > 0) { if ($result == 2) { $do = true; $dbg .= ob_get_clean(); if (!empty($dbg)) { $dbg .= "\r\n"; } ob_start(); $history = new stdClass(); $email = new stdClass(); $history->notified = 0; $history->amount = $amount . $this->accepted_currencies[0]; $history->data = $dbg . 'Authorization Code: ' . @$approvalCode . "\r\n" . 'Transaction ID: ' . @$transactionId; $order_status = $this->payment_params->verified_status; $order_text = "\r\n" . JText::sprintf('NOTIFICATION_OF_ORDER_ON_WEBSITE', '', HIKASHOP_LIVE); $order_text .= "\r\n" . str_replace('<br/>', "\r\n", JText::sprintf('ACCESS_ORDER_WITH_LINK', $url)); $email->subject = JText::sprintf('PAYMENT_NOTIFICATION', 'First Data', 'Accepted'); $email->body = str_replace('<br/>', "\r\n", JText::sprintf('PAYMENT_NOTIFICATION_STATUS', 'First Data', 'Accepted')) . ' ' . JText::sprintf('ORDER_STATUS_CHANGED', $order_status) . "\r\n\r\n" . $order_text; $this->modifyOrder($order, $order_status, $history, $email); } else { if (isset($responseMsg)) { $this->app->enqueueMessage($responseMsg); } else { $this->app->enqueueMessage('Error'); } if (isset($errorMsg)) { $this->app->enqueueMessage($errorMsg); } $do = false; } } else { $this->app->enqueueMessage('An error occurred.'); $do = false; } } else { $do = false; } if ($error != 0) { $this->app->enqueueMessage('There was an error during the connection with the First Data payment gateway'); if ($this->payment_params->debug) { $this->app->enqueueMessage('Curl Err [' . $error . '] : ' . $err_msg); } } $dbg .= ob_get_clean(); $this->writeToLog($dbg); if ($error != 0) { return true; } $this->ccClear(); return true; }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if (!function_exists('curl_init')) { $this->app->enqueueMessage('The eWay payment plugin needs the CURL library installed but it seems that it is not available on your server. Please contact your web hosting to set it up.', 'error'); return false; } $total = round($order->cart->full_total->prices[0]->price_value_with_tax, (int) $this->currency->currency_locale['int_frac_digits']) * 100; if ($this->payment_params->sandbox) { $this->app->enqueueMessage('NOTE : When you use the sandbox mode with a total amount with cents, your transaction will be declined!'); } require_once dirname(__FILE__) . DS . 'eway_lib.php'; if ($this->payment_params->sandbox) { $eway = new EwayPaymentLib('87654321', "https://www.eway.com.au/gateway_cvn/xmltest/testpage.asp"); } else { $eway = new EwayPaymentLib($this->payment_params->cust_id, 'https://www.eway.com.au/gateway_cvn/xmlpayment.asp'); } $eway->setCustomerInvoiceRef(uniqid("order_")); $eway->setTrxnNumber(uniqid("eway_")); $eway->setTotalAmount($total); $eway->setCustomerEmail($this->user->user_email); if (!empty($order->cart->shipping_address)) { $eway->setCustomerAddress(@$order->cart->shipping_address->address_street . ', ' . @$order->cart->shipping_address->address_city . ', ' . @$order->cart->shipping_address->address_state->zone_name_english); $eway->setCustomerPostcode(@$order->cart->shipping_address->address_post_code); $eway->setCustomerFirstname(@$order->cart->shipping_address->address_firstname); $eway->setCustomerLastname(@$order->cart->shipping_address->address_lastname); } elseif (!empty($order->cart->billing_address)) { $eway->setCustomerAddress(@$order->cart->billing_address->address_street . ', ' . @$order->cart->billing_address->address_city . ', ' . @$order->cart->billing_address->address_state->zone_name_english); $eway->setCustomerPostcode(@$order->cart->billing_address->address_post_code); $eway->setCustomerFirstname(@$order->cart->billing_address->address_firstname); $eway->setCustomerLastname(@$order->cart->billing_address->address_lastname); } $order_item_name = array(); foreach ($order->cart->products as $product) { $order_item_name[] = strip_tags($product->order_product_name); } $order_items = implode(' - ', $order_item_name); $eway->setCustomerInvoiceDescription($order_items); $this->ccLoad(); $eway->setCardHoldersName($this->cc_owner); $eway->setCardNumber($this->cc_number); $eway->setCardExpiryMonth($this->cc_month); $eway->setCardExpiryYear($this->cc_year); $eway->setCardCVN($this->cc_CCV); switch ($eway->doPayment()) { case EWAY_TRANSACTION_FAILED: $this->app->enqueueMessage('Your transaction was declined. Please reenter your credit card or another credit card information.'); $error = $eway->getErrorMessage(); if (!empty($error)) { $this->app->enqueueMessage($error); } $this->ccClear(); $do = false; break; case EWAY_TRANSACTION_UNKNOWN: default: $this->app->enqueueMessage('There was an error while processing your transaction: ' . $eway->getErrorMessage()); $this->ccClear(); $do = false; break; case EWAY_TRANSACTION_OK: $history = new stdClass(); $history->notified = 0; $history->amount = round($order->cart->full_total->prices[0]->price_value_with_tax, 2) . $this->currency->currency_code; $history->data = ''; $this->modifyOrder($order, $this->payment_params->verified_status, $history, true); break; } return true; }