:
:  
:
'. $designBox .''; PageCode(); exit(); } elseif ( $providerConf['Param_implementation'] == 'SIM' ) { $actionURL = 'https://secure.authorize.net/gateway/transact.dll'; $formData = array(); $timestamp = time(); srand( $timestamp ); $sequence = rand(1, 1000); // account ID $formData['x_login'] = $providerConf['Param_x_login']; $formData['x_fp_sequence'] = $sequence; $formData['x_fp_timestamp'] = $timestamp; $formData['x_fp_hash'] = calculateFingerPrint( $timestamp, $sequence, $tranArr['Amount'], $currency_code ); // transaction common data $formData['x_method'] = 'CC'; $formData['x_type'] = 'AUTH_CAPTURE'; $formData['x_amount'] = sprintf( "%.2f", (float)$tranArr['Amount'] ); $formData['x_description'] = $tranArr['Description']; $formData['x_invoice_num'] = $localTranID; $formData['x_version'] = '3.1'; $formData['x_show_form'] = 'PAYMENT_FORM'; $formData['x_relay_response'] = 'TRUE'; $formData['x_email_customer'] = 'FALSE'; $formData['x_cust_id'] = $memberID; // return and redirect $formData['x_relay_url'] = $checkoutURL; // test mode $formData['x_test_request'] = ($providerConf['Mode'] == 'live' ? 'FALSE' : 'TRUE'); Redirect($actionURL, $formData, 'post', $providerConf['Caption']); exit(); } } /** * Performs server side call payment processing * * @param bool $subscribe - indicates if payment is subcriptional payment * @param int $newTrandID - if payment subscriptional, then $newTrandID specfies * new transaction ID created by script * * @return bool - true if payment is successful, false otherwise * * */ function moduleAcceptPayment( $subscribe, $newTrandID = 0 ) { global $providerConf; global $date_format; $errorMessage = ''; if ( $providerConf['Debug'] ) { writeDebugLog( 'Payment event', 'Payment start', false ); } if ( $providerConf['Param_implementation'] == 'AIM' ) { if ( !isset($_POST['send_data']) || !isset($_POST['auth_card_num']) || !isset($_POST['auth_tran_id']) ) { PrintErrorPage( _t('_no data given') ); return false; } $transactionData = $_POST; if ( !validateCheckoutData($transactionData) ) { PrintErrorPage( _t('_no data given') ); return false; } $localTranID = (int)$transactionData['auth_tran_id']; $tranRes = db_res( "SELECT DATE_FORMAT(`Date`, '$date_format' ) AS 'Date', `Amount`, `Currency`, `Status`, `Data`, `Description` FROM `Transactions` WHERE `ID` = {$localTranID} AND `Status` = 'pending' AND `IDProvider` = {$providerConf['ID']}" ); if ( !$tranRes || mysql_num_rows($tranRes) == 0 ) return false; $tranArr = mysql_fetch_assoc($tranRes); $tranData = transStringToData( $tranArr['Data'] ); $postURL = 'https://secure.authorize.net/gateway/transact.dll'; $postParameters = "x_login={$providerConf['Param_x_login']}"; $postParameters .= "&x_tran_key={$providerConf['Param_x_tran_key']}"; $postParameters .= "&x_version=3.1"; $postParameters .= "&x_method=CC"; $postParameters .= "&x_type=AUTH_CAPTURE"; $postParameters .= "&x_amount=" . sprintf( "%.2f", (float)$tranArr['Amount'] ); $postParameters .= "&x_invoice_num={$localTranID}"; $postParameters .= "&x_description={$tranArr['Description']}"; $postParameters .= "&x_relay_response=FALSE"; $postParameters .= "&x_email_customer=FALSE"; $postParameters .= "&x_delim_data=TRUE"; $postParameters .= "&x_delim_char={$providerConf['Param_x_delim_char']}"; $postParameters .= "&x_encap_char={$providerConf['Param_x_encap_char']}"; $postParameters .= "&x_card_num={$transactionData['auth_card_num']}"; $postParameters .= "&x_exp_date={$transactionData['auth_expire_month']}-{$transactionData['auth_expire_year']}"; $postParameters .= "&x_cust_id={$tranData['memberID']}"; $postParameters .= "&x_test_request=" . ($providerConf['Mode'] == 'live' ? 'FALSE' : 'TRUE'); $response = sendCurlRequest( $postURL, $postParameters ); if ( $providerConf['Debug'] ) { writeDebugLog( 'AIM request response', $response, false ); } $responseArr = explode( $providerConf['Param_x_delim_char'], $response ); $encapChar = $providerConf['Param_x_encap_char']; if ( $encapChar == '\'' || $encapChar == '\\' ) $encapChar = '\\' . $encapChar; array_walk( $responseArr, create_function('&$arg', "\$arg = trim(\$arg, '{$encapChar}');") ); $transactionData = $responseArr; $res = moduleValidateTransaction( $transactionData, $errorMessage ); $localTranID = (int)$transactionData[7]; if ( $res != 2 ) { finishTransaction( $localTranID, $transactionData[6], $res == 1 ); } if ( $res == 1 ) { $purchaseRes = purchaseTransaction( $localTranID, $res ); if ( !$purchaseRes ) { $errorMessage = 'Purchase failed'; $res = 0; } } processValidationResult( $res, $errorMessage, $localTranID ); return ( $res == 1 ); } elseif ( $providerConf['Param_implementation'] == 'SIM' ) { if ( !isset($_POST['x_response_code']) || !isset($_POST['x_invoice_num']) ) { PrintErrorPage( _t('_no data given') ); return false; } $transactionData = $_POST; $res = moduleValidateTransaction( $transactionData, $errorMessage ); $localTranID = (int)$transactionData['x_invoice_num']; if ( $res != 2 ) { finishTransaction( $localTranID, $transactionData['x_trans_id'], $res == 1 ); } if ( $res == 1 ) { $purchaseRes = purchaseTransaction( $localTranID, $res ); if ( !$purchaseRes ) { $errorMessage = 'Purchase failed'; $res = 0; } } processValidationResult( $res, $errorMessage, $localTranID ); return ( $res == 1 ); } return false; } if ( !defined('PAYMENT_MODULE_AS_HEADER') ) { $validateRes = moduleValidateConfiguration( $errorMessage ); if ( !$validateRes ) { PrintErrorPage( $errorMessage ); exit(); } if ( $providerConf['Debug'] ) { writeDebugLog( 'Authorize.net checkout external call', '--------------', true ); writeDebugLog( 'Conf', $providerConf, false ); writeDebugLog( 'GET', $_GET, false ); writeDebugLog( 'POST', $_POST, false ); } moduleAcceptPayment( false ); } ?>