Updates.
git-svn-id: http://svn.cleancode.org/svn/pickles@97 4d10bc64-7434-11dc-a737-d2d0f8310089
This commit is contained in:
parent
d3d994ba2c
commit
5cf2336459
6 changed files with 452 additions and 712 deletions
|
@ -18,7 +18,7 @@
|
|||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Joshua John Sherman <josh@phpwithpickles.org>
|
||||
* @copyright Copyright 2007, 2008 Joshua John Sherman
|
||||
* @copyright Copyright 2009 Joshua John Sherman
|
||||
* @link http://phpwithpickles.org
|
||||
* @license http://www.gnu.org/copyleft/lesser.html
|
||||
* @package PICKLES
|
||||
|
@ -28,650 +28,179 @@
|
|||
* Authorize.Net Advanced Integrated Method (AIM) Web Service
|
||||
*/
|
||||
class WebService_AuthorizeNet_AIM extends WebService_Common {
|
||||
|
||||
|
||||
private $url = 'https://test.authorize.net/gateway/transact.dll';
|
||||
// $auth_net_url = "https://secure.authorize.net/gateway/transact.dll";
|
||||
|
||||
private $response_variables = array(
|
||||
'response_code',
|
||||
'response_subcode',
|
||||
'response_reason_code',
|
||||
'response_reason_text',
|
||||
'authorization_code',
|
||||
'avs_response',
|
||||
'transaction_id',
|
||||
'invoice_number',
|
||||
'description',
|
||||
'amount',
|
||||
'method',
|
||||
'transaction_type',
|
||||
'customer_id',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'company',
|
||||
'address',
|
||||
'city',
|
||||
'state',
|
||||
'zip_code',
|
||||
'country',
|
||||
'phone',
|
||||
'fax',
|
||||
'email_address',
|
||||
'ship_to_first_name',
|
||||
'ship_to_last_name',
|
||||
'ship_to_company',
|
||||
'ship_to_address',
|
||||
'ship_to_city',
|
||||
'ship_to_state',
|
||||
'ship_to_zip_code',
|
||||
'ship_to_country',
|
||||
'tax',
|
||||
'duty',
|
||||
'feight',
|
||||
'tax_exempt',
|
||||
'purchase_order_number',
|
||||
'md5_hash',
|
||||
'card_code_response',
|
||||
'cardholder_authentication_verification_response',
|
||||
'reserved'
|
||||
);
|
||||
|
||||
public function process() {
|
||||
|
||||
// Once the user is customer and their addresses are added, perform the authenticate.net logic
|
||||
$debugging = 1; // Display additional information to track down problems
|
||||
$testing = 1; // Set the testing flag so that transactions are not live
|
||||
$error_retries = 2; // Number of transactions to post if soft errors occur
|
||||
$post_variables = array(
|
||||
'x_test_request' => 'TRUE',
|
||||
'x_invoice_num' => $this->order_id,
|
||||
'x_cust_id' => trim($this->customer_id) != '' ? $this->customer_id : 'N/A',
|
||||
'x_cust_up' => $this->customer_ip,
|
||||
'x_description' => 'Menopause Solutions',
|
||||
'x_login' => $this->config->gateway->authorizenet_aim->test->login,
|
||||
'x_version' => '3.1',
|
||||
'x_delim_char' => '|',
|
||||
'x_delim_data' => 'TRUE',
|
||||
'x_type' => 'AUTH_CAPTURE', // @todo let the user pass this in for more functionality
|
||||
'x_method' => 'CC',
|
||||
'x_tran_key' => $this->config->gateway->authorizenet_aim->test->transaction_key,
|
||||
'x_relay_response' => 'FALSE',
|
||||
|
||||
// @todo move to object variables
|
||||
$auth_net_url = "https://test.authorize.net/gateway/transact.dll";
|
||||
// Uncomment the line ABOVE for test accounts or BELOW for live merchant accounts
|
||||
// $auth_net_url = "https://secure.authorize.net/gateway/transact.dll";
|
||||
|
||||
$authnet_values = array(
|
||||
'x_invoice_num' => $this->order_id,
|
||||
'x_login' => $this->config->gateway->authorizenet_aim->test->login,
|
||||
'x_version' => '3.1',
|
||||
'x_delim_char' => '|',
|
||||
'x_delim_data' => 'TRUE',
|
||||
'x_type' => 'AUTH_CAPTURE',
|
||||
'x_method' => 'CC',
|
||||
'x_tran_key' => $this->config->gateway->authorizenet_aim->test->transaction_key,
|
||||
'x_relay_response' => 'FALSE',
|
||||
|
||||
'x_card_num' => $this->cc_number,
|
||||
'x_exp_date' => $this->expiration_month . $this->expiration_year,
|
||||
'x_description' => 'Menopause Solutions',
|
||||
'x_amount' => $this->total_amount,
|
||||
// Payment information
|
||||
'x_card_num' => $this->card_number,
|
||||
'x_exp_date' => $this->expiration_month . $this->expiration_year,
|
||||
'x_amount' => $this->total_amount,
|
||||
'x_freight' => 'Shipping<|>Standard<|>' . $this->shipping,
|
||||
|
||||
'x_company' => $this->billing_company,
|
||||
'x_first_name' => $this->billing_first_name,
|
||||
'x_last_name' => $this->billing_last_name,
|
||||
'x_address' => $this->billing_address1,
|
||||
'x_city' => $this->billing_city,
|
||||
'x_state' => $this->billing_state,
|
||||
'x_zip' => $this->billing_zip_code,
|
||||
'x_country' => $this->billing_country,
|
||||
'x_email' => $this->billing_email,
|
||||
'x_phone' => $this->billing_phone,
|
||||
'x_fax' => $this->billing_fax,
|
||||
// Billing address information
|
||||
'x_company' => $this->billing_company,
|
||||
'x_first_name' => $this->billing_first_name,
|
||||
'x_last_name' => $this->billing_last_name,
|
||||
'x_address' => $this->billing_address1,
|
||||
'x_city' => $this->billing_city,
|
||||
'x_state' => $this->billing_state,
|
||||
'x_zip' => $this->billing_zip_code,
|
||||
'x_country' => $this->billing_country,
|
||||
'x_email' => $this->billing_email,
|
||||
'x_phone' => $this->billing_phone,
|
||||
'x_fax' => $this->billing_fax,
|
||||
|
||||
'x_ship_to_company' => $this->shipping_company,
|
||||
'x_ship_to_first_name' => $this->shipping_first_name,
|
||||
'x_ship_to_last_name' => $this->shipping_last_name,
|
||||
'x_ship_to_address' => $this->shipping_address1,
|
||||
'x_ship_to_city' => $this->shipping_city,
|
||||
'x_ship_to_state' => $this->shipping_state,
|
||||
'x_ship_to_zip' => $this->shipping_zip_code,
|
||||
'x_ship_to_country' => $this->shipping_country,
|
||||
// Shipping address information
|
||||
'x_ship_to_company' => $this->shipping_company,
|
||||
'x_ship_to_first_name' => $this->shipping_first_name,
|
||||
'x_ship_to_last_name' => $this->shipping_last_name,
|
||||
'x_ship_to_address' => $this->shipping_address1,
|
||||
'x_ship_to_city' => $this->shipping_city,
|
||||
'x_ship_to_state' => $this->shipping_state,
|
||||
'x_ship_to_zip' => $this->shipping_zip_code,
|
||||
'x_ship_to_country' => $this->shipping_country,
|
||||
|
||||
// @todo
|
||||
'x_email' => 'joshsherman@gmail.com',
|
||||
// Order information
|
||||
// @todo I'd like to change the line item stuff to be part of the array and
|
||||
// then looped through pragmatically, opposed to tacking it all to the end
|
||||
// of the transaction (see below)
|
||||
//'x_line_item' => '',
|
||||
|
||||
// Email receipt information
|
||||
'x_email_customer' => true,
|
||||
'x_header_email_receipt' => 'header text',
|
||||
'x_footer_email_receipt' => 'footer text',
|
||||
|
||||
// 'x_tax' => '',
|
||||
// 'x_freight' => '',
|
||||
// @todo These currently aren't in use
|
||||
// 'x_tax' => '',
|
||||
// 'se_session_token' => '',
|
||||
// 'x_header_email_receipt' => '',
|
||||
// 'x_footer_email_receipt' => '',
|
||||
|
||||
// 'x_invoice_num' => '',
|
||||
// 'se_session_token' => '',
|
||||
// @todo Debugging / testing information
|
||||
'x_email' => 'joshsherman@gmail.com',
|
||||
'x_card_num' => '4242424242424242',
|
||||
);
|
||||
|
||||
// Assembles the POSTed fields
|
||||
$fields = '';
|
||||
foreach ($authnet_values as $key => $value) {
|
||||
$fields .= "{$key}=" . urlencode($value) . '&';
|
||||
foreach ($post_variables as $variable => $value) {
|
||||
$fields .= $variable . '=' . urlencode($value) . '&';
|
||||
}
|
||||
|
||||
// Post the transaction to Authorize.net
|
||||
$ch = curl_init("https://test.authorize.net/gateway/transact.dll");
|
||||
// Uncomment the line ABOVE for test accounts or BELOW for live merchant accounts
|
||||
// $ch = curl_init("https://secure.authorize.net/gateway/transact.dll");
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim( $fields, "& " )); // use HTTP POST to send form data
|
||||
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response. ###
|
||||
$response = curl_exec($ch); //execute post and get results
|
||||
curl_close ($ch);
|
||||
|
||||
$h = substr_count($response, '|');
|
||||
$h++;
|
||||
|
||||
for($j = 1; $j <= $h; $j++) {
|
||||
$p = strpos($response, '|');
|
||||
|
||||
if ($p === false) {
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td class=\"e\">";
|
||||
|
||||
// x_delim_char is obviously not found in the last go-around
|
||||
|
||||
if($j>=69){
|
||||
|
||||
echo "Merchant-defined (".$j."): ";
|
||||
echo ": ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $response;
|
||||
echo "<br>";
|
||||
|
||||
} else {
|
||||
|
||||
echo $j;
|
||||
echo ": ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $response;
|
||||
echo "<br>";
|
||||
|
||||
// Tacks the line items to the end of the assemble POST fields
|
||||
if (is_array($this->products)) {
|
||||
foreach ($this->products as $product_id => $product) {
|
||||
$fields .= 'x_line_item=' . $product['sku'] . '<|>' . substr($product['name'], 0, 31) . '<|>' . substr($product['name'], 0, 255) . '<|>' . $product['quantity'] . '<|>' . $product['price'] . '<|>N&';
|
||||
}
|
||||
|
||||
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
|
||||
}else{
|
||||
|
||||
$p++;
|
||||
|
||||
// We found the x_delim_char and accounted for it . . . now do something with it
|
||||
|
||||
// get one portion of the response at a time
|
||||
$pstr = substr($response, 0, $p);
|
||||
|
||||
// this prepares the text and returns one value of the submitted
|
||||
// and processed name/value pairs at a time
|
||||
// for AIM-specific interpretations of the responses
|
||||
// please consult the AIM Guide and look up
|
||||
// the section called Gateway Response API
|
||||
$pstr_trimmed = substr($pstr, 0, -1); // removes "|" at the end
|
||||
|
||||
if($pstr_trimmed==""){
|
||||
$pstr_trimmed="NO VALUE RETURNED";
|
||||
}
|
||||
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td class=\"e\">";
|
||||
|
||||
switch($j){
|
||||
|
||||
case 1:
|
||||
echo "Response Code: ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
$fval="";
|
||||
if($pstr_trimmed=="1"){
|
||||
$fval="Approved";
|
||||
}elseif($pstr_trimmed=="2"){
|
||||
$fval="Declined";
|
||||
}elseif($pstr_trimmed=="3"){
|
||||
$fval="Error";
|
||||
}
|
||||
|
||||
echo $fval;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 2:
|
||||
echo "Response Subcode: ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 3:
|
||||
echo "Response Reason Code: ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 4:
|
||||
echo "Response Reason Text: ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 5:
|
||||
echo "Approval Code: ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 6:
|
||||
echo "AVS Result Code: ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 7:
|
||||
echo "Transaction ID: ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 8:
|
||||
echo "Invoice Number (x_invoice_num): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 9:
|
||||
echo "Description (x_description): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 10:
|
||||
echo "Amount (x_amount): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 11:
|
||||
echo "Method (x_method): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 12:
|
||||
echo "Transaction Type (x_type): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 13:
|
||||
echo "Customer ID (x_cust_id): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 14:
|
||||
echo "Cardholder First Name (x_first_name): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 15:
|
||||
echo "Cardholder Last Name (x_last_name): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 16:
|
||||
echo "Company (x_company): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 17:
|
||||
echo "Billing Address (x_address): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 18:
|
||||
echo "City (x_city): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 19:
|
||||
echo "State (x_state): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 20:
|
||||
echo "ZIP (x_zip): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 21:
|
||||
echo "Country (x_country): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 22:
|
||||
echo "Phone (x_phone): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 23:
|
||||
echo "Fax (x_fax): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 24:
|
||||
echo "E-Mail Address (x_email): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 25:
|
||||
echo "Ship to First Name (x_ship_to_first_name): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 26:
|
||||
echo "Ship to Last Name (x_ship_to_last_name): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 27:
|
||||
echo "Ship to Company (x_ship_to_company): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 28:
|
||||
echo "Ship to Address (x_ship_to_address): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 29:
|
||||
echo "Ship to City (x_ship_to_city): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 30:
|
||||
echo "Ship to State (x_ship_to_state): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 31:
|
||||
echo "Ship to ZIP (x_ship_to_zip): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 32:
|
||||
echo "Ship to Country (x_ship_to_country): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 33:
|
||||
echo "Tax Amount (x_tax): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 34:
|
||||
echo "Duty Amount (x_duty): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 35:
|
||||
echo "Freight Amount (x_freight): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 36:
|
||||
echo "Tax Exempt Flag (x_tax_exempt): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 37:
|
||||
echo "PO Number (x_po_num): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 38:
|
||||
echo "MD5 Hash: ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 39:
|
||||
echo "Card Code Response: ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
$fval="";
|
||||
if($pstr_trimmed=="M"){
|
||||
$fval="M = Match";
|
||||
}elseif($pstr_trimmed=="N"){
|
||||
$fval="N = No Match";
|
||||
}elseif($pstr_trimmed=="P"){
|
||||
$fval="P = Not Processed";
|
||||
}elseif($pstr_trimmed=="S"){
|
||||
$fval="S = Should have been present";
|
||||
}elseif($pstr_trimmed=="U"){
|
||||
$fval="U = Issuer unable to process request";
|
||||
}else{
|
||||
$fval="NO VALUE RETURNED";
|
||||
}
|
||||
|
||||
echo $fval;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 40:
|
||||
case 41:
|
||||
case 42:
|
||||
case 43:
|
||||
case 44:
|
||||
case 45:
|
||||
case 46:
|
||||
case 47:
|
||||
case 48:
|
||||
case 49:
|
||||
case 50:
|
||||
case 51:
|
||||
case 52:
|
||||
case 53:
|
||||
case 54:
|
||||
case 55:
|
||||
case 55:
|
||||
case 56:
|
||||
case 57:
|
||||
case 58:
|
||||
case 59:
|
||||
case 60:
|
||||
case 61:
|
||||
case 62:
|
||||
case 63:
|
||||
case 64:
|
||||
case 65:
|
||||
case 66:
|
||||
case 67:
|
||||
case 68:
|
||||
echo "Reserved (".$j."): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
if($j>=69){
|
||||
|
||||
echo "Merchant-defined (".$j."): ";
|
||||
echo ": ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
|
||||
} else {
|
||||
|
||||
echo $j;
|
||||
echo ": ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// POSTs the transaction to Authorize.Net
|
||||
$curl = curl_init($this->url);
|
||||
curl_setopt($curl, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, rtrim($fields, '& ')); // use HTTP POST to send form data
|
||||
|
||||
// @todo uncomment this line if you get no gateway response, or whatever they way
|
||||
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
|
||||
// Breaks apart the response and assigns it to an associative array
|
||||
$response_values = explode('|', $response, 41);
|
||||
$response = array_combine($this->response_variables, $response_values);
|
||||
|
||||
// Trims all of the variables up
|
||||
// @todo Replace this with a user defined trim() and use array_walk()
|
||||
foreach ($response as $key => $value) {
|
||||
$response[$key] = trim($value);
|
||||
}
|
||||
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
// Deciphers the cryptic internal response code
|
||||
// @todo case 4 is not represented
|
||||
switch ($response['response_code']) {
|
||||
case 1: $value = 'Approved'; break;
|
||||
case 2: $value = 'Declined'; break;
|
||||
default: $value = 'Error'; break;
|
||||
}
|
||||
|
||||
// remove the part that we identified and work with the rest of the string
|
||||
$response = substr($response, $p);
|
||||
$response['response_code'] = $value;
|
||||
|
||||
// Deciphers the cryptic internal card code response
|
||||
switch ($response['card_code_response']) {
|
||||
case 'M': $value .= ' = Match'; break;
|
||||
case 'N': $value .= ' = No Match'; break;
|
||||
case 'P': $value .= ' = Not Processed'; break;
|
||||
case 'S': $value .= ' = Should have been present'; break;
|
||||
case 'U': $value .= ' = Issuer unable to process request'; break;
|
||||
case '': $value = 'No value returned'; break;
|
||||
default: $value .= ' = Unknown value'; break;
|
||||
}
|
||||
|
||||
}
|
||||
$response['card_code_response'] = $value;
|
||||
|
||||
}
|
||||
|
||||
echo "</table>";
|
||||
|
||||
exit();
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ class store extends Module {
|
|||
}
|
||||
|
||||
// Loads the categories
|
||||
/*
|
||||
$categories = $this->db->getArray('SELECT id, name, permalink FROM categories WHERE parent_id IS NULL AND visible = "Y" ORDER BY weight;');
|
||||
if (is_array($categories)) {
|
||||
foreach ($categories as $key => $category) {
|
||||
|
@ -56,6 +57,7 @@ class store extends Module {
|
|||
}
|
||||
|
||||
$this->categories = $categories;
|
||||
*/
|
||||
}
|
||||
|
||||
public function __default() {
|
||||
|
|
|
@ -1,9 +1,62 @@
|
|||
<?php
|
||||
|
||||
// @todo store the address_id's in the cart instance to allow for an even easier look up of the data, maybe
|
||||
// @todo Add more error checking, basically against all queries
|
||||
|
||||
class store_checkout extends store {
|
||||
|
||||
protected $display = DISPLAY_JSON;
|
||||
|
||||
public function __default() {
|
||||
|
||||
// Required fields
|
||||
$required = array(
|
||||
'shipping_first_name',
|
||||
'shipping_last_name',
|
||||
'shipping_email',
|
||||
'shipping_phone',
|
||||
'shipping_address1',
|
||||
'shipping_city',
|
||||
'shipping_state',
|
||||
'shipping_zip_code',
|
||||
'referred_by',
|
||||
'other_source',
|
||||
'billing_first_name',
|
||||
'billing_last_name',
|
||||
'billing_email',
|
||||
'billing_phone',
|
||||
'billing_address1',
|
||||
'billing_city',
|
||||
'billing_state',
|
||||
'billing_zip_code',
|
||||
'cc_type',
|
||||
'cc_number',
|
||||
'cc_expiration'
|
||||
);
|
||||
|
||||
// Double safety in case the Javascript fails
|
||||
if (isset($_REQUEST) && is_array($_REQUEST)) {
|
||||
foreach ($_REQUEST as $key => $value) {
|
||||
if (in_array($key, $required)) {
|
||||
$values = is_array($value) ? $value : array($value);
|
||||
|
||||
foreach ($values as $value) {
|
||||
if (trim($value) == '') {
|
||||
$this->message = 'Error: The ' . strtr($key, '_', ' ') . ' field is required.';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['password']) && trim($_REQUEST['password']) != '') {
|
||||
if ($_REQUEST['password'] != $_REQUEST['confirm_password']) {
|
||||
$this->message = 'Error: The password and confirm password fields must match.';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Adds the shipping information into the database
|
||||
$shipping_address = array(
|
||||
'company' => $_REQUEST['shipping_company'],
|
||||
|
@ -22,20 +75,22 @@ class store_checkout extends store {
|
|||
|
||||
$shipping_address['hash'] = md5(implode('', $shipping_address));
|
||||
|
||||
if ($this->db->getField("SELECT COUNT(*) FROM addresses WHERE hash = '{$shipping_address['hash']}';")) {
|
||||
$shipping_address_id = $this->db->getField("SELECT id FROM addresses WHERE hash = '{$shipping_address['hash']}';");
|
||||
if ($this->db->getField("SELECT COUNT(*) FROM addresses WHERE hash = '{$shipping_address['hash']}';") == 0) {
|
||||
$shipping_address_id = $this->db->insert('addresses', $shipping_address);
|
||||
}
|
||||
else {
|
||||
$shipping_address_id = $this->db->insert('addresses', $shipping_address);
|
||||
$shipping_address = $this->db->getRow("SELECT * FROM addresses WHERE address_id = '{$shipping_address_id}';");
|
||||
$shipping_address = $this->db->getRow("SELECT * FROM addresses WHERE hash = '{$shipping_address['hash']}';");
|
||||
$shipping_address_id = $shipping_address['id'];
|
||||
}
|
||||
|
||||
// Adds the billing information into the database
|
||||
$billing_address_id = null;
|
||||
|
||||
if (isset($_REQUEST['billing_same_as_shipping']) && $_REQUEST['billing_same_as_shipping'] == 'on') {
|
||||
$billing_address_id = $shipping_address_id;
|
||||
$billing_address = $shipping_address;
|
||||
}
|
||||
else {
|
||||
else if (isset($_REQUEST['billing_address'])) {
|
||||
$billing_address = array(
|
||||
'company' => $_REQUEST['billing_company'],
|
||||
'first_name' => $_REQUEST['billing_first_name'],
|
||||
|
@ -53,88 +108,230 @@ class store_checkout extends store {
|
|||
|
||||
$billing_address['hash'] = md5(implode('', $billing_address));
|
||||
|
||||
if ($this->db->getField("SELECT COUNT(*) FROM addresses WHERE hash = '{$billing_address['hash']}';")) {
|
||||
$billing_address_id = $this->db->getField("SELECT id FROM addresses WHERE hash = '{$billing_address['hash']}';");
|
||||
if ($this->db->getField("SELECT COUNT(*) FROM addresses WHERE hash = '{$billing_address['hash']}';") == 0) {
|
||||
$billing_address_id = $this->db->insert('addresses', $billing_address);
|
||||
}
|
||||
else {
|
||||
$billing_address_id = $this->db->insert('addresses', $billing_address);
|
||||
$billing_address = $this->db->getRow("SELECT * FROM addresses WHERE address_id = '{$billing_address_id}';");
|
||||
$billing_address = $this->db->getRow("SELECT * FROM addresses WHERE hash = '{$billing_address['hash']}';");
|
||||
$billing_address_id = $billing_address['id'];
|
||||
}
|
||||
}
|
||||
|
||||
$customer = array(
|
||||
'email' => $_REQUEST['shipping_email'],
|
||||
'password' => md5('changeme'),
|
||||
'referred_by' => $_REQUEST['referred_by'],
|
||||
'billing_address_id' => $billing_address_id,
|
||||
'shipping_address_id' => $shipping_address_id,
|
||||
'created_at' => datE('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
// @todo Remove this when I figure out how I want to control certain code inside the common modules
|
||||
$this->error->resetErrors();
|
||||
|
||||
$customer_id = $this->db->insert('customers', $customer);
|
||||
$cart =& $_SESSION['cart'];
|
||||
|
||||
// Adds the customer's email into the email database
|
||||
$email = $_REQUEST['shipping_email'];
|
||||
|
||||
//if ($this->error->getErrors()) {
|
||||
if (false) {
|
||||
exit("There was an error - @todo make a more formal error for when the customer account cannot be created");
|
||||
if ($this->db->getField("SELECT COUNT(*) FROM emails WHERE email = '{$email}';") == 0) {
|
||||
$email_id = $this->db->insert('emails', array('email' => $email));
|
||||
}
|
||||
else {
|
||||
$gateway = new Gateway_AuthorizeNet_AIM($this->config, $this->error);
|
||||
$email_id = $this->db->getField("SELECT id FROM emails WHERE email = '{$email}';");
|
||||
}
|
||||
|
||||
$cart = $_SESSION['cart'];
|
||||
$total_amount = $cart['subtotal'] + $cart['shipping'];
|
||||
// Adds the customer's reference into the database
|
||||
$referrer = strtolower($_REQUEST['referred_by']) == 'other' ? $_REQUEST['other_source'] : $_REQUEST['referred_by'];
|
||||
|
||||
if ($total_amount > 0) {
|
||||
if ($this->db->getField("SELECT COUNT(*) FROM referrers WHERE referrer = '{$referrer}';") == 0) {
|
||||
$referrer_id = $this->db->insert('referrers', array('referrer' => $referrer));
|
||||
}
|
||||
else {
|
||||
$referrer_id = $this->db->getField("SELECT id FROM referrers WHERE referrer = '{$referrer}';");
|
||||
}
|
||||
|
||||
// Payment information
|
||||
$gateway->total_amount = $total_amount;
|
||||
//$gateway->card_type = '',
|
||||
$gateway->card_number = $_REQUEST['cc_number'];
|
||||
$gateway->expiration_month = $_REQUEST['cc_expiration']['month'];
|
||||
$gateway->expiration_year = $_REQUEST['cc_expiration']['year'];
|
||||
// If a password exists, try to create a customer account
|
||||
if (isset($_REQUEST['password']) && trim($_REQUEST['password']) != '') {
|
||||
$customer = array(
|
||||
'email_id' => $email_id,
|
||||
'password' => md5($_REQUEST['password']),
|
||||
'billing_address_id' => $billing_address_id,
|
||||
'shipping_address_id' => $shipping_address_id,
|
||||
'created_at' => datE('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
if (!isset($cart['customer_id']) || $cart['customer_id'] == 0) {
|
||||
// Adds the customer account
|
||||
if ($this->db->getField("SELECT COUNT(*) FROM customers WHERE email_id = '{$email_id}';") == 0) {
|
||||
$cart['customer_id'] = $this->db->insert('customers', $customer);
|
||||
|
||||
if (isset($_REQUEST['ccv2'])) {
|
||||
$gateway->cvv2 = $_REQUEST['ccv2'];
|
||||
// Contacts the user to advise them of their sign up
|
||||
mail($email, 'Welcome to Menopause Solutions', '<< @todo >>');
|
||||
}
|
||||
else {
|
||||
// @todo Change this out for a confirmation box and re-submit
|
||||
// $this->status = 'ExistingCustomer';
|
||||
$this->message = 'Error: The email address you supplied is already in use. There is an existing customer login form on the right-hand side of the page. If you wish to continue without logging in, please provide a different email address or delete the contents of the password box (this will skip the process of creating a new account).';
|
||||
return false;
|
||||
}
|
||||
|
||||
// Billing information
|
||||
$gateway->billing_company = $billing_address['company'];
|
||||
$gateway->billing_first_name = $billing_address['first_name'];
|
||||
$gateway->billing_last_name = $billing_address['last_name'];
|
||||
$gateway->billing_address1 = $billing_address['address1'];
|
||||
$gateway->billing_address2 = $billing_address['address2'];
|
||||
$gateway->billing_city = $billing_address['city'];
|
||||
$gateway->billing_state = $billing_address['state'];
|
||||
$gateway->billing_zip_code = $billing_address['zip_code'];
|
||||
$gateway->billing_country = $billing_address['country'];
|
||||
$gateway->billing_email = $billing_address['email'];
|
||||
$gateway->billing_phone = $billing_address['phone'];
|
||||
$gateway->billing_fax = $billing_address['fax'];
|
||||
|
||||
$gateway->shipping_company = $shipping_address['company'];
|
||||
$gateway->shipping_first_name = $shipping_address['first_name'];
|
||||
$gateway->shipping_last_name = $shipping_address['last_name'];
|
||||
$gateway->shipping_address1 = $shipping_address['address1'];
|
||||
$gateway->shipping_address2 = $shipping_address['address2'];
|
||||
$gateway->shipping_city = $shipping_address['city'];
|
||||
$gateway->shipping_state = $shipping_address['state'];
|
||||
$gateway->shipping_zip_code = $shipping_address['zip_code'];
|
||||
$gateway->shipping_country = $shipping_address['country'];
|
||||
$gateway->shipping_email = $shipping_address['email'];
|
||||
$gateway->shipping_phone = $shipping_address['phone'];
|
||||
$gateway->shipping_fax = $shipping_address['fax'];
|
||||
|
||||
/*
|
||||
$gateway->tax = '';
|
||||
$gateway->freight = '';
|
||||
$gateway->order_number = '';
|
||||
$gateway->session_number = '';
|
||||
*/
|
||||
|
||||
$gateway->process();
|
||||
}
|
||||
// Updates the existing customer account
|
||||
else {
|
||||
$this->db->execute('customers', $customer, array('id' => $cart['customer_id']));
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->error->getErrors()) {
|
||||
$this->status = 'Error';
|
||||
$this->message = 'There was an error adding the customer account (' . implode('. ', $this->error->getErrors()) . '.)';
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
$total_amount = $cart['subtotal'] + $cart['shipping'];
|
||||
|
||||
if (isset($cart['customer_id'])) {
|
||||
$xref_id = $cart['customer_id'];
|
||||
$xref_type = 'CUSTOMER';
|
||||
}
|
||||
else if (isset($email_id)) {
|
||||
$xref_id = $email_id;
|
||||
$xref_type = 'EMAIL';
|
||||
}
|
||||
else {
|
||||
$this->status = 'Error';
|
||||
$this->message = 'There was an internal error.';
|
||||
return false;
|
||||
}
|
||||
|
||||
// Assembles the order array
|
||||
$order = array(
|
||||
'xref_id' => $xref_id,
|
||||
'xref_type' => $xref_type,
|
||||
'shipping_address_id' => $shipping_address_id,
|
||||
'billing_address_id' => $billing_address_id,
|
||||
'referrer_id' => $referrer_id,
|
||||
'affiliate_id' => isset($cart['affiliate']) ? $cart['affiliate'] : null,
|
||||
'cc_type' => isset($_REQUEST['cc_type']) ? $_REQUEST['cc_type'] : null,
|
||||
'cc_last4' => isset($_REQUEST['cc_number']) ? substr($_REQUEST['cc_number'], -4) : null,
|
||||
'cc_expiration' => isset($_REQUEST['cc_expiration']) ? '20' . $_REQUEST['cc_expiration']['year'] . '-' . $_REQUEST['cc_expiration']['month'] . '-01' : null,
|
||||
'total_amount' => "{$total_amount}",
|
||||
'shipping_amount' => "{$cart['shipping']}"
|
||||
);
|
||||
|
||||
// Inserts the order into the database
|
||||
if (!isset($cart['order_id']) || $cart['order_id'] == 0) {
|
||||
$cart['order_id'] = $this->db->insert('orders', $order);
|
||||
}
|
||||
// Updates an existing order
|
||||
else {
|
||||
$this->db->update('orders', $order, array('id' => $cart['order_id']));
|
||||
|
||||
// Cleans out the order_* tables
|
||||
$this->db->execute("DELETE FROM order_products WHERE order_id = '{$cart['order_id']}';");
|
||||
}
|
||||
|
||||
// Populates the order_* tables
|
||||
foreach ($cart['products'] as $product_id => $product) {
|
||||
$order_product = array(
|
||||
'order_id' => $cart['order_id'],
|
||||
'product_id' => $product_id,
|
||||
'sequence' => '0',
|
||||
'quantity' => $product['quantity']
|
||||
);
|
||||
$this->db->insert('order_products', $order_product);
|
||||
}
|
||||
|
||||
// Checks if the transaction ID exists for the order, if not, process the order
|
||||
if ($this->db->getField("SELECT transaction_id FROM orders WHERE id = '{$cart['order_id']}';") == NULL) {
|
||||
if ($total_amount > 0) {
|
||||
$gateway = new WebService_AuthorizeNet_AIM($this->config, $this->error);
|
||||
|
||||
// Customer and order information
|
||||
$gateway->order_id = $cart['order_id'];
|
||||
$gateway->customer_id = isset($cart['customer_id']) ? $cart['customer_id'] : 'N/A';
|
||||
$gateway->customer_ip = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
// Payment information
|
||||
$gateway->total_amount = $total_amount;
|
||||
$gateway->shipping = $cart['shipping'];
|
||||
$gateway->card_number = $_REQUEST['cc_number'];
|
||||
$gateway->expiration_month = $_REQUEST['cc_expiration']['month'];
|
||||
$gateway->expiration_year = $_REQUEST['cc_expiration']['year'];
|
||||
|
||||
if (isset($_REQUEST['ccv2'])) {
|
||||
$gateway->cvv2 = $_REQUEST['ccv2'];
|
||||
}
|
||||
|
||||
// Billing information
|
||||
$gateway->billing_company = $billing_address['company'];
|
||||
$gateway->billing_first_name = $billing_address['first_name'];
|
||||
$gateway->billing_last_name = $billing_address['last_name'];
|
||||
$gateway->billing_address1 = $billing_address['address1'];
|
||||
$gateway->billing_address2 = $billing_address['address2'];
|
||||
$gateway->billing_city = $billing_address['city'];
|
||||
$gateway->billing_state = $billing_address['state'];
|
||||
$gateway->billing_zip_code = $billing_address['zip_code'];
|
||||
$gateway->billing_country = $billing_address['country'];
|
||||
$gateway->billing_email = $billing_address['email'];
|
||||
$gateway->billing_phone = $billing_address['phone'];
|
||||
$gateway->billing_fax = $billing_address['fax'];
|
||||
|
||||
// Shipping information
|
||||
$gateway->shipping_company = $shipping_address['company'];
|
||||
$gateway->shipping_first_name = $shipping_address['first_name'];
|
||||
$gateway->shipping_last_name = $shipping_address['last_name'];
|
||||
$gateway->shipping_address1 = $shipping_address['address1'];
|
||||
$gateway->shipping_address2 = $shipping_address['address2'];
|
||||
$gateway->shipping_city = $shipping_address['city'];
|
||||
$gateway->shipping_state = $shipping_address['state'];
|
||||
$gateway->shipping_zip_code = $shipping_address['zip_code'];
|
||||
$gateway->shipping_country = $shipping_address['country'];
|
||||
$gateway->shipping_email = $shipping_address['email'];
|
||||
$gateway->shipping_phone = $shipping_address['phone'];
|
||||
$gateway->shipping_fax = $shipping_address['fax'];
|
||||
|
||||
// Order information
|
||||
$gateway->products = $cart['products'];
|
||||
|
||||
/*
|
||||
$gateway->tax = '';
|
||||
$gateway->order_number = '';
|
||||
$gateway->session_number = '';
|
||||
*/
|
||||
|
||||
$response = $gateway->process();
|
||||
|
||||
// If the transaction was approved, update the order
|
||||
if ($response['response_code'] == 'Approved') {
|
||||
$this->db->execute("
|
||||
UPDATE orders
|
||||
SET transaction_id = '{$response['transaction_id']}', time_placed = NOW()
|
||||
WHERE id = '{$response['invoice_number']}';
|
||||
");
|
||||
|
||||
// Does some clean up to avoid duplicate transactions
|
||||
unset($_SESSION['cart']);
|
||||
}
|
||||
|
||||
$this->status = $response['response_code'];
|
||||
$this->message = $response['response_reason_text'];
|
||||
}
|
||||
// Free order (no payment processing necessary)
|
||||
else {
|
||||
// Email the user a receipt
|
||||
// Email the shipping department the request
|
||||
|
||||
$this->status = 'Approved';
|
||||
|
||||
$this->db->execute("
|
||||
UPDATE orders
|
||||
SET transaction_id = '', time_placed = NOW()
|
||||
WHERE id = '{$cart['order_id']}';
|
||||
");
|
||||
|
||||
// Does some clean up to avoid duplicate transactions
|
||||
unset($_SESSION['cart']);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->status = 'Error';
|
||||
$this->message = 'A duplicate transaction has been submitted.';
|
||||
}
|
||||
|
||||
// Unsets the cart variable
|
||||
unset($cart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,22 +12,25 @@ function getForm(form) {
|
|||
case 'password':
|
||||
case 'text':
|
||||
case 'textarea':
|
||||
// Check if it's required
|
||||
if (element.title == 'required' && trim(element.value) == '') {
|
||||
alert('Error: The ' + element.name.replace('_', ' ') + ' field is required.');
|
||||
element.focus();
|
||||
return false;
|
||||
}
|
||||
// If the field is named email, check it's validity
|
||||
else if (element.name == 'email') {
|
||||
if (element.value.match(/^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/i) == null) {
|
||||
alert('Error: The email address entered is not valid.');
|
||||
// Checks if the field is visible
|
||||
if (element.style.display != 'none') {
|
||||
// Checks if it's required
|
||||
if (element.title == 'required' && trim(element.value) == '') {
|
||||
alert('Error: The ' + element.name.replace('_', ' ') + ' field is required.');
|
||||
element.focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// If the field is named email, check it's validity
|
||||
else if (element.name == 'email') {
|
||||
if (element.value.match(/^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/i) == null) {
|
||||
alert('Error: The email address entered is not valid.');
|
||||
element.focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
params += '&' + element.name + '=' + encodeURI(element.value);
|
||||
params += '&' + element.name + '=' + encodeURI(element.value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'checkbox':
|
||||
|
@ -67,7 +70,7 @@ function createRequest() {
|
|||
}
|
||||
|
||||
function ajaxRequest(htmlElement, customHandler, placement, url) {
|
||||
var params = '';
|
||||
var params = '';
|
||||
var return_status = '';
|
||||
var customHandler = (customHandler == null) ? null : customHandler;
|
||||
var placement = (placement == null) ? 'before' : placement;
|
||||
|
@ -161,6 +164,10 @@ function ajaxRequest(htmlElement, customHandler, placement, url) {
|
|||
|
||||
request.send(params);
|
||||
}
|
||||
else if (customHandler) {
|
||||
responseElement = window[customHandler]();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function trim(str) {
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
<b>Transaction Successful!</b><br />
|
||||
(Small paragraph with emailed receipt. Also notice that one their order has been shipped they will receive the shipping tracking info via email as well.)<br /><br />
|
||||
-- or --<br /><br />
|
||||
<b>Transaction Failed.</b><br />
|
||||
(Small paragraph about returning to previous page to make sure all input info was correct and if they continue to have problems to call (800)895-4415 to resolve the issue and/or order by phone.)
|
||||
|
||||
{if $status == 'Approved'}
|
||||
<h1>Transaction Successful!</h1><br />
|
||||
Thank you for your order, a receipt should arrive via email shortly. Once your order has been shipped you will receive the shipment tracking information via email as well.
|
||||
{else}
|
||||
<h1>Transaction {$status}.</h1><br />
|
||||
There was an error processing your order:<br /><br />
|
||||
<div style="padding-left: 40px; font-weight: bold;">{$message}</div><br />
|
||||
Please return to the previous page and make sure all of the information is correct. Should you continue to have problems, please call (800) 895-4415 for futher assistance.
|
||||
{/if}
|
||||
<div style="height: 900px"></div>
|
||||
|
|
|
@ -38,12 +38,13 @@
|
|||
*/
|
||||
function smarty_function_html_select_state($params, &$smarty) {
|
||||
|
||||
// Sets up the prefix (optionally passed in)
|
||||
// Sets up the prefix and title (optionally passed in)
|
||||
$prefix = (isset($params['prefix']) ? $params['prefix'] : null) . 'state';
|
||||
$title = (isset($params['title']) ? $params['title'] : null);
|
||||
|
||||
// Puts together the dropdown
|
||||
$select = '
|
||||
<select id="' . $prefix . '" name="' . $prefix . '">
|
||||
<select id="' . $prefix . '" name="' . $prefix . '" title="' . $title . '">
|
||||
<option value="">-- Select a State --</option>
|
||||
<option value="AK">Alaska</option>
|
||||
<option value="AL">Alabama</option>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue