function go_auth_capture($order, $payment_config) { $this->loginid = $payment_config['account']; $this->_key = $payment_config['key']; $this->order = $order; $return_array = array(); //pr($order);die(); $isrealcard = $this->validateCreditcard_number($order['card_num']); if ($isrealcard != 'This is a valid credit card number') { $return_array['return_code'] = 4; $return_array['reason_text'] = $isrealcard; return $return_array; } $a = new authorizenet_class(); if ($payment_config['used_mod'] == '0') { $a->change_mod('test'); } else { $a->change_mod('now'); } // You login using your login, login and tran_key, or login and password. It // varies depending on how your account is setup. // I believe the currently reccomended method is to use a tran_key and not // your account password. See the AIM documentation for additional information. $a->add_field('x_login', $this->loginid); $a->add_field('x_tran_key', $this->_key); //$a->add_field('x_password', 'CHANGE THIS TO YOUR PASSWORD'); $a->add_field('x_version', '3.1'); $a->add_field('x_type', 'AUTH_CAPTURE'); //AUTH_ONLY,CAPTURE_ONLY,CREDIT,PRIOR_AUTH_CAPTURE,AUTH_CAPTURE $a->add_field('x_test_request', 'TRUE'); // Just a test transaction $a->add_field('x_relay_response', 'FALSE'); // You *MUST* specify '|' as the delim char due to the way I wrote the class. // I will change this in future versions should I have time. But for now, just // make sure you include the following 3 lines of code when using this class. $a->add_field('x_delim_data', 'TRUE'); $a->add_field('x_delim_char', '|'); $a->add_field('x_encap_char', ''); // Setup fields for customer information. This would typically come from an // array of POST values froma secure HTTPS form. $a->add_field('x_first_name', $order['payerName']); $a->add_field('x_last_name', ''); $a->add_field('x_address', $order['payerAdderss']['address']); $a->add_field('x_state', $order['payerAdderss']['state']); $a->add_field('x_zip', $order['x_zip']); $a->add_field('x_country', $order['payerAdderss']['country']); $a->add_field('x_email', $order['payerEmail']); $a->add_field('x_phone', $order['payerPhone']); // Using credit card number '4007000000027' performs a successful test. This // allows you to test the behavior of your script should the transaction be // successful. If you want to test various failures, use '4222222222222' as // the credit card number and set the x_amount field to the value of the // Response Reason Code you want to test. // // For example, if you are checking for an invalid expiration date on the // card, you would have a condition such as: // if ($a->response['Response Reason Code'] == 7) ... (do something) // // Now, in order to cause the gateway to induce that error, you would have to // set x_card_num = '4222222222222' and x_amount = '7.00' // Setup fields for payment information $a->add_field('x_method', 'CC'); $a->add_field('x_card_num', $order['card_num']); //$a->add_field('x_card_num', '4007000000027'); // test successful visa //$a->add_field('x_card_num', '370000000000002'); // test successful american express //$a->add_field('x_card_num', '6011000000000012'); // test successful discover //$a->add_field('x_card_num', '5424000000000015'); // test successful mastercard // $a->add_field('x_card_num', '4222222222222'); // test failure card number $a->add_field('x_amount', number_format($order['amount'], 2)); $a->add_field('x_exp_date', $order['expDate']); // march of 2015/03/ //$a->add_field('x_card_code', $order['CAVV']); // Card CAVV Security code // Process the payment and output the results switch ($a->process()) { case 1: // Successs $return_array['return_code'] = 1; $return_array['Transaction ID'] = $a->get_response_transacton_id(); $return_array['reason_text'] = $a->get_response_reason_text(); break; case 2: // Declined $return_array['return_code'] = 2; $return_array['reason_text'] = $a->get_response_reason_text(); break; case 3: // Error $return_array['return_code'] = 3; $return_array['reason_text'] = $a->get_response_reason_text(); break; case 0: // Error $return_array['return_code'] = 0; $return_array['reason_text'] = $a->get_response_reason_text(); break; } // The following two functions are for debugging and learning the behavior // of authorize.net's response codes. They output nice tables containing // the data passed to and recieved from the gateway. //$a->dump_fields(); // outputs all the fields that we set //$a->dump_response(); // outputs the response from the payment gateway return $return_array; }
*/ global $General, $Cart; $paymentOpts = $General->get_payment_optins($_REQUEST['paymentmethod']); //$userInfo = $General->getLoginUserInfo(); global $userInfo; global $current_user, $orderNumber; $display_name = $current_user->data->display_name; if (is_array($current_user->data->user_address_info)) { $userInfo = $current_user->data->user_address_info; } $address = $userInfo['buser_add1'] . ', ' . $userInfo['buser_add2']; $taxable_amt_info = $General->get_tax_amount(); $taxable_amt = $taxable_amt_info[0]; $payable_amt = $General->get_payable_amount($_REQUEST['shippingmethod']); require_once TEMPLATEPATH . '/library/payment/authorizenet/authorizenet.class.php'; $a = new authorizenet_class(); // You login using your login, login and tran_key, or login and password. It // varies depending on how your account is setup. // I believe the currently reccomended method is to use a tran_key and not // your account password. See the AIM documentation for additional information. $a->add_field('x_login', $paymentOpts['loginid']); $a->add_field('x_tran_key', $paymentOpts['transkey']); //$a->add_field('x_password', 'CHANGE THIS TO YOUR PASSWORD'); $a->add_field('x_version', '3.1'); $a->add_field('x_type', 'AUTH_CAPTURE'); //$a->add_field('x_test_request', 'TRUE'); // Just a test transaction $a->add_field('x_relay_response', 'FALSE'); // You *MUST* specify '|' as the delim char due to the way I wrote the class. // I will change this in future versions should I have time. But for now, just // make sure you include the following 3 lines of code when using this class. $a->add_field('x_delim_data', 'TRUE');
function process_authorize($subscription, $item_id, $proc) { global $Itemid, $JLMS_DB, $JLMS_CONFIG; $params2 = new JLMSParameters($proc->params); $orderNumber = $item_id; //$params2->get( 'x_invoice_num' ); $orderDescr = $params2->get('x_description'); if (!$subscription->sub_name && count($subscription->subscriptions) && (strpos($params2->get('x_description'), '[sub]') !== false || strpos($params2->get('x_description'), '[SUB]') !== false)) { $subscr_ids = implode(',', $subscription->subscriptions); $query = "SELECT id, sub_name FROM #__lms_subscriptions WHERE id IN ({$subscr_ids})"; $JLMS_DB->SetQuery($query); $subs_names_list_db = $JLMS_DB->LoadObjectList(); //create item name from list of all subscriptions separated by comma, ordered as in cart $subs_names_list = array(); foreach ($subscription->subscriptions as $cart_sub_id) { foreach ($subs_names_list_db as $subname_item) { if ($subname_item->id == $cart_sub_id) { $subs_names_list[] = $subname_item->sub_name; break; } } } $subscription->sub_name = implode(', ', $subs_names_list); } $orderDescr = str_replace('[SUB]', $subscription->sub_name, $orderDescr); $orderDescr = str_replace('[sub]', $subscription->sub_name, $orderDescr); $a = new authorizenet_class(); //if ($params2->get('x_test_request') == "TRUE") $a->gateway_url = 'https://test.authorize.net/gateway/transact.dll'; $a->add_field('x_login', $params2->get('x_login')); $a->add_field('x_tran_key', $params2->get('x_tran_key')); $a->add_field('x_invoice_num', $orderNumber); $a->add_field('x_description', $orderDescr); $a->add_field('x_version', '3.1'); $a->add_field('x_type', 'AUTH_CAPTURE'); $a->add_field('x_test_request', $params2->get('x_test_request')); $a->add_field('x_relay_response', 'FALSE'); $a->add_field('x_delim_data', 'TRUE'); $a->add_field('x_delim_char', '|'); $a->add_field('x_encap_char', ''); $a->add_field('x_email_customer', $params2->get('x_email_customer')); $a->add_field('x_merchant_email', $params2->get('x_merchant_email')); $query = "SELECT user_id FROM `#__lms_payments` WHERE id = {$item_id}"; $JLMS_DB->setQuery($query); $user_id_of_payment = $JLMS_DB->LoadResult(); $user_id_of_payment = intval($user_id_of_payment); $a->add_field('x_first_name', mosGetParam($_POST, 'x_first_name', '')); $a->add_field('x_last_name', mosGetParam($_POST, 'x_last_name', '')); $a->add_field('x_cust_id', $user_id_of_payment); $a->add_field('x_address', mosGetParam($_POST, 'x_address', '')); $a->add_field('x_city', mosGetParam($_POST, 'x_city', '')); $a->add_field('x_state', mosGetParam($_POST, 'x_state', '')); $a->add_field('x_zip', mosGetParam($_POST, 'x_zip', '')); $a->add_field('x_country', mosGetParam($_POST, 'x_country', '')); $a->add_field('x_email', mosGetParam($_POST, 'x_email', '')); $a->add_field('x_phone', mosGetParam($_POST, 'x_phone', '')); $a->add_field('x_method', 'CC'); $a->add_field('x_card_num', mosGetParam($_POST, 'x_card_num', '')); $a->add_field('x_amount', number_format($subscription->price + $subscription->tax_amount, 2, '.', '')); $a->add_field('x_currency_code', $JLMS_CONFIG->get('jlms_cur_code')); $a->add_field('x_exp_date', mosGetParam($_POST, 'card_expirationMonth', '') . mosGetParam($_POST, 'card_expirationYear', '')); $a->add_field('x_card_code', mosGetParam($_POST, 'x_card_code', '')); switch ($a->process()) { case 1: // Successs //$payment_amount = ($subscription->price + $subscription->tax_amount); $payment_currency = $JLMS_CONFIG->get('jlms_cur_code'); $txn_id = $a->response['Transaction ID']; require_once _JOOMLMS_FRONT_HOME . '/includes/joomla_lms.subscription.lib.php'; //if (!jlms_check_payment_transaction(($payment_amount - $subscription->tax_amount), $item_id)) { die('Invalid payment amount'); } $payment_date = date('Y-m-d H:i:s'); $query = "SELECT status FROM `#__lms_payments` WHERE id = {$item_id} "; $JLMS_DB->setQuery($query); $prev_payment = $JLMS_DB->LoadResult(); jlms_update_payment($item_id, $txn_id, 'Completed', $payment_date, $subscription->tax_amount); if ($prev_payment == 'Completed') { } else { jlms_register_new_user($item_id); //TODO: generate invoice only if enabled JLMS_CART_generateinvoice($item_id, $params2); } setcookie('joomlalms_cart_contents', '', time() - 3600, '/'); /*SoulPowerUniversity_MOD*/ /* mail_notification($subscription); */ /*SoulPowerUniversity_MOD*/ if ($params2->get('return_url') == '') { $query = "SELECT b.course_id FROM `#__lms_payments` as a, `#__lms_subscriptions_courses` as b WHERE a.id = {$item_id} AND a.sub_id = b.sub_id "; $JLMS_DB->setQuery($query); $courses = $JLMS_DB->loadObjectList(); if (count($courses) == 1) { JLMSRedirect(sefRelToAbs("index.php?option=com_joomla_lms&task=details_course&id=" . $courses[0]->course_id . "&Itemid=" . $Itemid), $params2->get('success_message')); } else { JLMSRedirect(sefRelToAbs("index.php?option=com_joomla_lms&Itemid={$Itemid}"), $params2->get('success_message')); } } else { JLMSRedirect($params2->get('return_url')); } break; case 2: // Declined $error_text = str_replace(array("\r\n", "\r", "\n"), '\\n', $a->get_response_reason_text()); echo "<script> alert(\"" . addslashes($error_text) . "\"); window.history.go(-1); </script>\n"; exit; break; case 3: // Error $error_text = str_replace(array("\r\n", "\r", "\n"), '\\n', $a->get_response_reason_text()); echo "<script> alert(\"" . addslashes($error_text) . "\"); window.history.go(-1); </script>\n"; exit; break; } }
function geodir_payment_form_authorizenet($invoice_id) { global $wpdb; $invoice_info = geodir_get_invoice($invoice_id); $payable_amount = $invoice_info->paied_amount; $last_postid = $invoice_info->post_id; $post_title = $invoice_info->post_title; $paymentOpts = get_payment_options($invoice_info->paymentmethod); global $current_user; $display_name = $current_user->data->display_name; $user_email = $current_user->data->user_email; $user_phone = isset($current_user->data->user_phone) ? $current_user->data->user_phone : ''; require_once 'authorizenet/authorizenet.class.php'; // get current post status $postid = $last_postid; $current_post_status = get_post_status($postid); /* we can't set headers and then redirect ?> <div class="wrapper" > <div class="clearfix container_message"> <h1 class="head2"><?php echo AUTHORISE_NET_MSG;?></h1> </div> </div> <?php */ $a = new authorizenet_class(); if ($paymentOpts['payment_mode'] == 'sandbox') { $a->is_sandbox(); } // put api in sandbox mode /*You login using your login, login and tran_key, or login and password. It varies depending on how your account is setup. I believe the currently reccomended method is to use a tran_key and not your account password. See the AIM documentation for additional information.*/ $a->add_field('x_login', $paymentOpts['loginid']); $a->add_field('x_tran_key', $paymentOpts['transkey']); /*$a->add_field('x_password', 'CHANGE THIS TO YOUR PASSWORD');*/ $a->add_field('x_version', '3.1'); $a->add_field('x_type', 'AUTH_CAPTURE'); /*$a->add_field('x_test_request', 'TRUE'); Just a test transaction*/ $a->add_field('x_relay_response', 'FALSE'); /*You *MUST* specify '|' as the delim char due to the way I wrote the class. I will change this in future versions should I have time. But for now, just make sure you include the following 3 lines of code when using this class.*/ $a->add_field('x_delim_data', 'TRUE'); $a->add_field('x_delim_char', '|'); $a->add_field('x_encap_char', ''); /* Setup fields for customer information. This would typically come from an array of POST values froma secure HTTPS form.*/ $a->add_field('x_first_name', $display_name); $a->add_field('x_last_name', ''); /* $a->add_field('x_address', $address); $a->add_field('x_city', $userInfo['user_city']); $a->add_field('x_state', $userInfo['user_state']); $a->add_field('x_zip', $userInfo['user_postalcode']); $a->add_field('x_country', 'US'); $a->add_field('x_country', $userInfo['user_country']);*/ $a->add_field('x_email', $user_email); $a->add_field('x_phone', $user_phone); /* Using credit card number '4007000000027' performs a successful test. This allows you to test the behavior of your script should the transaction be successful. If you want to test various failures, use '4222222222222' as the credit card number and set the x_amount field to the value of the Response Reason Code you want to test. For example, if you are checking for an invalid expiration date on the card, you would have a condition such as: if ($a->response['Response Reason Code'] == 7) ... (do something) Now, in order to cause the gateway to induce that error, you would have to set x_card_num = '4222222222222' and x_amount = '7.00' Setup fields for payment information*/ //$a->add_field('x_method', $_REQUEST['cc_type']); $a->add_field('x_method', 'CC'); $a->add_field('x_card_num', $_REQUEST['cc_number']); /*$a->add_field('x_card_num', '4007000000027'); // test successful visa $a->add_field('x_card_num', '370000000000002'); // test successful american express $a->add_field('x_card_num', '6011000000000012'); // test successful discover $a->add_field('x_card_num', '5424000000000015'); // test successful mastercard $a->add_field('x_card_num', '4222222222222'); // test failure card number*/ $a->add_field('x_amount', $payable_amount); $a->add_field('x_exp_date', $_REQUEST['cc_month'] . substr($_REQUEST['cc_year'], 2, strlen($_REQUEST['cc_year']))); /* march of 2008*/ $a->add_field('x_card_code', $_REQUEST['cv2']); // Card CAVV Security code /* Process the payment and output the results*/ switch ($a->process()) { case 1: /* Successs */ // set post status $post_default_status = geodir_new_post_default_status(); if ($post_default_status == '') { $post_default_status = 'publish'; } geodir_set_post_status($last_postid, $post_default_status); // set invoice status $transaction_details = ''; $transaction_details .= "--------------------------------------------------<br />"; $transaction_details .= sprintf(__("Payment Details for Listing ID #%s", GEODIRPAYMENT_TEXTDOMAIN), $last_postid) . "<br />"; $transaction_details .= "--------------------------------------------------<br />"; $transaction_details .= sprintf(__("Listing Title: %s", GEODIRPAYMENT_TEXTDOMAIN), $post_title) . "<br />"; $transaction_details .= "--------------------------------------------------<br />"; $transaction_details .= sprintf(__("Trans ID: %s", GEODIRPAYMENT_TEXTDOMAIN), $a->response['Transaction ID']) . "<br />"; $transaction_details .= sprintf(__("Status: %s", GEODIRPAYMENT_TEXTDOMAIN), $a->response['Response Code']) . "<br />"; $transaction_details .= sprintf(__("Amount: %s", GEODIRPAYMENT_TEXTDOMAIN), $a->response['Amount']) . "<br />"; $transaction_details .= sprintf(__("Type: %s", GEODIRPAYMENT_TEXTDOMAIN), $a->response['Transaction Type']) . "<br />"; $transaction_details .= sprintf(__("Date: %s", GEODIRPAYMENT_TEXTDOMAIN), date("F j, Y, g:i a")) . "<br />"; $transaction_details .= sprintf(__(" Method: %s", GEODIRPAYMENT_TEXTDOMAIN), 'Authorize.net') . "<br />"; $transaction_details .= "--------------------------------------------------<br />"; $transaction_details .= __("Information Submitted URL", GEODIRPAYMENT_TEXTDOMAIN) . "<br />"; $transaction_details .= "--------------------------------------------------<br />"; $transaction_details .= " {$post_title}<br />"; // Extend expire date start $invoice_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . INVOICE_TABLE . " WHERE post_id = %d AND is_current=%s", array($postid, '1'))); $invoice_package_id = ''; if (!empty($invoice_info) && isset($invoice_info->package_id)) { $invoice_package_id = $invoice_info->package_id; $invoice_alive_days = $invoice_info->alive_days; $invoice_status = $invoice_info->status; } $geodir_post_info = geodir_get_post_info($postid); if (!empty($geodir_post_info)) { $post_package_id = $geodir_post_info->package_id; $post_expire_date = $geodir_post_info->expire_date; if (!empty($invoice_package_id) && $invoice_alive_days > 0 && $invoice_package_id == $post_package_id && strtolower($post_expire_date) != 'never' && strtotime($post_expire_date) >= strtotime(date('Y-m-d')) && $current_post_status == 'publish') { $alive_days = (int) ($geodir_post_info->alive_days + $invoice_alive_days); $expire_date = date('Y-m-d', strtotime($post_expire_date . "+" . $invoice_alive_days . " days")); } else { $alive_days = (int) $geodir_post_info->alive_days; if (strtolower($post_expire_date) != 'never' && strtotime($post_expire_date) < strtotime(date('Y-m-d'))) { $alive_days = $invoice_alive_days; } $expire_date = $alive_days > 0 ? date('Y-m-d', strtotime(date('Y-m-d') . "+" . $alive_days . " days")) : 'Never'; } geodir_save_post_meta($postid, 'alive_days', $alive_days); geodir_save_post_meta($postid, 'expire_date', $expire_date); } // Extend expire date start end // update invoice statuse and transactio details geodir_update_invoice_status($invoice_id, 'Paid'); geodir_update_invoice_transaction_details($invoice_id, $transaction_details); // send emails geodir_payment_adminEmail($last_postid, $current_user->ID, 'payment_success', $transaction_details); /*email to admin*/ geodir_payment_clientEmail($last_postid, $current_user->ID, 'payment_success', $transaction_details); /*email to client*/ //$redirectUrl = home_url()."/?ptype=payment_success&pid=".$last_postid; //wp_redirect($redirectUrl);exit; $redirect_url = geodir_getlink(home_url(), array('pay_action' => 'success', 'pid' => $last_postid), false); wp_redirect($redirect_url); exit; break; case 2: /* Declined */ $paymentFlag = 0; $_SESSION['display_message'] = $a->get_response_reason_text(); break; case 3: /* Error */ $paymentFlag = 0; /*echo "<b>Error with Transaction:</b><br>"; echo $a->get_response_reason_text(); echo "<br><br>Details of the transaction are shown below...<br><br>";*/ $_SESSION['display_message'] = $a->get_response_reason_text(); break; } //echo $a->get_response_reason_text(); //print_r($a); //exit; if ($paymentFlag == 0) { wp_redirect(home_url() . "/?pay_action=cancel&pmethod=authorizenet&err_msg=" . urlencode($a->get_response_reason_text())); exit; } }
public function processpayment() { switch ($_POST['payment_type']) { case "1": // Credit require_once 'class/authorizenet.class.php'; $a = new authorizenet_class(); $a->add_field('x_login', authnet_login); $a->add_field('x_tran_key', authnet_key); $a->add_field('x_version', '3.1'); $a->add_field('x_type', 'AUTH_CAPTURE'); if (authnet_testmode == "Yes") { $a->add_field('x_test_request', 'TRUE'); // Just a test transaction } $a->add_field('x_relay_response', 'FALSE'); $a->add_field('x_delim_data', 'TRUE'); $a->add_field('x_delim_char', '|'); $a->add_field('x_encap_char', ''); $a->add_field('x_email_customer', 'FALSE'); $a->add_field('x_description', "ATSL {$_POST['reservationID']}"); $a->add_field('x_method', 'CC'); $a->add_field('x_card_num', $_POST['cc_num']); // test successful visa $a->add_field('x_amount', $_POST['payment_amount']); $exp_date = $_POST['cc_month'] . $_POST['cc_year']; $a->add_field('x_exp_date', $exp_date); // march of 2008 $a->add_field('x_card_code', $_POST['cvv']); // Card CAVV Security code switch ($a->process()) { case 1: // Accepted // $a->get_response_reason_text(); $transactionID = $a->get_transaction_id(); $payment = $this->record_payment($transactionID); if ($payment == "TRUE") { $msg = "<font color=green>The payment of \${$_POST['payment_amount']} was processed.</font>"; } break; case 2: // Declined $msg = "<font color=red>" . $a->get_response_reason_text() . "</font>"; break; case 3: // Error $msg = "<font color=red>" . $a->get_response_reason_text() . "</font>"; break; } break; case "2": // Check $payment = $this->record_payment($null); if ($payment == "TRUE") { $msg = "<font color=green>The payment of \${$_POST['payment_amount']} was processed.</font>"; } break; case "3": // Wire $payment = $this->record_payment($null); if ($payment == "TRUE") { $msg = "<font color=green>The payment of \${$_POST['payment_amount']} was processed.</font>"; } break; } $template = "completepayment.tpl"; $data['reservationID'] = $_POST['reservationID']; if ($msg == "") { $msg = "<font color=red>There was an un-known error and the payment was not processed.</font>"; } $data['msg'] = $msg; $this->load_smarty($data, $template); }
$invoice = substr($subinv, 0, 20); if (phpversion() >= '5.1.2') { $fingerprint = hash_hmac("md5", $LID . "^" . $sequence . "^" . $timestamp . "^" . $pvalue . "^", $Key); } else { $fingerprint = bin2hex(mhash(MHASH_MD5, $LID . "^" . $sequence . "^" . $timestamp . "^" . $pvalue . "^", $Key)); } $md5hash = $secret . $LID . $invoice . $pvalue; $checkid = md5($md5hash); if (isset($_COOKIE['ap_id'])) { $_POST['affiliate'] = $_COOKIE['ap_id']; } orderhandle($_POST, $checkid); if (isset($_COOKIE['ap_id'])) { unset($_POST['affiliate']); } $p = new authorizenet_class(); $p->add_field('x_login', $LID); $p->add_field('x_amount', $pvalue); $p->add_field('x_description', $description); $p->add_field('x_invoice_num', $invoice); $p->add_field('x_fp_sequence', $sequence); $p->add_field('x_fp_timestamp', $timestamp); $p->add_field('x_fp_hash', $fingerprint); if ($eshopoptions['status'] == 'live') { $p->authorizenet_url = 'https://secure.authorize.net/gateway/transact.dll'; // authorizenet url } else { $p->authorizenet_url = 'https://secure.authorize.net/gateway/transact.dll'; // testing authorizenet url } //only reqd for the developer
function authorize_refund($params) { global $CONFIG; $auth = new authorizenet_class(); if ($params['testmode'] == "on") { $gateway_url = "https://secure.authorize.net/gateway/transact.dll"; } else { $gateway_url = "https://secure.authorize.net/gateway/transact.dll"; } $auth->seturl($gateway_url); $auth->add_field("x_login", $params['loginid']); $auth->add_field("x_tran_key", $params['transkey']); $auth->add_field("x_version", "3.1"); $auth->add_field("x_type", "CREDIT"); if ($params['testmode'] == "on") { $auth->add_field("x_test_request", "TRUE"); } $auth->add_field("x_relay_response", "FALSE"); $auth->add_field("x_delim_data", "TRUE"); $auth->add_field("x_delim_char", "|"); $auth->add_field("x_encap_char", ""); $auth->add_field("x_invoice_num", $params['invoiceid']); $auth->add_field("x_description", $CONFIG['CompanyName'] . " Invoice #" . $params['invoiceid']); $auth->add_field("x_first_name", $params['clientdetails']['firstname']); $auth->add_field("x_last_name", $params['clientdetails']['lastname']); $auth->add_field("x_address", $params['clientdetails']['address1']); $auth->add_field("x_city", $params['clientdetails']['city']); $auth->add_field("x_state", $params['clientdetails']['state']); $auth->add_field("x_zip", $params['clientdetails']['postcode']); $auth->add_field("x_country", $params['clientdetails']['country']); $auth->add_field("x_phone", $params['clientdetails']['phonenumber']); $auth->add_field("x_email", $params['clientdetails']['email']); $auth->add_field("x_email_customer", "FALSE"); $auth->add_field("x_method", "CC"); $auth->add_field("x_card_num", $params['cardnum']); $auth->add_field("x_amount", $params['amount']); $auth->add_field("x_exp_date", $params['cardexp']); $auth->add_field("x_card_code", $params['cccvv']); $auth->add_field("x_trans_id", $params['transid']); switch ($auth->process()) { case 1: array("status" => "success", "transid" => $auth->response["Transaction ID"], "rawdata" => $auth->dump_response()); } return; }
/** * This function is used for payment for authorizenet for guest user * * * @return string */ function doPaymentForAuthorizenet() { if ($_SESSION['user_id'] != '') { // print_r($_POST);exit; $ccardno = $_POST['txtCardNumber']; $ccardexpry = $_POST['txt_cem'] . $_POST['txt_cey']; $cardcode = $_POST['cardcode']; require_once 'classes/Lib/authorizenet.class.php'; // echo "dfgsdf";exit; $qryuser = new Bin_Query(); $sqluser = "******"; $qryuser->executeQuery($sqluser); $records = $qryuser->records; $paym_login = $qryuser->records[0]['merchant_id']; $a = new authorizenet_class(); $a->add_field('x_login', '56wsTkC6M'); $a->add_field('x_tran_key', '99A47gGGN76mnsuA'); $a->add_field('x_version', '3.1'); $a->add_field('x_type', 'AUTH_CAPTURE'); $a->add_field('x_relay_response', 'FALSE'); $a->add_field('x_delim_data', 'TRUE'); $a->add_field('x_delim_char', '|'); $a->add_field('x_encap_char', ''); $a->add_field('x_method', 'CC'); $a->add_field('x_card_num', $ccardno); //card number $a->add_field('x_amount', $_SESSION['checkout_amount']); $a->add_field('x_exp_date', $ccardexpry); //expiry date $a->add_field('x_card_code', $_POST['cardcode']); //card code // $res = $a->process(); // echo "<Pre>";print_r($a);exit; if ($a) { // echo "success";exit; header('Location:?do=paymentgateway&action=success&pay_type=5'); } else { // echo "failed";exit; header('Location:?do=paymentgateway&action=failure'); } // echo"<Pre>";print_r($a);exit; } }