/**
  * Init payPal Mass pay api
  */
 public function call_masspay_api($receiver_information)
 {
     global $WCMp;
     require_once $WCMp->plugin_path . 'lib/paypal/CallerService.php';
     session_start();
     $emailSubject = urlencode('You have money!');
     $receiverType = urlencode('EmailAddress');
     $currency = urlencode(get_woocommerce_currency());
     $nvpstr = '';
     if ($receiver_information) {
         foreach ($receiver_information as $receiver) {
             $j = 0;
             $receiverEmail = urlencode($receiver['recipient']);
             $amount = urlencode($receiver['total']);
             $uniqueID = urlencode($receiver['vendor_id']);
             $note = urlencode($receiver['payout_note']);
             $nvpstr .= "&L_EMAIL{$j}={$receiverEmail}&L_Amt{$j}={$amount}&L_UNIQUEID{$j}={$uniqueID}&L_NOTE{$j}={$note}";
             $j++;
         }
         $nvpstr .= "&EMAILSUBJECT={$emailSubject}&RECEIVERTYPE={$receiverType}&CURRENCYCODE={$currency}";
         doProductVendorLOG($nvpstr);
         $resArray = hash_call("MassPay", $nvpstr);
         $ack = strtoupper($resArray["ACK"]);
         if ($ack == "SUCCESS" || $ack == "SuccessWithWarning") {
             doProductVendorLOG(json_encode($resArray));
             return $resArray;
         } else {
             doProductVendorLOG(json_encode($resArray));
             return false;
         }
     }
     return false;
 }
 function do_nvp_call($nvpstr)
 {
     global $db;
     $APIUsername = $this->config['api_user'];
     $APISignature = $this->config['api_sig'];
     $APIPassword = $this->config['api_pass'];
     if ($this->config['testing']) {
         $API_Endpoint = 'https://api-3t.sandbox.paypal.com/nvp';
     } else {
         $API_Endpoint = 'https://api-aa-3t.paypal.com/nvp';
     }
     $resArray = hash_call("doDirectPayment", $nvpstr, $APIUsername, $APIPassword, $APISignature, $API_Endpoint);
     return $resArray;
 }
示例#3
0
 /**
  * Makes the paypal transacation
  *
  * @param Array $fields
  * @return boolean
  */
 public function transaction($fields)
 {
     /* Construct the request string that will be sent to PayPal.
        The variable $nvpstr contains all the variables and is a
        name value pair string with & as a delimiter */
     $nvpstr = "&PAYMENTACTION={$fields['paymentType']}&AMT={$fields['amount']}&CREDITCARDTYPE={$fields['creditCardType']}&ACCT={$fields['creditCardNumber']}&EXPDATE=" . $fields['expDateMonth'] . $fields['expDateYear'] . "&CVV2={$fields['cvv2Number']}&FIRSTNAME={$fields['firstName']}&LASTNAME={$fields['lastName']}&" . "STREET={$fields['address1']}&CITY={$fields['city']}&STATE={$fields['state']}" . "&ZIP={$fields['zip']}&COUNTRYCODE={$fields['country']}&CURRENCYCODE={$fields['currencyCode']}";
     /* Make the API call to PayPal, using API signature.
        The API response is stored in an associative array called $resArray */
     /* @var $resArray type */
     $this->resArray = hash_call("doDirectPayment", $nvpstr);
     /* Display the API response back to the browser.
        If the response from PayPal was a success, display the response parameters'
        If the response was an error, display the errors received using APIError.php.
        */
     $ack = strtoupper($this->resArray["ACK"]);
     if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
         return true;
     } else {
         return false;
     }
 }
示例#4
0
function ConfirmPayment($token, $paymentType, $currencyCodeType, $payerID, $FinalPaymentAmt, $items)
{
    /* Gather the information to make the final call to
       finalize the PayPal payment.  The variable nvpstr
       holds the name value pairs
       */
    $token = urlencode($token);
    $paymentType = urlencode($paymentType);
    $currencyCodeType = urlencode($currencyCodeType);
    $payerID = urlencode($payerID);
    $serverName = urlencode($_SERVER['SERVER_NAME']);
    $nvpstr = '&TOKEN=' . $token . '&PAYERID=' . $payerID . '&PAYMENTREQUEST_0_PAYMENTACTION=' . $paymentType . '&PAYMENTREQUEST_0_AMT=' . $FinalPaymentAmt;
    $nvpstr .= '&PAYMENTREQUEST_0_CURRENCYCODE=' . $currencyCodeType . '&IPADDRESS=' . $serverName;
    foreach ($items as $index => $item) {
        $nvpstr .= "&L_PAYMENTREQUEST_0_NAME" . $index . "=" . urlencode($item["name"]);
        $nvpstr .= "&L_PAYMENTREQUEST_0_AMT" . $index . "=" . urlencode($item["amt"]);
        $nvpstr .= "&L_PAYMENTREQUEST_0_QTY" . $index . "=" . urlencode($item["qty"]);
        $nvpstr .= "&L_PAYMENTREQUEST_0_ITEMCATEGORY" . $index . "=Digital";
    }
    /* Make the call to PayPal to finalize payment
       If an error occured, show the resulting errors
       */
    $resArray = hash_call("DoExpressCheckoutPayment", $nvpstr);
    /* Display the API response back to the browser.
       If the response from PayPal was a success, display the response parameters'
       If the response was an error, display the errors received using APIError.php.
       */
    $ack = strtoupper($resArray["ACK"]);
    return $resArray;
}
示例#5
0
        header("Location: {$location}");
    }
} else {
    /* At this point, the buyer has completed in authorizing payment
    			at PayPal.  The script will now call PayPal with the details
    			of the authorization, incuding any shipping information of the
    			buyer.  Remember, the authorization is not a completed transaction
    			at this state - the buyer still needs an additional step to finalize
    			the transaction
    			*/
    $token = urlencode($_REQUEST['token']);
    /* Build a second API request to PayPal, using the token as the
    			ID to get the details on the payment authorization
    			*/
    $nvpstr = "&TOKEN=" . $token;
    $nvpstr = $nvpHeader . $nvpstr;
    /* Make the API call and store the results in an array.  If the
    			call was a success, show the authorization details, and provide
    			an action to complete the payment.  If failed, show the error
    			*/
    $resArray = hash_call("GetExpressCheckoutDetails", $nvpstr);
    $_SESSION['reshash'] = $resArray;
    $ack = strtoupper($resArray["ACK"]);
    if ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING') {
        require_once "GetExpressCheckoutDetails.php";
    } else {
        //Redirecting to APIError.php to display errors.
        $location = "APIError.php";
        header("Location: {$location}");
    }
}
示例#6
0
$creditCardType = urlencode($_POST['creditCardType']);
$creditCardNumber = urlencode($_POST['creditCardNumber']);
$expDateMonth = urlencode($_POST['expDateMonth']);
//Month must be padded with leading zero
$padDateMonth = str_pad($expDateMonth, 2, '0', STR_PAD_LEFT);
$expDateYear = urlencode($_POST['expDateYear']);
$cvv2Number = urlencode($_POST['cvv2Number']);
$amount = urlencode($_POST['ftotal']);
$currencyCode = "USD";
/* Construct the request string that will be sent to PayPal.
   The variable $nvpstr contains all the variables and is a
   name value pair string with & as a delimiter */
$nvpstr = "&PAYMENTACTION={$paymentType}&AMT={$amount}&CREDITCARDTYPE={$creditCardType}&ACCT={$creditCardNumber}&EXPDATE=" . $padDateMonth . $expDateYear . "&CVV2={$cvv2Number}&FIRSTNAME={$firstName}&COUNTRYCODE=US&CURRENCYCODE={$currencyCode}";
/* Make the API call to PayPal, using API signature.
   The API response is stored in an associative array called $resArray */
$resArray = hash_call("doDirectPayment", $nvpstr);
/* Display the API response back to the browser.
   If the response from PayPal was a success, display the response parameters'
   If the response was an error, display the errors received using APIError.php.
*/
$ack = strtoupper($resArray["ACK"]);
if ($ack != "SUCCESS") {
    $_SESSION['reshash'] = $resArray;
    $location = "confirmation.php?flag=2";
    header("Location: {$location}");
}
if ($ack == "SUCCESS") {
    $_SESSION['reshash'] = "SUCCESS";
    $location = "thankyou.php?stage=3";
    header("Location: {$location}");
}
示例#7
0
function DirectPayment($paymentType, $paymentAmount, $creditCardType, $creditCardNumber, $expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip, $countryCode, $currencyCode)
{
    //Construct the parameter string that describes DoDirectPayment
    $nvpstr = "&AMT=" . $paymentAmount;
    $nvpstr = $nvpstr . "&CURRENCYCODE=" . $currencyCode;
    $nvpstr = $nvpstr . "&PAYMENTACTION=" . $paymentType;
    $nvpstr = $nvpstr . "&CREDITCARDTYPE=" . $creditCardType;
    $nvpstr = $nvpstr . "&ACCT=" . $creditCardNumber;
    $nvpstr = $nvpstr . "&EXPDATE=" . $expDate;
    $nvpstr = $nvpstr . "&CVV2=" . $cvv2;
    $nvpstr = $nvpstr . "&FIRSTNAME=" . $firstName;
    $nvpstr = $nvpstr . "&LASTNAME=" . $lastName;
    $nvpstr = $nvpstr . "&STREET=" . $street;
    $nvpstr = $nvpstr . "&CITY=" . $city;
    $nvpstr = $nvpstr . "&STATE=" . $state;
    $nvpstr = $nvpstr . "&COUNTRYCODE=" . $countryCode;
    $nvpstr = $nvpstr . "&IPADDRESS=" . $_SERVER['REMOTE_ADDR'];
    $resArray = hash_call("DoDirectPayment", $nvpstr);
    return $resArray;
}
session_start();
/* Gather the information to make the final call to
   finalize the PayPal payment.  The variable nvpstr
   holds the name value pairs
   */
$token = urlencode($_SESSION['token']);
$paymentAmount = urlencode($_SESSION['paymentAmount']);
$paymentType = urlencode($_SESSION['paymentType']);
$currCodeType = urlencode($_SESSION['currCodeType']);
$payerID = urlencode($_SESSION['payer_id']);
$serverName = urlencode($_SERVER['SERVER_NAME']);
$nvpstr = '&TOKEN=' . $token . '&PAYERID=' . $payerID . '&PAYMENTACTION=' . $paymentType . '&AMT=' . $paymentAmount . '&CURRENCYCODE=' . $currCodeType . '&IPADDRESS=' . $serverName;
/* Make the call to PayPal to finalize payment
   If an error occured, show the resulting errors
   */
$resArray = hash_call("DoExpressCheckoutPayment", $nvpstr);
/* Display the API response back to the browser.
   If the response from PayPal was a success, display the response parameters'
   If the response was an error, display the errors received using APIError.php.
   */
$ack = strtoupper($resArray["ACK"]);
if ($ack != "SUCCESS") {
    $_SESSION['reshash'] = $resArray;
    $location = "APIError.php";
    header("Location: {$location}");
}
?>


<html>
<head>
示例#9
0
/**
 *	Validate payment
 *
 *	@param	string	$token				Token
 *	@param	string	$paymentType		Type
 *	@param	string	$currencyCodeType	Currency
 *	@param	string	$payerID			Payer ID
 *	@param	string	$ipaddress			IP Address
 *	@param	string	$FinalPaymentAmt	Amount
 *	@param	string	$tag				Tag
 *	@return	void
 */
function confirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $tag)
{
    /* Gather the information to make the final call to
       finalize the PayPal payment.  The variable nvpstr
       holds the name value pairs
       */
    //declaring of global variables
    global $conf, $langs;
    global $API_Endpoint, $API_Url, $API_version, $USE_PROXY, $PROXY_HOST, $PROXY_PORT;
    global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE;
    $nvpstr = '';
    $nvpstr .= '&TOKEN=' . urlencode($token);
    $nvpstr .= '&PAYERID=' . urlencode($payerID);
    $nvpstr .= '&PAYMENTACTION=' . urlencode($paymentType);
    $nvpstr .= '&AMT=' . urlencode($FinalPaymentAmt);
    $nvpstr .= '&CURRENCYCODE=' . urlencode($currencyCodeType);
    $nvpstr .= '&IPADDRESS=' . urlencode($ipaddress);
    $nvpstr .= '&INVNUM=' . urlencode($tag);
    /* Make the call to PayPal to finalize payment
       If an error occured, show the resulting errors
       */
    $resArray = hash_call("DoExpressCheckoutPayment", $nvpstr);
    /* Display the API response back to the browser.
       If the response from PayPal was a success, display the response parameters'
       If the response was an error, display the errors received using APIError.php.
       */
    $ack = strtoupper($resArray["ACK"]);
    return $resArray;
}
示例#10
0
    public function __Cart($action, $type = false)
    {
        $settings = $this->LoadSetting("ecommerce");
        if (!$settings['order_email']) {
            $settings['order_email'] = $this->Site['email'];
        }
        if ($settings['enable_https']) {
            $this->Site->EnableHTTPS();
        }
        switch (strtolower($action)) {
            case "success":
                $this->Page->Content = <<<EOH

Thank you very much for your purchase at {$this->Site->Title}. We hope you enjoy your purchase.
<br /><br />
Have a nice day!
<br /><br />
<a href="{$this->Site->URL}/"><< Return to {$this->Site->Title}</a>

EOH;
                break;
            case "cancel":
                if ($settings['require_authorization'] && !$this->User->Validated) {
                    $this->Redirect($this->Site->URL . "/account/login/");
                }
                $query = "UPDATE `{$this->DB->Prefix}ecommerce_orders` \n\t\t\t\t\t\tSET `order_status` 'Cancelled' \n\t\t\t\t\t\tWHERE `order_id` = " . $this->Session['order_id'];
                $this->DB->Query($query);
                unset($_SESSION['order_id']);
                unset($_SESSION['token']);
                unset($_SESSION['amount']);
                unset($_SESSION['paymentType']);
                unset($_SESSION['currCodeType']);
                unset($_SESSION['payer_id']);
                unset($_SESSION['SERVER_NAME']);
                unset($_SESSION['type']);
                unset($_SESSION['shipping_first_name']);
                unset($_SESSION['shipping_last_name']);
                unset($_SESSION['shipping_street_1']);
                unset($_SESSION['shipping_street_2']);
                unset($_SESSION['shipping_city']);
                unset($_SESSION['shipping_state']);
                unset($_SESSION['shipping_postal_code']);
                unset($_SESSION['shipping_phone_number']);
                unset($_SESSION['shipping_country']);
                unset($_SESSION['billing_first_name']);
                unset($_SESSION['billing_last_name']);
                unset($_SESSION['billing_street_1']);
                unset($_SESSION['billing_street_2']);
                unset($_SESSION['billing_city']);
                unset($_SESSION['billing_state']);
                unset($_SESSION['billing_postal_code']);
                unset($_SESSION['billing_phone_number']);
                unset($_SESSION['billing_country']);
                unset($_SESSION['user_id']);
                $this->Page->Content = <<<EOH

Your checkout has been cancelled.
<br /><br />
<a href="{$this->Site->URL}/"><< Return to {$this->Site->Title}</a>

EOH;
                break;
            case "error":
                if ($settings['require_authorization'] && !$this->User->Validated) {
                    $this->Redirect($this->Site->URL . "/account/login/");
                }
                $resArray = $_SESSION['reshash'];
                $this->Page->Content .= <<<EOH

<strong>We're sorry, there's been an error. Please try again.</strong>
<br />
EOH;
                if ($settings['paypal_api_debug']) {
                    $this->Page->Content .= <<<EOH

<table cellspacing="5" cellpadding="0" border="0">

EOH;
                    //it will print if any URL errors
                    if (isset($_SESSION['curl_error_no'])) {
                        $errorCode = $_SESSION['curl_error_no'];
                        $errorMessage = $_SESSION['curl_error_msg'];
                        session_unset();
                        $this->Page->Content .= <<<EOH

<tr>
\t\t<td>Error Number:</td>
\t\t<td>{$errorCode}</td>
\t</tr>
\t<tr>
\t\t<td>Error Message:</td>
\t\t<td>{$errorMessage}</td>
\t</tr>
\t
\t</center>
\t</table>
EOH;
                    } else {
                        /* If there is no URL Errors, Construct the HTML page with 
                           Response Error parameters.   
                           */
                        $this->Page->Content .= <<<EOH

\t\t<td>Ack:</td>
\t\t<td>{$resArray['ACK']}</td>
\t</tr>
\t<tr>
\t\t<td>Correlation ID:</td>
\t\t<td>{$resArray['CORRELATIONID']}</td>
\t</tr>
\t<tr>
\t\t<td>Version:</td>
\t\t<td>{$resArray['VERSION']}</td>
\t</tr>
EOH;
                        $count = 0;
                        while (isset($resArray["L_SHORTMESSAGE" . $count])) {
                            $errorCode = $resArray["L_ERRORCODE" . $count];
                            $shortMessage = $resArray["L_SHORTMESSAGE" . $count];
                            $longMessage = $resArray["L_LONGMESSAGE" . $count];
                            $count = $count + 1;
                            $this->Page->Content .= <<<EOH

\t<tr>
\t\t<td>Error Number:</td>
\t\t<td>{$errorCode}</td>
\t</tr>
\t<tr>
\t\t<td>Short Message:</td>
\t\t<td>{$shortMessage}</td>
\t</tr>
\t<tr>
\t\t<td>Long Message:</td>
\t\t<td>{$longMessage}</td>
\t</tr>
EOH;
                        }
                    }
                    $this->Page->Content .= <<<EOH

</center>
\t</table>
\t
EOH;
                }
                break;
            case "preview":
                if ($settings['require_authorization'] && !$this->User->Validated) {
                    $this->Redirect($this->Site->URL . "/account/login/");
                }
                $this->Session->Merge($_REQUEST);
                if ($this->Session['same_information'] == "yes") {
                    $this->Session['billing_first_name'] = $this->Session['shipping_first_name'];
                    $this->Session['billing_last_name'] = $this->Session['shipping_last_name'];
                    $this->Session['billing_street_1'] = $this->Session['shipping_street_1'];
                    $this->Session['billing_street_2'] = $this->Session['shipping_street_2'];
                    $this->Session['billing_city'] = $this->Session['shipping_city'];
                    $this->Session['billing_state'] = $this->Session['shipping_state'];
                    $this->Session['billing_postal_code'] = $this->Session['shipping_postal_code'];
                    $this->Session['billing_phone_number'] = $this->Session['shipping_phone_number'];
                    $this->Session['billing_fax_number'] = $this->Session['shipping_fax_number'];
                    $this->Session['billing_country'] = $this->Session['shipping_country'];
                }
                $type = $this->Session['type'];
                $items = explode(',', $this->Session->Cart);
                $count = count($items);
                $s = $count > 1 ? 's' : '';
                $contents = array();
                foreach ($items as $item) {
                    $contents[$item] = isset($contents[$item]) ? ++$contents[$item] : 1;
                }
                $purchase_total = 0;
                $purchases = '';
                $shipping_total = $settings['base_shipping'];
                foreach ($contents as $id => $quantity) {
                    $query = "SELECT `product_id`, `product_title`, `product_shipping_price`, `product_description`, `product_price`\n\t\t\t\t\t\t\tFROM `{$this->DB->Prefix}ecommerce_products` \n\t\t\t\t\t\t\tWHERE `product_id` = {$id} \n\t\t\t\t\t\t\tLIMIT 1";
                    if ($product = $this->DB->FetchRow($query, "slave")) {
                        $purchases .= <<<EOH

{$quantity}x <a href="{$this->Site->URL}/shop/product/{$product['product_id']}/" target="_blank">{$product['product_title']}</a> (\${$product['product_price']})
<br />

EOH;
                        if (isset($product['product_price'])) {
                            $purchase_total += $product['product_price'] * $quantity;
                        }
                        if (isset($product['product_shipping_price'])) {
                            $shipping_total += $product['product_shipping_price'] * $quantity;
                        }
                    }
                }
                $purchase_total = round($purchase_total, 2);
                $shipping_total = round($shipping_total, 2);
                if ($settings['sales_tax_state'] == $this->Session['shipping_state']) {
                    $tax_total = round($purchase_total * ($settings['sales_tax_percentage'] / 100), 2);
                } else {
                    $tax_total = 0;
                }
                $this->Session['amount'] = round($purchase_total + $shipping_total + $tax_total, 2);
                if ($type == "pp_basic") {
                    $query = array();
                    $query[] = "`order_amount` = '" . $this->Session['amount'] . "'";
                    if ($this->Session['order_products']) {
                        $query[] = "`order_products` = '" . rawurldecode($this->Session['order_products']) . "'";
                    }
                    //if($currCodeType) $query[] = "`order_currency` = '" . $currCodeType . "'";
                    $query[] = "`shipping_first_name` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_first_name'])) . "'";
                    $query[] = "`shipping_last_name` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_last_name'])) . "'";
                    $query[] = "`shipping_street_1` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_street_1'])) . "'";
                    $query[] = "`shipping_street_2` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_street_2'])) . "'";
                    $query[] = "`shipping_city` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_city'])) . "'";
                    $query[] = "`shipping_state` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_state'])) . "'";
                    $query[] = "`shipping_postal_code` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_postal_code'])) . "'";
                    $query[] = "`shipping_phone_number` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_phone_number'])) . "'";
                    $query[] = "`shipping_fax_number` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_fax_number'])) . "'";
                    $query[] = "`shipping_country` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_country'])) . "'";
                    $query[] = "`billing_first_name` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_first_name'])) . "'";
                    $query[] = "`billing_last_name` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_last_name'])) . "'";
                    $query[] = "`billing_street_1` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_street_1'])) . "'";
                    $query[] = "`billing_street_2` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_street_2'])) . "'";
                    $query[] = "`billing_city` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_city'])) . "'";
                    $query[] = "`billing_state` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_state'])) . "'";
                    $query[] = "`billing_postal_code` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_postal_code'])) . "'";
                    $query[] = "`billing_phone_number` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_phone_number'])) . "'";
                    $query[] = "`billing_fax_number` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_fax_number'])) . "'";
                    $query[] = "`billing_country` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_country'])) . "'";
                    if ($this->User['id']) {
                        $query[] = "`user_id` = '" . $this->User['id'] . "'";
                    }
                    if ($this->Session->Cart) {
                        $query[] = "`order_products` = '" . $this->Session->Cart . "'";
                    }
                    $query[] = "`order_status` = 'Pending'";
                    $query[] = "`order_type` = 'PayPal Basic'";
                    $query[] = "`order_date` = FROM_UNIXTIME(" . time() . ")";
                    $query[] = "`order_notes` = '" . mysql_real_escape_string(rawurldecode($this->Session['order_notes'])) . "'";
                    $query = "INSERT INTO `{$this->DB->Prefix}ecommerce_orders` \n\t\t\t\t\t\t\t\tSET " . fix_query(implode(',', $query));
                    $this->DB->Query($query);
                    $order_id = mysql_insert_id();
                    $this->Session['order_id'] = $order_id;
                }
                $this->Page->Content .= <<<EOH

<center>
\t<div class="style1" style="float: left;">
\t\t<strong><a href="{$this->Site->URL}/shop/cart/">View Cart</a></strong>
\t</div>
\t<div class="style1" style="float: left;">
\t\t<strong><a href="{$this->Site->URL}/shop/cart/information/">Information</a></strong>
\t</div>
\t<div class="style1 active" style="float: left;">
\t\t<strong>Preview</strong>
\t</div>
\t<div class="style1 disabled" style="float: left;">
\t\t<strong>Payment</strong>
\t</div>
\t<div class="style1 disabled" style="float: left;">
\t\t<strong>Review</strong>
\t</div>
\t<div class="style1 disabled" style="float: left;">
\t\t<strong>Complete</strong>
\t</div>
\t<div style="clear: both"></div>
</center>
<br /><br />
<strong>Purchases:</strong>  \${$purchase_total} USD
<br/>
<strong>Shipping:</strong> \${$shipping_total} USD
<br/>
<strong>Tax:</strong> \${$tax_total} USD
<br/>
<strong>Total:</strong> \${$this->Session['amount']} USD
<br /><br /><br />

EOH;
                $this->Page->Content .= <<<EOH

<center>
<form action="{$this->Site->URL}/shop/cart/payment/" method="post">
\t<input type="submit" name="submit" value="Continue" class="submit" />
</form>
</center>

EOH;
                break;
            case "review":
                if ($settings['require_authorization'] && !$this->User->Validated) {
                    $this->Redirect($this->Site->URL . "/account/login/");
                }
                $items = explode(',', $this->Session->Cart);
                $count = count($items);
                $s = $count > 1 ? 's' : '';
                $contents = array();
                foreach ($items as $item) {
                    $contents[$item] = isset($contents[$item]) ? ++$contents[$item] : 1;
                }
                $purchases = '';
                foreach ($contents as $id => $quantity) {
                    $query = "SELECT `product_pin`, `product_id`, `product_title`, `product_description`, `product_price`\n\t\t\t\t\t\t\tFROM `{$this->DB->Prefix}ecommerce_products` \n\t\t\t\t\t\t\tWHERE `product_id` = {$id} LIMIT 1";
                    if ($product = $this->DB->FetchRow($query, "slave")) {
                        $purchases .= <<<EOH

{$quantity}x <a href="{$this->Site->URL}/shop/product/{$product['product_id']}/" target="_blank">{$product['product_title']} (#{$product['product_pin']})</a> (\${$product['product_price']})
<br />

EOH;
                    }
                }
                $this->Page->Content .= <<<EOH

<center>
\t<div class="style1" style="float: left;">
\t\t<strong><a href="{$this->Site->URL}/shop/cart/">View Cart</a></strong>
\t</div>
\t<div class="style1" style="float: left;">
\t\t<strong><a href="{$this->Site->URL}/shop/cart/information/">Information</a></strong>
\t</div>
\t<div class="style1" style="float: left;">
\t\t<strong><a href="{$this->Site->URL}/shop/cart/preview/">Preview</a></strong>
\t</div>
\t<div class="style1" style="float: left;">
\t\t<strong><a href="{$this->Site->URL}/shop/cart/payment/">Payment</a></strong>
\t</div>
\t<div class="style1 active" style="float: left;">
\t\t<strong>Review</strong>
\t</div>
\t<div class="style1 disabled" style="float: left;">
\t\t<strong>Complete</strong>
\t</div>
\t<div style="clear: both"></div>
</center>
<br /><br />
<center>
<strong>
\tBefore continuing, please confirm your order
\t<br />
\tand information are correct.
\t<br />
\tThank you for your patience.
</strong>
</center>
<br /><br /><br />

EOH;
                $type = $this->Session['type'];
                if ($type == "pp_express") {
                    $this->Page->Content .= <<<EOH

<h2>Amount: \${$this->Session['amount']} USD</h2>
<br /><br /><br />
<h2>Purchases</h2>
<br />
{$purchases}
<br /><br /><br />
<h2>Payment Information</h2>
<br />
<strong>Payment Method:</strong> PayPal
<br /><br /><br />
<h2>Billing Information</h2>
<br />
<strong>First Name:</strong> {$this->Session['billing_first_name']}
<br />
<strong>Last Name:</strong> {$this->Session['billing_last_name']}
<br />
<strong>Country:</strong> {$this->Session['billing_country']}
<br />
<strong>State:</strong> {$this->Session['billing_state']}
<br />
<strong>City:</strong> {$this->Session['billing_city']}
<br />
<strong>Street Address 1:</strong> {$this->Session['billing_street_1']}
<br />
<strong>Street Address 2:</strong> {$this->Session['billing_street_2']}
<br />
<strong>Postal Code:</strong> {$this->Session['billing_postal_code']}
<br />
<strong>Phone Number:</strong> {$this->Session['billing_phone_number']}
<br />
<strong>Fax Number:</strong> {$this->Session['billing_fax_number']}
<br /><br /><br />
<h2>Shipping Information</h2>
<br />
<strong>First Name:</strong> {$this->Session['shipping_first_name']}
<br />
<strong>Last Name:</strong> {$this->Session['shipping_last_name']}
<br />
<strong>Country:</strong> {$this->Session['shipping_country']}
<br />
<strong>State:</strong> {$this->Session['shipping_state']}
<br />
<strong>City:</strong> {$this->Session['shipping_city']}
<br />
<strong>Street Address 1:</strong> {$this->Session['shipping_street_1']}
<br />
<strong>Street Address 2:</strong> {$this->Session['shipping_street_2']}
<br />
<strong>Postal Code:</strong> {$this->Session['shipping_postal_code']}
<br />
<strong>Phone Number:</strong> {$this->Session['shipping_phone_number']}
<br />
<strong>Fax Number:</strong> {$this->Session['shipping_fax_number']}
<br /><br /><br />
<h2>Order Notes</h2>
<br />
{$this->Session['order_notes']}
<br /><br /><br />
<center>
<form action="{$this->Site->URL}/shop/cart/complete/" method="post">
\t<input type="submit" value="Continue" class="submit" />
</form>
</center>
<br /><br /><br />

EOH;
                } else {
                    if ($type == "pp_cc") {
                        $this->Session->Merge($_REQUEST);
                        $creditCardNumber = "xxxx-xxxx-xxxx-" . substr($this->Session['creditCardNumber'], 12, 16);
                        $this->Page->Content .= <<<EOH

<h2>Amount: \${$this->Session['amount']} USD</h2>
<br /><br /><br />
<h2>Purchases</h2>
<br />
{$purchases}
<br /><br /><br />
<h2>Payment Information</h2>
<br />
<strong>Payment Method:</strong> Credit Card
<br />
<strong>First Name:</strong> {$this->Session['user_first_name']}
<br />
<strong>Last Name:</strong> {$this->Session['user_last_name']}
<br />
<strong>Card Type:</strong> {$this->Session['creditCardType']}
<br />
<strong>Card Number:</strong> {$creditCardNumber}
<br />
<strong>Expiration Date:</strong> {$this->Session['expDateMonth']}/{$this->Session['expDateYear']}
<br />
<strong>Card Verification Number:</strong> {$this->Session['cvv2Number']}
<br />
<strong>Country:</strong> {$this->Session['user_country']}
<br />
<strong>State:</strong> {$this->Session['user_state']}
<br />
<strong>City:</strong> {$this->Session['user_city']}
<br />
<strong>Street Address 1:</strong> {$this->Session['user_street_1']}
<br />
<strong>Street Address 2:</strong> {$this->Session['user_street_2']}
<br />
<strong>Postal Code:</strong> {$this->Session['user_postal_code']}
<br /><br /><br />
<h2>Billing Information</h2>
<br />
<strong>First Name:</strong> {$this->Session['billing_first_name']}
<br />
<strong>Last Name:</strong> {$this->Session['billing_last_name']}
<br />
<strong>Country:</strong> {$this->Session['billing_country']}
<br />
<strong>State:</strong> {$this->Session['billing_state']}
<br />
<strong>City:</strong> {$this->Session['billing_city']}
<br />
<strong>Street Address 1:</strong> {$this->Session['billing_street_1']}
<br />
<strong>Street Address 2:</strong> {$this->Session['billing_street_2']}
<br />
<strong>Postal Code:</strong> {$this->Session['billing_postal_code']}
<br />
<strong>Phone Number:</strong> {$this->Session['billing_phone_number']}
<br />
<strong>Fax Number:</strong> {$this->Session['billing_fax_number']}
<br /><br /><br />
<h2>Shipping Information</h2>
<br />
<strong>First Name:</strong> {$this->Session['shipping_first_name']}
<br />
<strong>Last Name:</strong> {$this->Session['shipping_last_name']}
<br />
<strong>Country:</strong> {$this->Session['shipping_country']}
<br />
<strong>State:</strong> {$this->Session['shipping_state']}
<br />
<strong>City:</strong> {$this->Session['shipping_city']}
<br />
<strong>Street Address 1:</strong> {$this->Session['shipping_street_1']}
<br />
<strong>Street Address 2:</strong> {$this->Session['shipping_street_2']}
<br />
<strong>Postal Code:</strong> {$this->Session['shipping_postal_code']}
<br />
<strong>Phone Number:</strong> {$this->Session['shipping_phone_number']}
<br />
<strong>Fax Number:</strong> {$this->Session['shipping_fax_number']}
<br /><br /><br />
<h2>Order Notes</h2>
<br />
{$this->Session['order_notes']}
<br /><br /><br />
<center>
<form action="{$this->Site->URL}/shop/cart/complete/" method="post">
\t<input type="submit" value="Continue" class="submit" />
</form>
</center>
<br /><br /><br />

EOH;
                    } else {
                        if ($type == "pp_basic") {
                            $this->Page->Content .= <<<EOH

<h2>Amount: \${$this->Session['amount']} USD</h2>
<br /><br /><br />
<h2>Purchases</h2>
<br />
{$purchases}
<br /><br /><br />
<h2>Payment Information</h2>
<br />
<strong>Payment Method:</strong> PayPal
<br /><br /><br />
<h2>Billing Information</h2>
<br />
<strong>First Name:</strong> {$this->Session['billing_first_name']}
<br />
<strong>Last Name:</strong> {$this->Session['billing_last_name']}
<br />
<strong>Country:</strong> {$this->Session['billing_country']}
<br />
<strong>State:</strong> {$this->Session['billing_state']}
<br />
<strong>City:</strong> {$this->Session['billing_city']}
<br />
<strong>Street Address 1:</strong> {$this->Session['billing_street_1']}
<br />
<strong>Street Address 2:</strong> {$this->Session['billing_street_2']}
<br />
<strong>Postal Code:</strong> {$this->Session['billing_postal_code']}
<br />
<strong>Phone Number:</strong> {$this->Session['billing_phone_number']}
<br />
<strong>Fax Number:</strong> {$this->Session['billing_fax_number']}
<br /><br /><br />
<h2>Shipping Information</h2>
<br />
<strong>First Name:</strong> {$this->Session['shipping_first_name']}
<br />
<strong>Last Name:</strong> {$this->Session['shipping_last_name']}
<br />
<strong>Country:</strong> {$this->Session['shipping_country']}
<br />
<strong>State:</strong> {$this->Session['shipping_state']}
<br />
<strong>City:</strong> {$this->Session['shipping_city']}
<br />
<strong>Street Address 1:</strong> {$this->Session['shipping_street_1']}
<br />
<strong>Street Address 2:</strong> {$this->Session['shipping_street_2']}
<br />
<strong>Postal Code:</strong> {$this->Session['shipping_postal_code']}
<br />
<strong>Phone Number:</strong> {$this->Session['shipping_phone_number']}
<br />
<strong>Fax Number:</strong> {$this->Session['shipping_fax_number']}
<br /><br /><br />
<h2>Order Notes</h2>
<br />
{$this->Session['order_notes']}
<br /><br /><br />
<center>
<form action="{$this->Site->URL}/shop/cart/complete/" method="post">
\t<input type="submit" value="Continue" class="submit" />
</form>
</center>
<br /><br /><br />

EOH;
                        }
                    }
                }
                break;
            case "information":
                if ($settings['require_authorization'] && !$this->User->Validated) {
                    $this->Redirect($this->Site->URL . "/account/login/");
                }
                $this->Session['type'] = $this->Request['type'] ? $this->Request['type'] : $this->Session['type'];
                if ($this->Session['type'] === "pp_express") {
                    $this->Session['paymentType'] = $this->Request['paymentType'] ? $this->Request['paymentType'] : $this->Session['paymentType'];
                    $this->Session['currencyCodeType'] = $this->Request['currencyCodeType'] ? $this->Request['currencyCodeType'] : $this->Session['currencyCodeType'];
                } else {
                    if ($this->Session['type'] === "pp_cc") {
                        $this->Session['paymentType'] = $this->Request['paymentType'] ? $this->Request['paymentType'] : $this->Session['paymentType'];
                    }
                }
                //$this->Session->Merge($_REQUEST);
                $type = $this->Session['type'];
                $country = <<<EOH

\t<option selected="selected" value="">--- Choose Country ---</option>
     <option value="United States">United States</option>
    <option value="Canada">Canada</option>
    <option value="Afghanistan">Afghanistan</option>
    <option value="Albania">Albania</option>
    <option value="Algeria">Algeria</option>
    <option value="Andorra">Andorra</option>
    <option value="Angola">Angola</option>
    <option value="Anguilla">Anguilla</option>
    <option value="Antigua and Barbuda">Antigua and Barbuda</option>
    <option value="Argentina">Argentina</option>
    <option value="Armenia">Armenia</option>
    <option value="Aruba">Aruba</option>
    <option value="Australia">Australia</option>
    <option value="Austria">Austria</option>
    <option value="Azerbaijan">Azerbaijan</option>
    <option value="Bahamas">Bahamas</option>
    <option value="Bahrain">Bahrain</option>
    <option value="Bangladesh">Bangladesh</option>
    <option value="Barbados">Barbados</option>
    <option value="Belarus">Belarus</option>
    <option value="Belgium">Belgium</option>
    <option value="Belize">Belize</option>
    <option value="Benin">Benin</option>
    <option value="Bermuda">Bermuda</option>
    <option value="Bhutan">Bhutan</option>
    <option value="Bolivia">Bolivia</option>
    <option value="Borneo">Borneo</option>
    <option value="Bosnia and Herzegovina">Bosnia and Herzegovina</option>
    <option value="Botswana">Botswana</option>
    <option value="Brazil">Brazil</option>
    <option value="Brunei">Brunei</option>
    <option value="Bulgaria">Bulgaria</option>
    <option value="Burkina Faso">Burkina 
      Faso</option>
    <option value="Burma">Burma</option>
    <option value="Burundi">Burundi</option>
    <option value="Cameroon">Cameroon</option>
    <option value="Cambodia">Cambodia</option>
    <option value="Cape Verde">Cape 
      Verde</option>
    <option value="Central African Rep">Central African 
      Republic</option>
    <option value="Chad">Chad</option>
    <option value="Chile">Chile</option>
    <option value="China">China</option>
    <option value="Cote d'Ivoire">Cote d'Ivoire</option>
    <option value="Colombia">Colombia</option>
    <option value="Comoros">Comoros</option>
    <option value="Congo, Democratic Republic of">Congo, Democratic Republic 
      of</option>
    <option value="Costa Rica, Republic of the">Costa Rica, 
      Republic of the</option>
    <option value="Croatia">Croatia</option>
    <option value="Cuba">Cuba</option>
    <option value="Cyprus">Cyprus</option>
    <option value="Czech Republic">Czech Republic</option>
    <option value="Denmark">Denmark</option>
    <option value="Djibouti">Djibouti</option>
    <option value="Dominica">Dominica</option>
    <option value="Dominican Republic">Dominican Republic</option>
    <option value="East Timor">East Timor</option>
    <option value="Ecuador">Ecuador</option>
    <option value="Egypt">Egypt</option>
    <option value="El Salvador">El Salvador</option>
    <option value="Equatorial Guinea">Equatorial Guinea</option>
    <option value="Eritrea">Eritrea</option>
    <option value="Estonia">Estonia</option>
    <option value="Ethiopia">Ethiopia</option>
    <option value="Fiji">Fiji</option>
    <option value="Finland">Finland</option>
    <option value="France">France</option>
    <option value="Gabon">Gabon</option>
    <option value="Gambia">Gambia</option>
    <option value="Georgia">Georgia</option>
    <option value="Germany">Germany</option>
    <option value="Ghana">Ghana</option>
    <option value="Gibraltar">Gibraltar</option>
    <option value="Greece">Greece</option>
    <option value="Greenland">Greenland</option>
    <option value="Grenada">Grenada</option>
    <option value="Guadeloupe">Guadeloupe</option>
    <option value="Guatemala">Guatemala</option>
    <option value="Guinea">Guinea</option>
    <option value="Guinea-Bissau">Guinea-Bissau</option>
    <option value="Guyana">Guyana</option>
    <option value="Haiti">Haiti</option>
    <option value="Honduras">Honduras</option>
    <option value="Hong Kong">Hong 
      Kong</option>
    <option value="Hungary">Hungary</option>
    <option value="Iceland">Iceland</option>
    <option value="India">India</option>
    <option value="Indonesia">Indonesia</option>
    <option value="Iran">Iran</option>
    <option value="Iraq">Iraq</option>
    <option value="Ireland">Ireland</option>
    <option value="Israel">Israel</option>
    <option value="Italy">Italy</option>
    <option value="Jamaica">Jamaica</option>
    <option value="Japan">Japan</option>
    <option value="Jordan">Jordan</option>
    <option value="Kazakhstan">Kazakhstan</option>
    <option value="Kenya">Kenya</option>
    <option value="Kiribati">Kiribati</option>
    <option value="Korea, North">Korea, North</option>
    <option value="Korea, South">Korea, South</option>
    <option value="Kosovo">Kosovo</option>
    <option value="Kuwait">Kuwait</option>
    <option value="Kyrgyzstan">Kyrgyzstan</option>
    <option value="Laos">Laos</option>
    <option value="Latvia">Latvia</option>
    <option value="Lebanon">Lebanon</option>
    <option value="Lesotho">Lesotho</option>
    <option value="Liberia">Liberia</option>
    <option value="Libya">Libya</option>
    <option value="Liechtenstein">Liechtenstein</option>
    <option value="Lithuania">Lithuania</option>
    <option value="Luxembourg">Luxembourg</option>
    <option value="Macedonia">Macedonia</option>
    <option value="Madagascar">Madagascar</option>
    <option value="Malawi">Malawi</option>
    <option value="Malaysia">Malaysia</option>
    <option value="Maldives">Maldives</option>
    <option value="Mali">Mali</option>
    <option value="Malta">Malta</option>
    <option value="Marshall Islands">Marshall Islands</option>
    <option value="Martinique">Martinique</option>
    <option value="Mauritania">Mauritania</option>
    <option value="Mauritius">Mauritius</option>
    <option value="Mexico">Mexico</option>
    <option value="Micronesia, Federated States of">Micronesia, Federated 
      States of</option>
    <option value="Moldova">Moldova</option>
    <option value="Monaco">Monaco</option>
    <option value="Mongolia">Mongolia</option>
    <option value="Montserrat">Montserrat</option>
    <option value="Morocco">Morocco</option>
    <option value="Mozambique">Mozambique</option>
    <option value="Namibia">Namibia</option>
    <option value="Naura">Naura</option>
    <option value="Nepal">Nepal</option>
    <option value="Netherlands">Netherlands</option>
    <option value="New Zealand">New 
      Zealand</option>
    <option value="Nicaragua">Nicaragua</option>
    <option value="Niger">Niger</option>
    <option value="Nigeria">Nigeria</option>
    <option value="Norway">Norway</option>
    <option value="Oman">Oman</option>
    <option value="Pakistan">Pakistan</option>
    <option value="Palau">Palau</option>
    <option value="Panama">Panama</option>
    <option value="Papua New Guinea">Papua New Guinea</option>
    <option value="Paraguay">Paraguay</option>
    <option value="Peru">Peru</option>
    <option value="Philippines">Philippines</option>
    <option value="Poland">Poland</option>
    <option value="Portugal">Portugal</option>
    <option value="Qatar">Qatar</option>
    <option value="Romania">Romania</option>
    <option value="Russia">Russia</option>
    <option value="Rwanda">Rwanda</option>
    <option value="Samoa">Samoa</option>
    <option value="Saint Kitts and Nevis">Saint Kitts and Nevis</option>
    <option value="Saint Lucia">Saint Lucia</option>
    <option value="Saint Vincent and Grenadines">Saint Vincent and 
      Grenadines</option>
    <option value="San Marino">San Marino</option>
    <option value="Sao Tome and Principe">Sao Tome and Principe</option>
    <option value="Saudi Arabia">Saudi Arabia</option>
    <option value="Senegal">Senegal</option>
    <option value="Seychelles">Seychelles</option>
    <option value="Sierra Leone">Sierra 
      Leone</option>
    <option value="Singapore">Singapore</option>
    <option value="Slovakia">Slovakia</option>
    <option value="Slovenia">Slovenia</option>
    <option value="Solomon Islands">Solomon 
      Islands</option>
    <option value="Somalia">Somalia</option>
    <option value="South Africa">South Africa</option>
    <option value="Spain">Spain</option>
    <option value="Sri Lanka">Sri Lanka</option>
    <option value="Sudan">Sudan</option>
    <option value="Suriname">Suriname</option>
    <option value="Swaziland">Swaziland</option>
    <option value="Sweden">Sweden</option>
    <option value="Switzerland">Switzerland</option>
    <option value="Syria">Syria</option>
    <option value="Taiwan">Taiwan</option>
    <option value="Tajikistan">Tajikistan</option>
    <option value="Tanzania">Tanzania</option>
    <option value="Thailand">Thailand</option>
    <option value="Togo">Togo</option>
    <option value="Tonga">Tonga</option>
    <option value="Trinidad and Tobago">Trinidad and Tobago</option>
    <option value="Tunisia">Tunisia</option>
    <option value="Turkey">Turkey</option>
    <option value="Turkmenistan">Turkmenistan</option>
    <option value="Tuvalu">Tuvalu</option>
    <option value="Uganda">Uganda</option>
    <option value="Ukraine">Ukraine</option>
    <option value="United Arab Emirates">United Arab Emirates</option>
    <option value="United Kingdom">United Kingdom</option>
    <option value="Uruguay">Uruguay</option>
    <option value="Uzbekistan">Uzbekistan</option>
    <option value="Vanuatu">Vanuatu</option>
    <option value="Vatican City">Vatican 
      City</option>
    <option value="Venezuela">Venezuela</option>
    <option value="Vietnam">Vietnam</option>
    <option value="Virgin Islands">Virgin 
      Islands</option>
    <option value="West Bank and Gaza">West Bank and 
      Gaza</option>
    <option value="Western Sahara">Western Sahara</option>
    <option value="Yemen">Yemen</option>
    <option value="Yugoslavia">Yugoslavia, 
      Federal Republic of</option>
    <option value="Zambia">Zambia</option>
    <option value="Zimbabwe">Zimbabwe</option>

EOH;
                $country = str_replace("value=\"{$this->User['country']}\"", "value=\"{$this->User['country']}\" selected=\"selected\"", $country);
                $state = <<<EOH

\t<option value="">--- Choose State ---</option>
\t<option value="NA">Outside USA</option>
\t<option value="AL">Alabama</option>
\t<option value="AK">Alaska</option>
\t<option value="AZ">Arizona</option>
\t<option value="AR">Arkansas</option>
\t<option value="CA">California</option>
\t<option value="CO">Colorado</option>
\t<option value="CT">Connecticut</option>
\t<option value="DE">Delaware</option>
\t<option value="DC">Dist of Columbia</option>
\t<option value="FL">Florida</option>
\t<option value="GA">Georgia</option>
\t<option value="HI">Hawaii</option>
\t<option value="ID">Idaho</option>
\t<option value="IL">Illinois</option>
\t<option value="IN">Indiana</option>
\t<option value="IA">Iowa</option>
\t<option value="KS">Kansas</option>
\t<option value="KY">Kentucky</option>
\t<option value="LA">Louisiana</option>
\t<option value="ME">Maine</option>
\t<option value="MD">Maryland</option>
\t<option value="MA">Massachusetts</option>
\t<option value="MI">Michigan</option>
\t<option value="MN">Minnesota</option>
\t<option value="MS">Mississippi</option>
\t<option value="MO">Missouri</option>
\t<option value="MT">Montana</option>
\t<option value="NE">Nebraska</option>
\t<option value="NV">Nevada</option>
\t<option value="NH">New Hampshire</option>
\t<option value="NJ">New Jersey</option>
\t<option value="NM">New Mexico</option>
\t<option value="NY">New York</option>
\t<option value="NC">North Carolina</option>
\t<option value="ND">North Dakota</option>
\t<option value="OH">Ohio</option>
\t<option value="OK">Oklahoma</option>
\t<option value="OR">Oregon</option>
\t<option value="PA">Pennsylvania</option>
\t<option value="RI">Rhode Island</option>
\t<option value="SC">South Carolina</option>
\t<option value="SD">South Dakota</option>
\t<option value="TN">Tennessee</option>
\t<option value="TX">Texas</option>
\t<option value="UT">Utah</option>
\t<option value="VT">Vermont</option>
\t<option value="VA">Virginia</option>
\t<option value="WA">Washington</option>
\t<option value="WV">West Virginia</option>
\t<option value="WI">Wisconsin</option>
\t<option value="WY">Wyoming</option>

EOH;
                $state = str_replace("value=\"{$this->User['state']}\"", "value=\"{$this->User['state']}\" selected=\"selected\"", $state);
                $this->Page->Content .= <<<EOH

<script src="{$this->Site->URL}/libs/spry/SpryValidationTextField.js" type="text/javascript"></script>
<script src="{$this->Site->URL}/libs/spry/SpryValidationSelect.js" type="text/javascript"></script>
<link href="{$this->Site->URL}/libs/spry/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="{$this->Site->URL}/libs/spry/SpryValidationSelect.css" rel="stylesheet" type="text/css" />
\t\t\t\t\t
<center>
\t<div class="style1" style="float: left;">
\t\t<strong><a href="{$this->Site->URL}/shop/cart/">View Cart</a></strong>
\t</div>
\t<div class="style1 active" style="float: left;">
\t\t<strong>Information</strong>
\t</div>
\t<div class="style1 disabled" style="float: left;">
\t\t<strong>Preview</strong>
\t</div>
\t<div class="style1 disabled" style="float: left;">
\t\t<strong>Payment</strong>
\t</div>
\t<div class="style1 disabled" style="float: left;">
\t\t<strong>Review</strong>
\t</div>
\t<div class="style1 disabled" style="float: left;">
\t\t<strong>Complete</strong>
\t</div>
\t<div style="clear: both"></div>
</center>
<br /><br />

<form action="{$this->Site->URL}/shop/cart/preview/" method="post">
\t<h2>Shipping Information</h2>
\t<br />
\t<center>
\t<table id="shipping_information" width="100%" cellpadding="0" cellspacing="5">
        <tr>
            <td><strong>First Name <span style="color: #FF0000">*</span></strong></td>
            <td>
            \t<span id="sprytextfield1">
            \t\t<input name="shipping_first_name" type="text" size="20" maxlength="50" value="{$this->User['first_name']}" />
            \t\t<span class="textfieldRequiredMsg">A value is required.</span>
            \t</span>
            </td>
        </tr>
        <tr>
            <td><strong>Last Name <span style="color: #FF0000">*</span></strong></td>
            <td>
            \t<span id="sprytextfield2">
            \t\t<input name="shipping_last_name" type="text" size="20" maxlength="50" value="{$this->User['last_name']}" />
            \t\t<span class="textfieldRequiredMsg">A value is required.</span>
            \t</span>
            </td>
        </tr>
        <tr>
            <td><strong>Country <span style="color: #FF0000">*</span></strong></td>
            <td>
            \t<span id="spryselect1">
            \t\t<select name="shipping_country">{$country}</select>
            \t\t<span class="selectRequiredMsg">Please select an item.</span>
            \t\t<span class="selectInvalidMsg">Please select a valid item.</span>
            \t</span>
            </td>
        </tr>
        <tr>
            <td><strong>State <span style="color: #FF0000">*</span></strong></td>
            <td>
            \t<span id="spryselect2">
            \t\t<select name="shipping_state">{$state}</select>
            \t\t<span class="selectInvalidMsg">Please select a valid item.</span>
            \t\t<span class="selectRequiredMsg">Please select an item.</span>
            \t</span>
            </td>
        </tr>
        <tr>
            <td><strong>City <span style="color: #FF0000">*</span></strong></td>
            <td>
            \t<span id="sprytextfield3">
            \t\t<input name="shipping_city" type="text" size="20" maxlength="40" value="{$this->User['city']}" />
           \t\t\t<span class="textfieldRequiredMsg">A value is required.</span>
           \t\t</span>
\t\t\t</td>
        </tr>
        <tr>
            <td><strong>Street Address 1 <span style="color: #FF0000">*</span></strong></td>
            <td>
            \t<span id="sprytextfield4">
            \t\t<input name="shipping_street_1" type="text" size="20" maxlength="100" value="{$this->User['street_1']}" />
        \t\t\t<span class="textfieldRequiredMsg">A value is required.</span>
        \t\t</span>
        \t</td>
\t\t</tr>
        <tr>
            <td><strong>Street Address 2</strong></td>
            <td>
            \t\t<input name="shipping_street_2" type="text" size="20" maxlength="100" value="{$this->User['street_2']}" />
            </td>
        </tr>
        <tr>
            <td><strong>Postal Code <span style="color: #FF0000">*</span></strong></td>
            <td>
            \t<span id="sprytextfield5">
            \t\t<input name="shipping_postal_code" type="text" size="20" maxlength="10" value="{$this->User['postal_code']}" />
            \t\t<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span>
            \t</span>
            </td>
        </tr>
        <tr>
            <td><strong>Phone Number <span style="color: #FF0000">*</span></strong></td>
            <td>
            \t<span id="sprytextfield6">
            \t\t<input name="shipping_phone_number" type="text" size="20" maxlength="25" value="{$this->User['phone_number']}" />
            \t\t<span class="textfieldRequiredMsg">A value is required.</span>
            \t\t<span class="textfieldInvalidFormatMsg">Invalid format.</span>
            \t</span>
           </td>
        </tr>
        <tr>
            <td><strong>Fax Number</strong></td>
            <td>
            \t<span id="sprytextfield7">
            \t\t<input name="shipping_fax_number" type="text" size="20" maxlength="25" value="{$this->User['fax_number']}" />
            \t</span>
            </td>
        </tr>
    </table>
    </center>
    <br /><br />
\t<h2>Billing Information</h2>
\t<br />
\t<center>
\t<input checked type="checkbox" name="same_information" value="yes" /> Same billing and shipping information.
\t<br />
\t<table id="billing_information" width="100%" cellpadding="0" cellspacing="5">
        <tr>
            <td><strong>First Name <span style="color: #FF0000">*</span></strong></td>
            <td>
            \t<span id="sprytextfield8">
            \t\t<input disabled name="billing_first_name" type="text" size="20" maxlength="50" value="{$this->User['first_name']}" />
            \t\t<span class="textfieldRequiredMsg">A value is required.</span>
            \t</span>
            </td>
        </tr>
        <tr>
            <td><strong>Last Name <span style="color: #FF0000">*</span></strong></td>
            <td>
            \t<span id="sprytextfield9">
            \t\t<input disabled name="billing_last_name" type="text" size="20" maxlength="50" value="{$this->User['last_name']}" />
            \t\t<span class="textfieldRequiredMsg">A value is required.</span>
            \t</span>
            </td>
        </tr>
        <tr>
            <td><strong>Country <span style="color: #FF0000">*</span></strong></td>
            <td>
            \t<span id="spryselect3">
            \t\t<select disabled name="billing_country">{$country}</select>
            \t\t<span class="selectRequiredMsg">Please select an item.</span>
            \t\t<span class="selectInvalidMsg">Please select a valid item.</span>
            \t</span>
            </td>
        </tr>
        <tr>
            <td><strong>State <span style="color: #FF0000">*</span></strong></td>
            <td>
            \t<span id="spryselect4">
            \t\t<select disabled name="billing_state">{$state}</select>
            \t\t<span class="selectInvalidMsg">Please select a valid item.</span>
            \t\t<span class="selectRequiredMsg">Please select an item.</span>
            \t</span>
            </td>
        </tr>
        <tr>
            <td><strong>City <span style="color: #FF0000">*</span></strong></td>
            <td>
            \t<span id="sprytextfield10">
            \t\t<input disabled name="billing_city" type="text" size="20" maxlength="40" value="{$this->User['city']}" />
           \t\t\t<span class="textfieldRequiredMsg">A value is required.</span>
           \t\t</span>
\t\t\t</td>
        </tr>
        <tr>
            <td><strong>Street Address 1 <span style="color: #FF0000">*</span></strong></td>
            <td>
            \t<span id="sprytextfield11">
            \t\t<input disabled name="billing_street_1" type="text" size="20" maxlength="100" value="{$this->User['street_1']}" />
        \t\t\t<span class="textfieldRequiredMsg">A value is required.</span>
        \t\t</span>
        \t</td>
\t\t</tr>
        <tr>
            <td><strong>Street Address 2</strong></td>
            <td>
            \t\t<input disabled name="billing_street_2" type="text" size="20" maxlength="100" value="{$this->User['street_2']}" />
            </td>
        </tr>
        <tr>
            <td><strong>Postal Code <span style="color: #FF0000">*</span></strong></td>
            <td>
            \t<span id="sprytextfield12">
            \t\t<input disabled name="billing_postal_code" type="text" size="20" maxlength="10" value="{$this->User['postal_code']}" />
            \t\t<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span>
            \t</span>
            </td>
        </tr>
        <tr>
            <td><strong>Phone Number <span style="color: #FF0000">*</span></strong></td>
            <td>
            \t<span id="sprytextfield13">
            \t\t<input disabled name="billing_phone_number" type="text" size="20" maxlength="25" value="{$this->User['phone_number']}" />
            \t\t<span class="textfieldRequiredMsg">A value is required.</span>
            \t\t<span class="textfieldInvalidFormatMsg">Invalid format.</span>
            \t</span>
           </td>
        </tr>
        <tr>
            <td><strong>Fax Number</strong></td>
            <td>
            \t<span id="sprytextfield14">
            \t\t<input disabled name="billing_fax_number" type="text" size="20" maxlength="25" value="{$this->User['fax_number']}" />
            \t</span>
            </td>
        </tr>
    </table>
    </center>
    <br /><br />
\t<h2>Ordering Notes</h2>
\t<br />
\t<center>
    <textarea name="order_notes" cols="40" rows="10"></textarea>
    </center>
\t<br /><br />
\t<center><input type="submit" value="Continue" class="submit" /></center>
</form>
<br /><br />
<script type="text/javascript">
\tjQuery(document).ready(function(\$)
\t{
\t\t\$("[name='same_information']").click(function()
\t\t{
\t\t\tif(\$(this).is(":checked"))
\t\t\t\t\$("#billing_information").find("input, select").attr("disabled", true); 
\t\t\telse
\t\t\t\t\$("#billing_information").find("input, select").removeAttr("disabled");
\t\t});\t\t\t
\t});
</script>

<script type="text/javascript">
<!--
new Spry.Widget.ValidationTextField("sprytextfield1", "none", {validateOn:["blur", "change"]});
new Spry.Widget.ValidationTextField("sprytextfield2", "none", {validateOn:["blur", "change"]});
new Spry.Widget.ValidationSelect("spryselect1", {validateOn:["blur", "change"], invalidValue:""});
new Spry.Widget.ValidationSelect("spryselect2", {validateOn:["blur", "change"], invalidValue:""});
new Spry.Widget.ValidationTextField("sprytextfield3", "none", {validateOn:["blur", "change"]});
new Spry.Widget.ValidationTextField("sprytextfield4", "none", {validateOn:["blur", "change"]});
new Spry.Widget.ValidationTextField("sprytextfield5", "zip_code", {validateOn:["blur"]});
new Spry.Widget.ValidationTextField("sprytextfield6", "phone_number", {validateOn:["blur"], useCharacterMasking:true});

new Spry.Widget.ValidationTextField("sprytextfield8", "none", {validateOn:["blur", "change"]});
new Spry.Widget.ValidationTextField("sprytextfield9", "none", {validateOn:["blur", "change"]});
new Spry.Widget.ValidationSelect("spryselect3", {validateOn:["blur", "change"], invalidValue:""});
new Spry.Widget.ValidationSelect("spryselect4", {validateOn:["blur", "change"], invalidValue:""});
new Spry.Widget.ValidationTextField("sprytextfield10", "none", {validateOn:["blur", "change"]});
new Spry.Widget.ValidationTextField("sprytextfield11", "none", {validateOn:["blur", "change"]});
new Spry.Widget.ValidationTextField("sprytextfield12", "zip_code", {validateOn:["blur"]});
new Spry.Widget.ValidationTextField("sprytextfield13", "phone_number", {validateOn:["blur"], useCharacterMasking:true});
//-->
</script>

EOH;
                break;
            case "complete":
                if ($settings['require_authorization'] && !$this->User->Validated) {
                    $this->Redirect($this->Site->URL . "/account/login/");
                }
                $type = $this->Session['type'];
                if ($type == "pp_express") {
                    require_once PATH . "/libs/paypal/constants.php";
                    require_once PATH . "/libs/paypal/CallerService.php";
                    /* Gather the information to make the final call to
                       finalize the PayPal payment.  The variable nvpstr
                       holds the name value pairs
                       */
                    $token = urlencode($this->Session['token']);
                    $paymentAmount = urlencode($this->Session['amount']);
                    $paymentType = urlencode($this->Session['paymentType']);
                    $currCodeType = urlencode($this->Session['currCodeType']);
                    $payerID = urlencode($this->Session['payer_id']);
                    $serverName = urlencode($this->Session['SERVER_NAME']);
                    $nvpstr = '&TOKEN=' . $token . '&PAYERID=' . $payerID . '&PAYMENTACTION=' . $paymentType . '&AMT=' . $paymentAmount . '&CURRENCYCODE=' . $currCodeType . '&IPADDRESS=' . $serverName;
                    /* Make the call to PayPal to finalize payment
                       If an error occured, show the resulting errors
                       */
                    $resArray = hash_call("DoExpressCheckoutPayment", $nvpstr);
                    /* Display the API response back to the browser.
                       If the response from PayPal was a success, display the response parameters'
                       If the response was an error, display the errors received using APIError.php.
                       */
                    $ack = strtoupper($resArray["ACK"]);
                    if ($ack == "SUCCESS") {
                        $query = array();
                        $query[] = "`order_amount` = '" . $resArray['AMT'] . "'";
                        if ($this->Session['order_products']) {
                            $query[] = "`order_products` = '" . rawurldecode($this->Session['order_products']) . "'";
                        }
                        if ($currCodeType) {
                            $query[] = "`order_currency` = '" . $currCodeType . "'";
                        }
                        if ($resArray['TRANSACTIONID']) {
                            $query[] = "`order_transaction_id` = '" . $resArray['TRANSACTIONID'] . "'";
                        }
                        $query[] = "`shipping_first_name` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_first_name'])) . "'";
                        $query[] = "`shipping_last_name` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_last_name'])) . "'";
                        $query[] = "`shipping_street_1` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_street_1'])) . "'";
                        $query[] = "`shipping_street_2` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_street_2'])) . "'";
                        $query[] = "`shipping_city` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_city'])) . "'";
                        $query[] = "`shipping_state` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_state'])) . "'";
                        $query[] = "`shipping_postal_code` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_postal_code'])) . "'";
                        $query[] = "`shipping_phone_number` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_phone_number'])) . "'";
                        $query[] = "`shipping_fax_number` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_fax_number'])) . "'";
                        $query[] = "`shipping_country` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_country'])) . "'";
                        $query[] = "`billing_first_name` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_first_name'])) . "'";
                        $query[] = "`billing_last_name` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_last_name'])) . "'";
                        $query[] = "`billing_street_1` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_street_1'])) . "'";
                        $query[] = "`billing_street_2` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_street_2'])) . "'";
                        $query[] = "`billing_city` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_city'])) . "'";
                        $query[] = "`billing_state` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_state'])) . "'";
                        $query[] = "`billing_postal_code` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_postal_code'])) . "'";
                        $query[] = "`billing_phone_number` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_phone_number'])) . "'";
                        $query[] = "`billing_fax_number` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_fax_number'])) . "'";
                        $query[] = "`billing_country` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_country'])) . "'";
                        if ($this->User['id']) {
                            $query[] = "`user_id` = '" . $this->User['id'] . "'";
                        }
                        if ($this->Session->Cart) {
                            $query[] = "`order_products` = '" . $this->Session->Cart . "'";
                        }
                        $query[] = "`order_status` = 'Completed'";
                        $query[] = "`order_type` = 'PayPal Express'";
                        $query[] = "`order_date` = FROM_UNIXTIME(" . time() . ")";
                        $query[] = "`order_notes` = '" . rawurldecode($this->Session['order_notes']) . "'";
                        $query = "INSERT INTO `{$this->DB->Prefix}ecommerce_orders` SET " . fix_query(implode(',', $query));
                        $this->DB->Query($query);
                        $order_id = mysql_insert_id();
                        // clear the cart
                        $this->Session->Cart = '';
                        $this->Page->Content .= <<<EOH

<center>
\t<div class="style1" style="float: left;">
\t\t<strong><a href="{$this->Site->URL}/shop/cart/">View Cart</a></strong>
\t</div>
\t<div class="style1" style="float: left;">
\t\t<strong>Information</strong>
\t</div>
\t<div class="style1" style="float: left;">
\t\t<strong>Preview</strong>
\t</div>
\t<div class="style1" style="float: left;">
\t\t<strong>Payment</strong>
\t</div>
\t<div class="style1" style="float: left;">
\t\t<strong>Review</strong>
\t</div>
\t<div class="style1 active" style="float: left;">
\t\t<strong>Complete</strong>
\t</div>
\t<div style="clear: both"></div>
</center>
<br /><br />

<strong>Thank you for your payment!</strong>
<br /><br />
Your order number is {$order_id}. You should keep this number for future reference.
<br /><br />
If you have any questions about your order, please don't hesitate to <a href="{$this->Site->URL}/contact/">contact us</a>.
<br /><br />
<a href="{$this->Site->URL}/"><< Return to Home</a>

EOH;
                        $template =& $this->Mail->LoadTemplate("ecommerce_order_received", array("order_id" => $order_id));
                        $this->Mail->Send($this->User->Email, $settings['order_email'], $template['title'], $template['content']);
                        $template =& $this->Mail->LoadTemplate("ecommerce_order_notify", array("order_id" => $order_id));
                        $this->Mail->Send($settings['order_email'], $settings['order_email'], $template['title'], $template['content']);
                    } else {
                        $this->Session['reshash'] = $resArray;
                        $this->Redirect($this->Site->URL . "/shop/cart/error/");
                    }
                } else {
                    if ($type == "pp_cc") {
                        require_once PATH . "/libs/paypal/constants.php";
                        require_once PATH . "/libs/paypal/CallerService.php";
                        /**
                         * Get required parameters from the web form for the request
                         */
                        $paymentType = urlencode($this->Session['paymentType']);
                        $firstName = urlencode($this->Session['user_first_name']);
                        $lastName = urlencode($this->Session['user_last_name']);
                        $creditCardType = urlencode($this->Session['creditCardType']);
                        $creditCardNumber = urlencode($this->Session['creditCardNumber']);
                        $expDateMonth = urlencode($this->Session['expDateMonth']);
                        // Month must be padded with leading zero
                        $padDateMonth = str_pad($expDateMonth, 2, '0', STR_PAD_LEFT);
                        $expDateYear = urlencode($this->Session['expDateYear']);
                        $cvv2Number = urlencode($this->Session['cvv2Number']);
                        $address1 = urlencode($this->Session['user_street_1']);
                        $address2 = urlencode($this->Session['user_street_2']);
                        $city = urlencode($this->Session['user_city']);
                        $state = urlencode($this->Session['user_state']);
                        $zip = urlencode($this->Session['user_postal_code']);
                        $amount = urlencode($this->Session['amount']);
                        $currencyCode = "USD";
                        /* Construct the request string that will be sent to PayPal.
                           The variable $nvpstr contains all the variables and is a
                           name value pair string with & as a delimiter */
                        $nvpstr = "&PAYMENTACTION={$paymentType}&AMT={$amount}&CREDITCARDTYPE={$creditCardType}&ACCT={$creditCardNumber}&EXPDATE=" . $padDateMonth . $expDateYear . "&CVV2={$cvv2Number}&FIRSTNAME={$firstName}&LASTNAME={$lastName}&STREET={$address1}&CITY={$city}&STATE={$state}" . "&ZIP={$zip}&COUNTRYCODE=US&CURRENCYCODE={$currencyCode}";
                        /* Make the API call to PayPal, using API signature.
                           The API response is stored in an associative array called $resArray */
                        $resArray = hash_call("doDirectPayment", $nvpstr);
                        /* Display the API response back to the browser.
                           If the response from PayPal was a success, display the response parameters'
                           If the response was an error, display the errors received using APIError.php.
                           */
                        $ack = strtoupper($resArray["ACK"]);
                        if ($ack == "SUCCESS") {
                            $query = array();
                            $query[] = "`order_amount` = '" . $resArray['AMT'] . "'";
                            if ($this->Session['user_id']) {
                                $query[] = "`user_id` = '" . rawurldecode($this->Session['user_id']) . "'";
                            }
                            if ($this->Session['order_products']) {
                                $query[] = "`order_products` = '" . rawurldecode($this->Session['order_products']) . "'";
                            }
                            if ($currCodeType) {
                                $query[] = "`order_currency` = '" . $currCodeType . "'";
                            }
                            if ($resArray['TRANSACTIONID']) {
                                $query[] = "`order_transaction_id` = '" . $resArray['TRANSACTIONID'] . "'";
                            }
                            $query[] = "`shipping_first_name` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_first_name'])) . "'";
                            $query[] = "`shipping_last_name` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_last_name'])) . "'";
                            $query[] = "`shipping_street_1` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_street_1'])) . "'";
                            $query[] = "`shipping_street_2` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_street_2'])) . "'";
                            $query[] = "`shipping_city` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_city'])) . "'";
                            $query[] = "`shipping_state` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_state'])) . "'";
                            $query[] = "`shipping_postal_code` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_postal_code'])) . "'";
                            $query[] = "`shipping_phone_number` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_phone_number'])) . "'";
                            $query[] = "`shipping_fax_number` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_fax_number'])) . "'";
                            $query[] = "`shipping_country` = '" . mysql_real_escape_string(rawurldecode($this->Session['shipping_country'])) . "'";
                            $query[] = "`billing_first_name` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_first_name'])) . "'";
                            $query[] = "`billing_last_name` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_last_name'])) . "'";
                            $query[] = "`billing_street_1` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_street_1'])) . "'";
                            $query[] = "`billing_street_2` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_street_2'])) . "'";
                            $query[] = "`billing_city` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_city'])) . "'";
                            $query[] = "`billing_state` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_state'])) . "'";
                            $query[] = "`billing_postal_code` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_postal_code'])) . "'";
                            $query[] = "`billing_phone_number` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_phone_number'])) . "'";
                            $query[] = "`billing_fax_number` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_fax_number'])) . "'";
                            $query[] = "`billing_country` = '" . mysql_real_escape_string(rawurldecode($this->Session['billing_country'])) . "'";
                            if ($this->User['id']) {
                                $query[] = "`user_id` = '" . $this->User['id'] . "'";
                            }
                            if ($this->Session->Cart) {
                                $query[] = "`order_products` = '" . $this->Session->Cart . "'";
                            }
                            $query[] = "`order_status` = 'Completed'";
                            $query[] = "`order_type` = 'PayPal Pro'";
                            $query[] = "`order_date` = FROM_UNIXTIME(" . time() . ")";
                            $query[] = "`order_notes` = '" . rawurldecode($this->Session['order_notes']) . "'";
                            $query = fix_query(implode(',', $query));
                            $this->DB->Query("INSERT INTO `{$this->DB->Prefix}ecommerce_orders` SET {$query}");
                            $order_id = mysql_insert_id();
                            // clear the cart
                            $this->Session->Cart = '';
                            $this->Page->Content .= <<<EOH

<center>
\t<div class="style1" style="float: left;">
\t\t<strong><a href="{$this->Site->URL}/shop/cart/">View Cart</a></strong>
\t</div>
\t<div class="style1" style="float: left;">
\t\t<strong>Information</strong>
\t</div>
\t<div class="style1" style="float: left;">
\t\t<strong>Preview</strong>
\t</div>
\t<div class="style1" style="float: left;">
\t\t<strong>Payment</strong>
\t</div>
\t<div class="style1" style="float: left;">
\t\t<strong>Review</strong>
\t</div>
\t<div class="style1 active" style="float: left;">
\t\t<strong>Complete</strong>
\t</div>
\t<div style="clear: both"></div>
</center>
<br /><br />

<strong>Thank you for your payment!</strong>
<br /><br />
Your order number is {$order_id}. You should keep this number for future reference.
<br /><br />
If you have any questions about your order, please don't hesitate to <a href="{$this->Site->URL}/contact/">contact us</a>.
<br /><br />
<a href="{$this->Site->URL}/"><< Return to Home</a>

EOH;
                            $template =& $this->Mail->LoadTemplate("ecommerce_order_received", array("order_id" => $order_id));
                            $this->Mail->Send($this->User->Email, $settings['order_email'], $template['title'], $template['content']);
                            $template =& $this->Mail->LoadTemplate("ecommerce_order_notify", array("order_id" => $order_id));
                            $this->Mail->Send($settings['order_email'], $settings['order_email'], $template['title'], $template['content']);
                        } else {
                            $this->Session['reshash'] = $resArray;
                            $this->Redirect($this->Site->URL . "/shop/cart/error/");
                        }
                    } else {
                        if ($type == "pp_basic") {
                            $this->Page->Content .= <<<EOH

<center>
\t<div class="style1" style="float: left;">
\t\t<strong><a href="{$this->Site->URL}/shop/cart/">View Cart</a></strong>
\t</div>
\t<div class="style1" style="float: left;">
\t\t<strong>Information</strong>
\t</div>
\t<div class="style1" style="float: left;">
\t\t<strong>Preview</strong>
\t</div>
\t<div class="style1" style="float: left;">
\t\t<strong>Payment</strong>
\t</div>
\t<div class="style1" style="float: left;">
\t\t<strong>Review</strong>
\t</div>
\t<div class="style1 active" style="float: left;">
\t\t<strong>Complete</strong>
\t</div>
\t<div style="clear: both"></div>
</center>
<br /><br />

EOH;
                            $query = "SELECT `order_extra`, `order_amount`, `order_currency` FROM `{$this->DB->Prefix}ecommerce_orders` \n\t\t\t\t\t\t\t\t\tWHERE `order_id` = " . $this->Session['order_id'];
                            $row = $this->DB->FetchRow($query);
                            $message = <<<EOH

<strong>We're sorry, there's been a problem with your order</strong>
<br /><br />
Your order number is {$this->Session['order_id']}. Please contact our <a href="{$this->Site->URL}/contact/">contact us</a>. Our customer support e-mail is <a href="mailto:{$this->Site['support_email']}">{$this->Site['support_email']}</a>.
<br /><br />
<a href="{$this->Site->URL}/"><< Return to {$this->Site->Title}</a>

EOH;
                            $paypal = unserialize($row['extra']);
                            $order_status = $paypal['payment_status'];
                            $order_amount = $paypal['mc_gross'];
                            //$order_currency = $paypal['mc_currency'];
                            $order_transaction_id = $paypal['txn_id'];
                            // check if txn_id has been processed before
                            //$query =
                            //	"SELECT `order_transaction_id`
                            //	FROM `{$this->DB->Prefix}ecommerce_orders`
                            //	WHERE `order_transaction_id` = '" . $order_transaction_id . "'";
                            //if(!$this->DB->FetchRow($query))
                            //{
                            if ($order_status == "Completed" && $order_amount == $row['order_amount']) {
                                // post back to PayPal system to validate
                                $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
                                $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
                                $header .= "Content-Length: " . strlen($row['order_extra']) . "\r\n\r\n";
                                $fp = fsockopen("www.paypal.com", 80, $errno, $errstr, 30);
                                if (!$fp) {
                                    // HTTP ERROR
                                } else {
                                    fputs($fp, $header . $row['order_extra']);
                                    while (!feof($fp)) {
                                        $res = fgets($fp, 1024);
                                        if (strcmp($res, "VERIFIED") == 0) {
                                            $query = "UPDATE `{$this->DB->Prefix}ecommerce_orders` \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tSET `order_status` 'Completed', `order_transaction_id` = '" . $order_transaction_id . "' \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `order_id` = " . $this->Session['order_id'];
                                            $this->DB->Query($query);
                                            $message = <<<EOH

<strong>Thank you for your payment!</strong>
<br /><br />
Your order number is {$this->Session['order_id']}. You should keep this number for future reference.
<br /><br />
If you have any questions about your order, please don't hesitate to <a href="{$this->Site->URL}/contact/">contact us</a>.
<br /><br />
<a href="{$this->Site->URL}/"><< Return to {$this->Site->Title}</a>

EOH;
                                            $template =& $this->Mail->LoadTemplate("ecommerce_order_received", array("order_id" => $order_id));
                                            $this->Mail->Send($this->User->Email, $settings['order_email'], $template['title'], $template['content']);
                                            $template =& $this->Mail->LoadTemplate("ecommerce_order_notify", array("order_id" => $order_id));
                                            $this->Mail->Send($settings['order_email'], $settings['order_email'], $template['title'], $template['content']);
                                        } else {
                                            if (strcmp($res, "INVALID") == 0) {
                                                $query = "UPDATE `{$this->DB->Prefix}ecommerce_orders` \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tSET `order_status` 'Failed', `order_transaction_id` = '" . $order_transaction_id . "' \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `order_id` = " . $this->Session['order_id'];
                                                $this->DB->Query($query);
                                            }
                                        }
                                    }
                                    fclose($fp);
                                }
                            } else {
                                $query = "UPDATE `{$this->DB->Prefix}ecommerce_orders` \n\t\t\t\t\t\t\t\t\t\t\tSET `order_status` 'Failed', `order_transaction_id` = '" . $order_transaction_id . "' \n\t\t\t\t\t\t\t\t\t\t\tWHERE `order_id` = " . $this->Session['order_id'];
                                $this->DB->Query($query);
                            }
                            //}
                        }
                    }
                }
                $this->Page->Content .= $message;
                // clear the cart
                $this->Session->Cart = '';
                unset($_SESSION['order_id']);
                unset($_SESSION['token']);
                unset($_SESSION['amount']);
                unset($_SESSION['paymentType']);
                unset($_SESSION['currCodeType']);
                unset($_SESSION['payer_id']);
                unset($_SESSION['SERVER_NAME']);
                unset($_SESSION['type']);
                unset($_SESSION['shipping_first_name']);
                unset($_SESSION['shipping_last_name']);
                unset($_SESSION['shipping_street_1']);
                unset($_SESSION['shipping_street_2']);
                unset($_SESSION['shipping_city']);
                unset($_SESSION['shipping_state']);
                unset($_SESSION['shipping_postal_code']);
                unset($_SESSION['shipping_phone_number']);
                unset($_SESSION['shipping_country']);
                unset($_SESSION['billing_first_name']);
                unset($_SESSION['billing_last_name']);
                unset($_SESSION['billing_street_1']);
                unset($_SESSION['billing_street_2']);
                unset($_SESSION['billing_city']);
                unset($_SESSION['billing_state']);
                unset($_SESSION['billing_postal_code']);
                unset($_SESSION['billing_phone_number']);
                unset($_SESSION['billing_country']);
                unset($_SESSION['user_id']);
                break;
            case "confirm":
                //$paypal = $_POST;
                //$paypal['cmd'] = "_notify-validate";
                $query[] = "`order_status` = 'Completed'";
                $query = "UPDATE `{$this->DB->Prefix}ecommerce_orders` \n\t\t\t\t\t\tSET " . fix_query(implode(',', $query)) . "\n\t\t\t\t\t\tWHERE `order_id` = " . $_POST['item_number'];
                $this->DB->Query($query);
                break;
            case "payment":
                if ($settings['require_authorization'] && !$this->User->Validated) {
                    $this->Redirect($this->Site->URL . "/account/login/");
                }
                //$this->Session->Merge($_REQUEST);
                $this->Page->Content .= <<<EOH

<script src="{$this->Site->URL}/libs/spry/SpryValidationTextField.js" type="text/javascript"></script>
<script src="{$this->Site->URL}/libs/spry/SpryValidationSelect.js" type="text/javascript"></script>
<link href="{$this->Site->URL}/libs/spry/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="{$this->Site->URL}/libs/spry/SpryValidationSelect.css" rel="stylesheet" type="text/css" />
\t\t\t\t
EOH;
                $type = $this->Session['type'];
                if ($type == "pp_basic") {
                    $this->Redirect("https://www.paypal.com/cgi-bin/webscr/?cmd=_xclick&business=" . urlencode("{$settings['paypal_email']}") . "&item_name=" . urlencode("{$this->Site->Title} Order #{$this->Session['order_id']}") . "&item_number={$this->Session['order_id']}&amount={$this->Session['amount']}&tax=0&no_note=1&currency_code=USD&cancel_return=" . urlencode("{$this->Site->URL}/shop/cart/cancel/") . "&return=" . urlencode("{$this->Site->URL}/shop/cart/thanks/") . "&notify_url=" . urlencode("{$this->Site->URL}/shop/cart/confirm/"));
                    /*
                    							$this->Page->Content .= <<< EOH
                    
                    <center>
                    	<div class="style1" style="float: left;">
                    		<strong><a href="{$this->Site->URL}/shop/cart/">View Cart</a></strong>
                    	</div>
                    	<div class="style1" style="float: left;">
                    		<strong><a href="{$this->Site->URL}/shop/cart/preview/">Preview</a></strong>
                    	</div>
                    	<div class="style1" style="float: left;">
                    		<strong><a href="{$this->Site->URL}/shop/cart/information/">Information</a></strong>
                    	</div>
                    	<div class="style1 active" style="float: left;">
                    		<strong>Payment</strong>
                    	</div>
                    	<div class="style1 disabled" style="float: left;">
                    		<strong>Review</strong>
                    	</div>
                    	<div class="style1 disabled" style="float: left;">
                    		<strong>Complete</strong>
                    	</div>
                    	<div style="clear: both"></div>
                    </center>
                    <br /><br />
                    						
                    <center>
                    <form method="post" action="https://www.paypal.com/cgi-bin/webscr" target="paypal">
                    	<input type="hidden" name="cmd" value="_xclick" />
                    	<input type="hidden" name="business" value="{$settings['paypal_email']}" />
                    	<input type="hidden" name="item_name" value="{$this->Site->Name} Order #{$order_id}" />
                    	<input type="hidden" name="item_number" value="{$order_id}" />
                    	<input type="hidden" name="amount" value="{$this->Session['amount']}" />
                    	<input type="hidden" name="tax" value="0" />
                    	<input type="hidden" name="no_note" value="1" />
                    	<input type="hidden" name="currency_code" value="USD" />
                    	<input type="hidden" name="cancel_return" value="{$this->Site->URL}/shop/cart/cancel/" />
                    	<input type="hidden" name="return" value="{$this->Site->URL}/shop/cart/review/" />
                    	<input type="hidden" name="notify_url" value="{$this->Site->URL}/shop/cart/confirm/" />
                    	<input type="submit" name="submit" value="Continue" class="submit" />
                    </form>
                    </center>
                    
                    EOH;
                    */
                }
                if ($type == "pp_express") {
                    require_once PATH . "/libs/paypal/constants.php";
                    require_once PATH . "/libs/paypal/CallerService.php";
                    $token = $this->Request['token'];
                    if (!$token) {
                        /* The servername and serverport tells PayPal where the buyer
                           should be directed back to after authorizing payment.
                           In this case, its the local webserver that is running this script
                           Using the servername and serverport, the return URL is the first
                           portion of the URL that buyers will return to after authorizing payment
                           */
                        //$serverName = $_SERVER['SERVER_NAME'];
                        //$serverPort = $_SERVER['SERVER_PORT'];
                        $url = $this->Site->URL . "/shop/cart/";
                        //$this->Session['currencyCodeType'] = $this->Request['currencyCodeType'] ? $this->Request['currencyCodeType'] : $this->Session['currencyCodeType'];
                        //$this->Session['paymentType'] = $this->Request['paymentType'] ? $this->Request['paymentType'] : $this->Session['paymentType'];
                        $paymentAmount = $this->Session['amount'];
                        $currencyCodeType = $this->Session['currencyCodeType'];
                        $paymentType = $this->Session['paymentType'];
                        //die(var_dump($this->Session));
                        /* The returnURL is the location where buyers return when a
                        			payment has been succesfully authorized.
                        			The cancelURL is the location buyers are sent to when they hit the
                        			cancel button during authorization of payment during the PayPal flow
                        			*/
                        $returnURL = urlencode($this->Site->URL . "/shop/cart/payment/");
                        $cancelURL = urlencode($this->Site->URL . "/shop/cart/cancel/");
                        /* Construct the parameter string that describes the PayPal payment
                        			the varialbes were set in the web form, and the resulting string
                        			is stored in $nvpstr
                        			*/
                        $nvpstr = "&Amt=" . $paymentAmount . "&PAYMENTACTION=" . $paymentType . "&ReturnUrl=" . $returnURL . "&CANCELURL=" . $cancelURL . "&CURRENCYCODE=" . $currencyCodeType;
                        //die(var_dump($nvpstr));
                        /* Make the call to PayPal to set the Express Checkout token
                        			If the API call succeded, then redirect the buyer to PayPal
                        			to begin to authorize payment.  If an error occured, show the
                        			resulting errors
                        			*/
                        $resArray = hash_call("SetExpressCheckout", $nvpstr);
                        $this->Session['reshash'] = $resArray;
                        $ack = strtoupper($resArray['ACK']);
                        if ($ack == "SUCCESS") {
                            // Redirect to paypal.com here
                            $token = urldecode($resArray['TOKEN']);
                            $payPalURL = PAYPAL_URL . $token;
                            $this->Redirect($payPalURL);
                        } else {
                            //Redirecting to APIError.php to display errors.
                            $this->Redirect($this->Site->URL . "/shop/cart/error/");
                        }
                    } else {
                        /* At this point, the buyer has completed in authorizing payment
                        			at PayPal.  The script will now call PayPal with the details
                        			of the authorization, incuding any shipping information of the
                        			buyer.  Remember, the authorization is not a completed transaction
                        			at this state - the buyer still needs an additional step to finalize
                        			the transaction
                        			*/
                        //die(var_dump($this->Request));
                        $token = urlencode($token);
                        /* Build a second API request to PayPal, using the token as the
                        			ID to get the details on the payment authorization
                        			*/
                        $nvpstr = "&TOKEN=" . $token;
                        /* Make the API call and store the results in an array.  If the
                        			call was a success, show the authorization details, and provide
                        			an action to complete the payment.  If failed, show the error
                        			*/
                        $resArray = hash_call("GetExpressCheckoutDetails", $nvpstr);
                        $this->Session['reshash'] = $resArray;
                        $ack = strtoupper($resArray["ACK"]);
                        if ($ack == "SUCCESS") {
                            $this->Session['token'] = $this->Request['token'];
                            $this->Session['payer_id'] = $this->Request['PayerID'];
                            //$this->Session['currCodeType'] = $this->Request['currencyCodeType'];
                            //$this->Session['paymentType'] = $this->Request['paymentType'];
                            $resArray = $this->Session['reshash'];
                            $this->Redirect($this->Site->URL . "/shop/cart/review/");
                        } else {
                            //Redirecting to APIError.php to display errors.
                            $this->Redirect($this->Site->URL . "/shop/cart/error/");
                        }
                    }
                } else {
                    if ($type == "pp_cc") {
                        $this->Page->Title[] = "Checkout";
                        $country = <<<EOH

\t<option selected="selected" value="">--- Choose Country ---</option>
     <option value="United States">United States</option>
    <option value="Canada">Canada</option>
    <option value="Afghanistan">Afghanistan</option>
    <option value="Albania">Albania</option>
    <option value="Algeria">Algeria</option>
    <option value="Andorra">Andorra</option>
    <option value="Angola">Angola</option>
    <option value="Anguilla">Anguilla</option>
    <option value="Antigua and Barbuda">Antigua and Barbuda</option>
    <option value="Argentina">Argentina</option>
    <option value="Armenia">Armenia</option>
    <option value="Aruba">Aruba</option>
    <option value="Australia">Australia</option>
    <option value="Austria">Austria</option>
    <option value="Azerbaijan">Azerbaijan</option>
    <option value="Bahamas">Bahamas</option>
    <option value="Bahrain">Bahrain</option>
    <option value="Bangladesh">Bangladesh</option>
    <option value="Barbados">Barbados</option>
    <option value="Belarus">Belarus</option>
    <option value="Belgium">Belgium</option>
    <option value="Belize">Belize</option>
    <option value="Benin">Benin</option>
    <option value="Bermuda">Bermuda</option>
    <option value="Bhutan">Bhutan</option>
    <option value="Bolivia">Bolivia</option>
    <option value="Borneo">Borneo</option>
    <option value="Bosnia and Herzegovina">Bosnia and Herzegovina</option>
    <option value="Botswana">Botswana</option>
    <option value="Brazil">Brazil</option>
    <option value="Brunei">Brunei</option>
    <option value="Bulgaria">Bulgaria</option>
    <option value="Burkina Faso">Burkina 
      Faso</option>
    <option value="Burma">Burma</option>
    <option value="Burundi">Burundi</option>
    <option value="Cameroon">Cameroon</option>
    <option value="Cambodia">Cambodia</option>
    <option value="Cape Verde">Cape 
      Verde</option>
    <option value="Central African Rep">Central African 
      Republic</option>
    <option value="Chad">Chad</option>
    <option value="Chile">Chile</option>
    <option value="China">China</option>
    <option value="Cote d'Ivoire">Cote d'Ivoire</option>
    <option value="Colombia">Colombia</option>
    <option value="Comoros">Comoros</option>
    <option value="Congo, Democratic Republic of">Congo, Democratic Republic 
      of</option>
    <option value="Costa Rica, Republic of the">Costa Rica, 
      Republic of the</option>
    <option value="Croatia">Croatia</option>
    <option value="Cuba">Cuba</option>
    <option value="Cyprus">Cyprus</option>
    <option value="Czech Republic">Czech Republic</option>
    <option value="Denmark">Denmark</option>
    <option value="Djibouti">Djibouti</option>
    <option value="Dominica">Dominica</option>
    <option value="Dominican Republic">Dominican Republic</option>
    <option value="East Timor">East Timor</option>
    <option value="Ecuador">Ecuador</option>
    <option value="Egypt">Egypt</option>
    <option value="El Salvador">El Salvador</option>
    <option value="Equatorial Guinea">Equatorial Guinea</option>
    <option value="Eritrea">Eritrea</option>
    <option value="Estonia">Estonia</option>
    <option value="Ethiopia">Ethiopia</option>
    <option value="Fiji">Fiji</option>
    <option value="Finland">Finland</option>
    <option value="France">France</option>
    <option value="Gabon">Gabon</option>
    <option value="Gambia">Gambia</option>
    <option value="Georgia">Georgia</option>
    <option value="Germany">Germany</option>
    <option value="Ghana">Ghana</option>
    <option value="Gibraltar">Gibraltar</option>
    <option value="Greece">Greece</option>
    <option value="Greenland">Greenland</option>
    <option value="Grenada">Grenada</option>
    <option value="Guadeloupe">Guadeloupe</option>
    <option value="Guatemala">Guatemala</option>
    <option value="Guinea">Guinea</option>
    <option value="Guinea-Bissau">Guinea-Bissau</option>
    <option value="Guyana">Guyana</option>
    <option value="Haiti">Haiti</option>
    <option value="Honduras">Honduras</option>
    <option value="Hong Kong">Hong 
      Kong</option>
    <option value="Hungary">Hungary</option>
    <option value="Iceland">Iceland</option>
    <option value="India">India</option>
    <option value="Indonesia">Indonesia</option>
    <option value="Iran">Iran</option>
    <option value="Iraq">Iraq</option>
    <option value="Ireland">Ireland</option>
    <option value="Israel">Israel</option>
    <option value="Italy">Italy</option>
    <option value="Jamaica">Jamaica</option>
    <option value="Japan">Japan</option>
    <option value="Jordan">Jordan</option>
    <option value="Kazakhstan">Kazakhstan</option>
    <option value="Kenya">Kenya</option>
    <option value="Kiribati">Kiribati</option>
    <option value="Korea, North">Korea, North</option>
    <option value="Korea, South">Korea, South</option>
    <option value="Kosovo">Kosovo</option>
    <option value="Kuwait">Kuwait</option>
    <option value="Kyrgyzstan">Kyrgyzstan</option>
    <option value="Laos">Laos</option>
    <option value="Latvia">Latvia</option>
    <option value="Lebanon">Lebanon</option>
    <option value="Lesotho">Lesotho</option>
    <option value="Liberia">Liberia</option>
    <option value="Libya">Libya</option>
    <option value="Liechtenstein">Liechtenstein</option>
    <option value="Lithuania">Lithuania</option>
    <option value="Luxembourg">Luxembourg</option>
    <option value="Macedonia">Macedonia</option>
    <option value="Madagascar">Madagascar</option>
    <option value="Malawi">Malawi</option>
    <option value="Malaysia">Malaysia</option>
    <option value="Maldives">Maldives</option>
    <option value="Mali">Mali</option>
    <option value="Malta">Malta</option>
    <option value="Marshall Islands">Marshall Islands</option>
    <option value="Martinique">Martinique</option>
    <option value="Mauritania">Mauritania</option>
    <option value="Mauritius">Mauritius</option>
    <option value="Mexico">Mexico</option>
    <option value="Micronesia, Federated States of">Micronesia, Federated 
      States of</option>
    <option value="Moldova">Moldova</option>
    <option value="Monaco">Monaco</option>
    <option value="Mongolia">Mongolia</option>
    <option value="Montserrat">Montserrat</option>
    <option value="Morocco">Morocco</option>
    <option value="Mozambique">Mozambique</option>
    <option value="Namibia">Namibia</option>
    <option value="Naura">Naura</option>
    <option value="Nepal">Nepal</option>
    <option value="Netherlands">Netherlands</option>
    <option value="New Zealand">New 
      Zealand</option>
    <option value="Nicaragua">Nicaragua</option>
    <option value="Niger">Niger</option>
    <option value="Nigeria">Nigeria</option>
    <option value="Norway">Norway</option>
    <option value="Oman">Oman</option>
    <option value="Pakistan">Pakistan</option>
    <option value="Palau">Palau</option>
    <option value="Panama">Panama</option>
    <option value="Papua New Guinea">Papua New Guinea</option>
    <option value="Paraguay">Paraguay</option>
    <option value="Peru">Peru</option>
    <option value="Philippines">Philippines</option>
    <option value="Poland">Poland</option>
    <option value="Portugal">Portugal</option>
    <option value="Qatar">Qatar</option>
    <option value="Romania">Romania</option>
    <option value="Russia">Russia</option>
    <option value="Rwanda">Rwanda</option>
    <option value="Samoa">Samoa</option>
    <option value="Saint Kitts and Nevis">Saint Kitts and Nevis</option>
    <option value="Saint Lucia">Saint Lucia</option>
    <option value="Saint Vincent and Grenadines">Saint Vincent and 
      Grenadines</option>
    <option value="San Marino">San Marino</option>
    <option value="Sao Tome and Principe">Sao Tome and Principe</option>
    <option value="Saudi Arabia">Saudi Arabia</option>
    <option value="Senegal">Senegal</option>
    <option value="Seychelles">Seychelles</option>
    <option value="Sierra Leone">Sierra 
      Leone</option>
    <option value="Singapore">Singapore</option>
    <option value="Slovakia">Slovakia</option>
    <option value="Slovenia">Slovenia</option>
    <option value="Solomon Islands">Solomon 
      Islands</option>
    <option value="Somalia">Somalia</option>
    <option value="South Africa">South Africa</option>
    <option value="Spain">Spain</option>
    <option value="Sri Lanka">Sri Lanka</option>
    <option value="Sudan">Sudan</option>
    <option value="Suriname">Suriname</option>
    <option value="Swaziland">Swaziland</option>
    <option value="Sweden">Sweden</option>
    <option value="Switzerland">Switzerland</option>
    <option value="Syria">Syria</option>
    <option value="Taiwan">Taiwan</option>
    <option value="Tajikistan">Tajikistan</option>
    <option value="Tanzania">Tanzania</option>
    <option value="Thailand">Thailand</option>
    <option value="Togo">Togo</option>
    <option value="Tonga">Tonga</option>
    <option value="Trinidad and Tobago">Trinidad and Tobago</option>
    <option value="Tunisia">Tunisia</option>
    <option value="Turkey">Turkey</option>
    <option value="Turkmenistan">Turkmenistan</option>
    <option value="Tuvalu">Tuvalu</option>
    <option value="Uganda">Uganda</option>
    <option value="Ukraine">Ukraine</option>
    <option value="United Arab Emirates">United Arab Emirates</option>
    <option value="United Kingdom">United Kingdom</option>
    <option value="Uruguay">Uruguay</option>
    <option value="Uzbekistan">Uzbekistan</option>
    <option value="Vanuatu">Vanuatu</option>
    <option value="Vatican City">Vatican 
      City</option>
    <option value="Venezuela">Venezuela</option>
    <option value="Vietnam">Vietnam</option>
    <option value="Virgin Islands">Virgin 
      Islands</option>
    <option value="West Bank and Gaza">West Bank and 
      Gaza</option>
    <option value="Western Sahara">Western Sahara</option>
    <option value="Yemen">Yemen</option>
    <option value="Yugoslavia">Yugoslavia, 
      Federal Republic of</option>
    <option value="Zambia">Zambia</option>
    <option value="Zimbabwe">Zimbabwe</option>

EOH;
                        $country = str_replace("value=\"{$this->User['country']}\"", "value=\"{$this->User['country']}\" selected=\"selected\"", $country);
                        $state = <<<EOH

\t<option value="">--- Choose State ---</option>
\t<option value="NA">Outside USA</option>
\t<option value="AL">Alabama</option>
\t<option value="AK">Alaska</option>
\t<option value="AZ">Arizona</option>
\t<option value="AR">Arkansas</option>
\t<option value="CA">California</option>
\t<option value="CO">Colorado</option>
\t<option value="CT">Connecticut</option>
\t<option value="DE">Delaware</option>
\t<option value="DC">Dist of Columbia</option>
\t<option value="FL">Florida</option>
\t<option value="GA">Georgia</option>
\t<option value="HI">Hawaii</option>
\t<option value="ID">Idaho</option>
\t<option value="IL">Illinois</option>
\t<option value="IN">Indiana</option>
\t<option value="IA">Iowa</option>
\t<option value="KS">Kansas</option>
\t<option value="KY">Kentucky</option>
\t<option value="LA">Louisiana</option>
\t<option value="ME">Maine</option>
\t<option value="MD">Maryland</option>
\t<option value="MA">Massachusetts</option>
\t<option value="MI">Michigan</option>
\t<option value="MN">Minnesota</option>
\t<option value="MS">Mississippi</option>
\t<option value="MO">Missouri</option>
\t<option value="MT">Montana</option>
\t<option value="NE">Nebraska</option>
\t<option value="NV">Nevada</option>
\t<option value="NH">New Hampshire</option>
\t<option value="NJ">New Jersey</option>
\t<option value="NM">New Mexico</option>
\t<option value="NY">New York</option>
\t<option value="NC">North Carolina</option>
\t<option value="ND">North Dakota</option>
\t<option value="OH">Ohio</option>
\t<option value="OK">Oklahoma</option>
\t<option value="OR">Oregon</option>
\t<option value="PA">Pennsylvania</option>
\t<option value="RI">Rhode Island</option>
\t<option value="SC">South Carolina</option>
\t<option value="SD">South Dakota</option>
\t<option value="TN">Tennessee</option>
\t<option value="TX">Texas</option>
\t<option value="UT">Utah</option>
\t<option value="VT">Vermont</option>
\t<option value="VA">Virginia</option>
\t<option value="WA">Washington</option>
\t<option value="WV">West Virginia</option>
\t<option value="WI">Wisconsin</option>
\t<option value="WY">Wyoming</option>

EOH;
                        $state = str_replace("value=\"{$this->User['state']}\"", "value=\"{$this->User['state']}\" selected=\"selected\"", $state);
                        $this->Page->Content .= <<<EOH
\t\t\t\t\t
<center>
\t<div class="style1" style="float: left;">
\t\t<strong><a href="{$this->Site->URL}/shop/cart/">View Cart</a></strong>
\t</div>
\t<div class="style1" style="float: left;">
\t\t<strong><a href="{$this->Site->URL}/shop/cart/information/">Information</a></strong>
\t</div>
\t<div class="style1" style="float: left;">
\t\t<strong><a href="{$this->Site->URL}/shop/cart/preview/">Preview</a></strong>
\t</div>
\t<div class="style1 active" style="float: left;">
\t\t<strong>Payment</strong>
\t</div>
\t<div class="style1 disabled" style="float: left;">
\t\t<strong>Review</strong>
\t</div>
\t<div class="style1 disabled" style="float: left;">
\t\t<strong>Complete</strong>
\t</div>
\t<div style="clear: both"></div>
</center>
<br /><br />

<center>
<form action="{$this->Site->URL}/shop/cart/review/" method="post">
\t<input type="hidden" name="paymentType" value="Sale" />

    <table cellspacing="5" cellpadding="0" border="0">
        <tr>
            <td><strong>Amount being charged:</strong></td>
            <td>\${$this->Session['amount']} USD</td>
        </tr>
        <tr>
            <td></td>
        </tr>
        <tr>
            <td><strong>First Name <span style="color: #FF0000">*</span></strong></td>
            <td><span id="sprytextfield1">
\t\t\t<input type="text" size="30" maxlength="32" name="user_first_name" value="{$this->User['first_name']}" />
\t\t\t<span class="textfieldRequiredMsg"><br /><br />A first name is required.</span></span></td>
        </tr>
        <tr>
            <td><strong>Last Name <span style="color: #FF0000">*</span></strong></td>
\t\t\t<td><span id="sprytextfield2">
\t\t\t<input type="text" size="30" maxlength="32" name="user_last_name" value="{$this->User['last_name']}" />
\t\t\t<span class="textfieldRequiredMsg"><br /><br />
\t\t\tA last name is required.</span></span></td>
        </tr>
        <tr>
            <td><strong>Card Type <span style="color: #FF0000">*</span></strong></td>
\t\t\t<td><span id="spryselect1">
\t\t\t<select name="creditCardType">
\t\t\t<option value="">--- Choose Card ---</option>
\t\t\t<option value="Visa">Visa</option>
\t\t\t<option value="MasterCard">MasterCard</option>
\t\t\t<option value="Discover">Discover</option>
\t\t\t<option value="Amex">American Express</option>
\t\t\t</select>
\t\t\t<span class="selectInvalidMsg"><br /><br />
\t\t\tPlease select a credit card type.</span>          <span class="selectRequiredMsg">Please select a card type.</span></span></td>
        </tr>
        <tr>
            <td><strong>Card Number <span style="color: #FF0000">*</span></strong></td>
\t\t\t<td><span id="sprytextfield3">
\t\t\t<input type="text" size="19" maxlength="19" name="creditCardNumber" value="" />
\t\t\t<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid card format.</span></span></td>
\t\t</tr>
        <tr>
            <td><strong>Expiration Date <span style="color: #FF0000">*</span></strong></td>
            <td>
            \t<span id="spryselect2">
\t                <select name="expDateMonth">
\t                \t<option value="">--- Choose Month ---</option>
\t                    <option value="1">01</option>
\t                    <option value="2">02</option>
\t                    <option value="3">03</option>
\t                    <option value="4">04</option>
\t                    <option value="5">05</option>
\t                    <option value="6">06</option>
\t                    <option value="7">07</option>
\t                    <option value="8">08</option>
\t                    <option value="9">09</option>
\t                    <option value="10">10</option>
\t                    <option value="11">11</option>
\t                    <option value="12">12</option>
\t                </select>
\t                <span class="selectInvalidMsg">Please select a month.</span>
\t                <span class="selectRequiredMsg">Please select an item.</span>
\t\t\t\t</span>
\t\t\t\t<span id="spryselect3">
\t                <select name="expDateYear">
\t                \t<option value="">--- Choose Year ---</option>
\t                    <option value="2004">2004</option>
\t                    <option value="2005">2005</option>
\t                    <option value="2006">2006</option>
\t                    <option value="2007">2007</option>
\t                    <option value="2008">2008</option>
\t                    <option value="2009">2009</option>
\t                    <option value="2010">2010</option>
\t                    <option value="2011">2011</option>
\t                    <option value="2012">2012</option>
\t                    <option value="2013">2013</option>
\t                    <option value="2014">2014</option>
\t                    <option value="2015">2015</option>
\t                    <option value="2016">2016</option>
\t                    <option value="2017">2017</option>
\t                    <option value="2018">2018</option>
\t                </select>
\t                <span class="selectRequiredMsg">Please select a year.</span>
\t                <span class="selectInvalidMsg">Please select a year.</span>
                </span>
            </td>
        </tr>
        <tr>
            <td><strong>Card Verification Number <span style="color: #FF0000">*</span></strong></td>
\t\t\t<td>
\t\t\t<span id="sprytextfield4">
\t\t\t<input type="text" size="3" maxlength="4" name="cvv2Number" value="" />
\t\t\t<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
\t\t\t</td>
        </tr>
        <tr>
            <td></td>
        </tr>
        <tr>
            <td><strong>Country <span style="color: #FF0000">*</span></strong></td>
            <td><span id="spryselect4"><select name="user_country">{$country}</select><span class="selectInvalidMsg">Please select a Country.</span>              <span class="selectRequiredMsg">Please select an item.</span></span></td>
        </tr>
        <tr>
            <td><strong>State <span style="color: #FF0000">*</span></strong></td>
            <td><span id="spryselect5"><select name="user_state">{$state}</select><span class="selectInvalidMsg"><br /><br />
            Please select a State.</span>            <span class="selectRequiredMsg">Please select an item.</span></span></td>
        </tr>
        <tr>
            <td><strong>City <span style="color: #FF0000">*</span></strong></td>
            <td><span id="sprytextfield5"><input type="text" size="25" maxlength="40" name="user_city" value="{$this->User['city']}" />
            <span class="textfieldRequiredMsg"><br /><br />A City is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
        </tr>
        <tr>
            <td><strong>Street Address 1 <span style="color: #FF0000">*</span></strong></td>
            <td><span id="sprytextfield6"><input type="text" size="25" maxlength="100" name="user_street_1" value="{$this->User['street_1']}" /><span class="textfieldRequiredMsg"><br /><br />A delivery address is required.</span></span></td>
        </tr>
        <tr>
            <td><strong>Street Address 2</strong></td>
            <td><input type="text" size="25" maxlength="100" name="user_street_2" value="{$this->User['street_2']}" /></td>
        </tr>
        <tr>
            <td><strong>Postal Code <span style="color: #FF0000">*</span></strong></td>
            <td><span id="sprytextfield7"><input type="text" size="10" maxlength="10" name="user_postal_code" value="{$this->User['postal_code']}" />
            <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
        </tr>
        <tr>
            <td></td>
            <td><input type="submit" value="Continue" class="submit" /></td>
        </tr>
    </table>
</form>
</center>

<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none", {validateOn:["blur", "change"]});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "none", {validateOn:["blur", "change"]});
var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1", {invalidValue:"", validateOn:["change", "blur"]});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "credit_card", {useCharacterMasking:true, validateOn:["blur"], hint:""});
var spryselect2 = new Spry.Widget.ValidationSelect("spryselect2", {invalidValue:"", validateOn:["blur", "change"]});
var spryselect3 = new Spry.Widget.ValidationSelect("spryselect3", {invalidValue:"", validateOn:["blur", "change"]});
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "integer", {validateOn:["blur", "change"], useCharacterMasking:true, hint:""});
var spryselect4 = new Spry.Widget.ValidationSelect("spryselect4", {invalidValue:"", validateOn:["blur", "change"]});
var spryselect5 = new Spry.Widget.ValidationSelect("spryselect5", {invalidValue:"", validateOn:["blur", "change"]});
var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "custom", {validateOn:["blur", "change"]});
var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6", "none", {validateOn:["blur", "change"]});
var sprytextfield7 = new Spry.Widget.ValidationTextField("sprytextfield7", "zip_code", {hint:"", validateOn:["blur"]});
//-->
</script>

EOH;
                    }
                }
                break;
            case "thanks":
                $this->Page->Content .= <<<EOH

<strong>Thank you for your payment!</strong>
<br /><br />
Your order number is {$this->Session['order_id']}. You should keep this number for future reference.
<br /><br />
If you have any questions about your order, please don't hesitate to <a href="{$this->Site->URL}/contact/">contact us</a>.
<br /><br />
<a href="{$this->Site->URL}/"><< Return to {$this->Site->Title}</a>

EOH;
                break;
            case "update":
                $this->Page->Title[] = "Update Cart";
                $this->Session->Cart = array();
                foreach ($this->Request->ID as $offset => $id) {
                    if (!$this->Request->Delete[$id]) {
                        for ($i = 0, $l = $this->Request->Quantity[$offset]; $i < $l; ++$i) {
                            $this->Session->Cart[] = $id;
                        }
                    }
                }
                $this->Page->Content = <<<EOH

<div class="success">Shopping cart updated. <a href="{$this->Site->URL}/">Continue shopping...</a></div>
<br />

EOH;
                $this->Session->Cart = implode(',', $this->Session->Cart);
            default:
                $this->Page->Title[] = "Shopping Cart";
                $this->Page->Content .= <<<EOH

<h2>Your Shopping Cart</h2> 
<br />

EOH;
                if (!$this->Session->Cart) {
                    $this->Page->Content .= <<<EOH

You have no items in your shopping cart. <a href="{$this->Site->URL}/">Continue shopping...</a>
\t
EOH;
                } else {
                    $items = explode(',', $this->Session->Cart);
                    $count = count($items);
                    $s = $count > 1 ? 's' : '';
                    $contents = array();
                    foreach ($items as $item) {
                        $contents[$item] = isset($contents[$item]) ? ++$contents[$item] : 1;
                    }
                    $this->Page->Content .= <<<EOH

You have {$count} item{$s} in your shopping cart. <a href="{$this->Site->URL}/">Continue shopping...</a>
<br /><br />

<br />
<h2>Your Choices</h2>
<form action="{$this->Site->URL}/shop/cart/update/" method="post">
\t<table class="style1" cellpadding="0" cellspacing="10">
\t\t<thead>
\t\t\t<tr>
\t\t\t<th align="center" style="width: 20%"><input type="checkbox" class="deleteAll" /> Remove</th>
\t\t\t<th style="width: 50%">Title</th>
\t\t\t<th align="right">Price</th>
\t\t\t<th align="right">Quantity</th>
\t\t\t<th align="right">Total</th>
\t\t\t</tr>
\t\t</thead>
\t\t<tbody>
\t
EOH;
                    $total = 0;
                    foreach ($contents as $id => $quantity) {
                        $query = "\n\t\t\t\t\t\t\t\tSELECT `product_pin`, `product_id`, `product_title`, `product_description`, `product_price`\n\t\t\t\t\t\t\t\tFROM `{$this->DB->Prefix}ecommerce_products` \n\t\t\t\t\t\t\t\tWHERE `product_id` = {$id} LIMIT 1";
                        if ($product = $this->DB->FetchRow($query, "slave")) {
                            $product_total = $product['product_price'] * $quantity;
                            $this->Page->Content .= <<<EOH

<tr>
\t<td align="center"><input type="hidden" value="{$product['product_id']}" name="id[]" /><input type="checkbox" value="{$product['product_id']}" name="delete[{$product['product_id']}]" /></td>
\t<td><a href="{$this->Site->URL}/shop/product/{$product['product_id']}/">{$product['product_title']} (#{$product['product_pin']})</a></td>
\t<td align="right">\${$product['product_price']}</td>
\t<td align="right"><input type="text" name="quantity[]" value="{$quantity}" size="1" maxlength="4" /></td>
\t<td align="right">\${$product_total}</td>
</tr>
\t\t\t\t\t\t\t\t
EOH;
                            $total += $product['product_price'] * $quantity;
                        }
                    }
                    $this->Page->Content .= <<<EOH

\t\t</tbody>
\t</table>
\t<span class="style1" style="float: right"><strong>Sub-total:</strong> \${$total}</span>
\t<br />
\t<a title="Update your choices" href="#" onclick="\$(this).parent('form:first').submit()"><img src="{$this->Site->URL}/modules/eCommerce/images/cart-update.gif"/></a>
</form>
<br /><br />
<div style="text-align:right">

EOH;
                    if ($settings['paypal_pro']) {
                        $this->Page->Content .= <<<EOH
\t\t\t\t\t\t
\t<form action="{$this->Site->URL}/shop/cart/information/" method="post">
\t\t<input type="hidden" name="paymentType" value="Sale">
\t\t
\t\t<input type="hidden" name="paymentAmount" size="5" maxlength="7" value="{$total}" />
\t\t<input type="hidden" name="currencyCodeType" value="USD" />
\t\t
\t\t<input type="hidden" name="type" value="pp_cc">
\t\t
\t\t<input type="image" name="submit" title="Checkout your choices" src="{$this->Site->URL}/modules/eCommerce/images/cart-checkout.gif" style="border: 0pt" />
\t</form>
\t<br />

EOH;
                    }
                    if ($settings['paypal_express']) {
                        $this->Page->Content .= <<<EOH
\t\t\t\t\t\t
\t<form action="{$this->Site->URL}/shop/cart/information/" method="post">
\t\t<input type="hidden" name="paymentType" value="Sale">
\t\t
\t\t<input type="hidden" name="paymentAmount" size="5" maxlength="7" value="{$total}" />
\t\t<input type="hidden" name="currencyCodeType" value="USD" />
\t\t
\t\t<input type="hidden" name="type" value="pp_express">
\t\t
\t\t<input type="image" name="submit" title="Checkout your choices" src="{$this->Site->URL}/modules/eCommerce/images/cart-checkout-paypal-express.gif" style="border: 0pt" />
\t</form>
\t<br />
\t
EOH;
                    }
                    if ($settings['paypal_basic']) {
                        $this->Page->Content .= <<<EOH
\t
\t<form action="{$this->Site->URL}/shop/cart/information/" method="post">
\t\t<input type="hidden" name="paymentType" value="Sale">
\t\t
\t\t<input type="hidden" name="paymentAmount" size="5" maxlength="7" value="{$total}" />
\t\t<input type="hidden" name="currencyCodeType" value="USD" />
\t\t
\t\t<input type="hidden" name="type" value="pp_basic">
\t\t
\t\t<input type="image" name="submit" title="Checkout your choices" src="{$this->Site->URL}/modules/eCommerce/images/cart-checkout-paypal-basic.gif" style="border: 0pt" />
\t</form>
\t<br />
\t
EOH;
                    }
                    $this->Page->Content .= <<<EOH
\t\t\t\t\t\t
</div>

<script type="text/javascript">
\tjQuery(document).ready(function(\$)
\t{
\t\t\$(".deleteAll").click(function()
\t\t{
\t\t\tvar self = this;
\t\t\t
\t\t\t\$(this).parents("table:first").find(":checkbox").each(function()
\t\t\t{
\t\t\t\tthis.checked = self.checked;
\t\t\t});
\t\t});
\t});
</script>

EOH;
                }
                break;
        }
    }
Calls CallerService.php and APIError.php.

******************************************************/
// clearing the session before starting new API Call
session_unset();
require_once '../CallerService.php';
session_start();
$profileID = urlencode($_REQUEST['profileID']);
$action = urlencode($_REQUEST['action']);
/* Construct the request string that will be sent to PayPal.
   The variable $nvpstr contains all the variables and is a
   name value pair string with & as a delimiter */
$nvpStr = "&PROFILEID={$profileID}&ACTION={$action}";
/* Make the API call to PayPal, using API signature.
   The API response is stored in an associative array called $resArray */
$resArray = hash_call("ManageRecurringPaymentsProfileStatus", $nvpStr);
/* Next, collect the API request in the associative array $reqArray
   as well to display back to the browser.
   Normally you wouldnt not need to do this, but its shown for testing */
$reqArray = $_SESSION['nvpReqArray'];
/* Display the API response back to the browser.
   If the response from PayPal was a success, display the response parameters'
   If the response was an error, display the errors received using APIError.php.
   */
$ack = strtoupper($resArray["ACK"]);
if ($ack != "SUCCESS") {
    $_SESSION['reshash'] = $resArray;
    $location = "../APIError.php";
    header("Location: {$location}");
}
?>
Calls CallerService.php and APIError.php.

******************************************************/
// clearing the session before starting new API Call
session_unset();
require_once '../CallerService.php';
session_start();
$profileID = urlencode($_REQUEST['profileID']);
/* Construct the request string that will be sent to PayPal.
   The variable $nvpstr contains all the variables and is a
   name value pair string with & as a delimiter */
$nvpStr = "&PROFILEID={$profileID}";
/* Make the API call to PayPal, using API signature.
   The API response is stored in an associative array called $resArray */
$resArray = hash_call("GetRecurringPaymentsProfileDetails", $nvpStr);
/* Next, collect the API request in the associative array $reqArray
   as well to display back to the browser.
   Normally you wouldnt not need to do this, but its shown for testing */
$reqArray = $_SESSION['nvpReqArray'];
/* Display the API response back to the browser.
   If the response from PayPal was a success, display the response parameters'
   If the response was an error, display the errors received using APIError.php.
   */
$ack = strtoupper($resArray["ACK"]);
if ($ack != "SUCCESS") {
    $_SESSION['reshash'] = $resArray;
    $location = "../APIError.php";
    header("Location: {$location}");
}
?>
示例#13
0
/**
 * Purpose: 	This function makes a MassPay API call
 * Inputs:
 *		Beneficiarie:		Array that contains the Beneficiearie paypal account and the payout amount
 *		Currency Code:  	The currency Iso code
 * Returns:
 *		The NVP Collection object of the MassPay Call Response.
 */
function MassPayment(array $beneficiaries, $currencyCode)
{
    $nvpstr = "&RECEIVERTYPE=EmailAddress";
    $nvpstr .= "&CURRENCYCODE=" . $currencyCode;
    $index = 0;
    foreach ($beneficiaries as $beneficiary) {
        $nvpstr .= "&L_EMAIL" . $index . "=" . $beneficiary['paypal_account'];
        $nvpstr .= "&L_AMT" . $index . "=" . $beneficiary['commission'];
        $index++;
    }
    $resArray = hash_call("MassPay", $nvpstr);
    return $resArray;
}
示例#14
0
function ConfirmPayment($FinalPaymentAmt)
{
    /* Gather the information to make the final call to
       finalize the PayPal payment.  The variable nvpstr
       holds the name value pairs
       */
    //Format the other parameters that were stored in the session from the previous calls
    $token = urlencode($_SESSION['token']);
    $paymentType = urlencode($_SESSION['paymentType']);
    $currencyCodeType = urlencode($_SESSION['currencyCodeType']);
    $payerID = urlencode($_SESSION['payer_id']);
    $serverName = urlencode($_SERVER['SERVER_NAME']);
    $nvpstr = '&TOKEN=' . $token . '&PAYERID=' . $payerID . '&PAYMENTACTION=' . $paymentType . '&AMT=' . $FinalPaymentAmt;
    $nvpstr .= '&CURRENCYCODE=' . $currencyCodeType . '&IPADDRESS=' . $serverName;
    /* Make the call to PayPal to finalize payment
       If an error occured, show the resulting errors
       */
    $resArray = hash_call("DoExpressCheckoutPayment", $nvpstr);
    /* Display the API response back to the browser.
       If the response from PayPal was a success, display the response parameters'
       If the response was an error, display the errors received using APIError.php.
       */
    $ack = strtoupper($resArray["ACK"]);
    return $resArray;
}
 public function finishAction()
 {
     $order_id = session_id();
     $this->view->headTitle('Reservation');
     $objReser = new Models_Reservation();
     $resId = $this->_getParam('rid', false);
     if (false === $resId) {
         $this->_redirect('');
     }
     /**
      * Get restaurant
      */
     $objRes = new Models_Restaurant();
     $res = $objRes->find($resId)->toArray();
     $res = current($res);
     if (false == $res || '0' == $res['reser_onoff']) {
         $this->_redirect('');
     }
     /**
      * Check active restaurant
      */
     $this->_checkReservationOfRestaurant($res);
     /**
      * Get search condition
      */
     $t = $this->_getParam('t', false);
     $search = $this->session->reserSearch;
     if (null == $search || false == $t || 0 >= $search['quantity']) {
         $this->_redirect('restaurant/reservation/index/rid/' . $resId);
     }
     $t = base64_decode($t);
     /**
      * Update search
      */
     $search['date'] = date('m/d/Y', $t);
     $search['time'] = date('G', $t) * 3600 + ceil(date('i', $t) / 30) * 1800;
     $search['unixTime'] = $t;
     $this->session->reserSearch = $search;
     //        echo '<pre>';print_r($search);die;
     /**
      * Check availabe at current time
      */
     $exitResers = $objReser->searchExistRerservation($t, $t, $res['reser_quantity'] - $search['quantity']);
     if (0 < count($exitResers)) {
         /**
          * Some users are faster :)
          */
         $this->_redirect('restaurant/reservation/index/rid/' . $resId);
     }
     /**
      * Submit?
      */
     $error = '';
     $data = $this->_getParam('data', false);
     //        echo '<pre>';print_r($data);die;
     if (false != $data) {
         //            echo '<pre>';print_r($data);die;
         /**
          * Insert reservation
          */
         $newData = array('restaurant_id' => $resId, 'time' => $search['unixTime'], 'quantity' => $search['quantity'], 'created_date' => time(), 'deposit' => '1' == $res['reser_deposit_onoff'] ? $res['reser_deposit'] : 0, 'full_name' => $data['full_name'], 'address' => $data['address'], 'note' => $data['note'], 'city' => $data['city'], 'state' => $data['state'], 'zip_code' => $data['zip_code'], 'phone' => $data['phone1'] . "." . $data['phone2'] . "." . $data['phone3'], 'email' => $data['email'], 'special_request' => $data['special_request']);
         $newReserId = $objReser->insert($newData);
         if ('1' == $res['reser_deposit_onoff']) {
             /**************************************************************************
              * Make payment
              */
             require_once 'libs/paypal/CallerService.php';
             /**
              * Fist name, last name
              */
             $firstName = trim(substr($data['full_name'], 0, strpos($data['full_name'] . ' ', ' ') + 1));
             $lastName = trim(substr($data['full_name'], strlen($firstName)));
             /**
              * Get required parameters from the web form for the request
              */
             $paymentType = urlencode('Sale');
             $firstName = urlencode($firstName);
             $lastName = urlencode($lastName);
             $creditCardType = urlencode($data['card_type']);
             $creditCardNumber = urlencode($data['card_number']);
             $expDateMonth = urlencode($data['card_month']);
             // Month must be padded with leading zero
             $padDateMonth = str_pad($expDateMonth, 2, '0', STR_PAD_LEFT);
             $expDateYear = urlencode($data['card_year']);
             $cvv2Number = urlencode($data['card_cvv']);
             $address1 = urlencode($data['address']);
             $address2 = urlencode('');
             $city = urlencode($data['city']);
             $state = urlencode($data['state']);
             $zip = urlencode($data['zip_code']);
             $amount = urlencode(number_format($res['reser_deposit'], 2, '.', ''));
             $currencyCode = "CAD";
             //            $state = 'NL';
             $country = 'CA';
             /* Construct the request string that will be sent to PayPal.
                The variable $nvpstr contains all the variables and is a
                name value pair string with & as a delimiter */
             $nvpstr = "&PAYMENTACTION={$paymentType}&AMT={$amount}&CREDITCARDTYPE={$creditCardType}&ACCT={$creditCardNumber}&EXPDATE=" . $padDateMonth . $expDateYear . "&CVV2={$cvv2Number}&FIRSTNAME={$firstName}&LASTNAME={$lastName}&STREET={$address1}&CITY={$city}&STATE={$state}" . "&ZIP={$zip}&COUNTRYCODE={$country}&CURRENCYCODE={$currencyCode}";
             //            echo $nvpstr;die;
             /* Make the API call to PayPal, using API signature.
                The API response is stored in an associative array called $resArray */
             $resArray = hash_call("doDirectPayment", $nvpstr);
             //            echo '<pre>';print_r($resArray);die;
             /* Display the API response back to the browser.
                If the response from PayPal was a success, display the response parameters'
                If the response was an error, display the errors received using APIError.php.
                */
             $ack = strtoupper($resArray["ACK"]);
             /**
              * End payment
              **************************************************************************/
         }
         if ('1' == $res['reser_deposit_onoff'] && $ack != "SUCCESS") {
             $error = @$resArray['L_LONGMESSAGE0'];
             /**
              * Delete reservation
              */
             $objReser->delete(array('reservation_id=?' => $newReserId));
         } else {
             /**
              * Success
              */
             /**
              * Send email to admin and user
              */
             $objUser = new Models_User();
             $objMail = new Models_Mail();
             $config = Vi_Registry::getConfig();
             $cardNumber = @$data['card_number'];
             $cardNumber[4] = 'X';
             $cardNumber[5] = 'X';
             $cardNumber[6] = 'X';
             $cardNumber[7] = 'X';
             $cardNumber[8] = 'X';
             $cardNumber[9] = 'X';
             $cardNumber[10] = 'X';
             $cardNumber[11] = 'X';
             $data['card_number'] = $cardNumber;
             $cartDetail = "\n                     <table width='90%'>\n                            <tr>\n                                <td width='55%'></td>\n                                <td width='15%'></td>\n                                <td width='15%'></td>\n                                <td width='15%'></td>\n                            </tr>\n                            <tr>\n                                <td style='color: #442006; font-weight: bold;'>SHIPPING ADDRESS</td>\n                                <td colspan='3'  style='color: #442006; font-weight: bold;'>RESTAURANT</td>\n                            </tr> \n                            <tr>\n                               <td valign='top'>\n                                   <br/>\n                                   <table width='400px;'>\n            \n                                       <tr>\n                                           <td width='30%' align='right' style='background-color: #EEEEEE;'>Full Name:</td>\n                                           <td width='70%' style='color: #442006;'>{$data['full_name']}</td>\n                                       </tr>\n                                       <tr>\n                                           <td align='right' style='background-color: #EEEEEE;'>Address:</td>\n                                           <td style='color: #442006;'>{$data['address']}</td>\n            \n                                       </tr>\n                                       <tr>\n                                           <td align='right' style='background-color: #EEEEEE;'>Postal Code:</td>\n                                           <td style='color: #442006;'>{$data['zip_code']}</td>\n                                       </tr>\n                                       <tr>\n                                           <td align='right' style='background-color: #EEEEEE;'>Phone:</td>\n            \n                                           <td style='color: #442006;'>{$data['phone1']}.{$data['phone2']}.{$data['phone3']}</td>\n                                       </tr>\n                                       <tr>\n                                           <td align='right' style='background-color: #EEEEEE;'>Special Requests:</td>\n            \n                                           <td style='color: #442006;'>{$data['special_request']}</td>\n                                       </tr>\n                                   </table>\n                                   <br/>\n                                   \n                               </td>\n                               <td valign='top'>\n                                   <br/>\n                                   <table width='400px;'>\n            \n                                       <tr>\n                                           <td width='30%' align='right' style='background-color: #EEEEEE;'>Name:</td>\n                                           <td width='70%' style='color: #442006;'>{$res['name']}</td>\n                                       </tr>\n                                       <tr>\n                                           <td align='right' style='background-color: #EEEEEE;'>Address:</td>\n                                           <td style='color: #442006;'>{$res['street']}, {$res['city']}, {$res['state']}</td>\n                                       </tr>\n                                       <tr>\n                                           <td width='30%' align='right' style='background-color: #EEEEEE;'>Phone:</td>\n                                           <td width='70%' style='color: #442006;'>{$res['phone']}</td>\n                                       </tr>" . ('1' == $res['reser_deposit_onoff'] ? "\n                                       <tr>\n                                           <td colspan='2' style='color: #442006; font-weight: bold;'><br/>PAYMENT METHOD</td>\n                                       </tr>\n                                       <tr>\n                                           <td  align='right' colspan='2'>{$data['card_type']}: {$data['card_number']}</td>\n                                       </tr>" : "") . "\n                                   </table>\n                                   <br/>\n                               </td>\n            \n                            </tr>\n                         </table>   \n                         \n                         <table width='90%'>   \n                            <tr style='background-color: #DDDDDD;'>\n                                <td width='25%' style='color: #AD5B21; font-weight: bold;'> Date</td>\n                                <td width='25%' style='color: #AD5B21; font-weight: bold;'> Time</td>\n                                <td width='25%' style='color: #AD5B21; font-weight: bold;'> Party Size</td>\n                                <td width='25%' style='color: #AD5B21; font-weight: bold;'> Deposit</td>\n                            </tr>\n                             <tr>\n                                <td style='border-bottom: 1px solid #DDDDDD;'> " . date('m/d/Y', $t) . " </td>\n                                <td style='border-bottom: 1px solid #DDDDDD;'>  " . date('g:i A', $t) . "</td>\n                                <td style='border-bottom: 1px solid #DDDDDD;'> {$search['quantity']} " . (1 == $search['quantity'] ? 'person' : 'people') . " </td>\n                                <td style='border-bottom: 1px solid #DDDDDD;'>\$ " . ('1' == $res['reser_deposit_onoff'] ? number_format($res['reser_deposit'] * 1.0, 2) : 0) . "</td>\n                            </tr>\n                            \n                        </table>\n                ";
             $data['card_detail'] = $cartDetail;
             //            echo '<pre>';print_r($data);die;
             $admin = $objUser->getByUserName('admin');
             $objMail->sendHtmlMail('reservation_order', $data, array($admin['email'], $data['email'], $res['owner_email']));
             /**
              * Redirec to success page
              */
             $objContent = new Models_ScontentLang();
             $this->_redirect($objContent->getUrlWithoutAppBaseUrl(22));
             return;
         }
     }
     /**
      * Data for view
      */
     $this->view->res = $res;
     $this->view->arr_restaurant = $res;
     $this->view->resId = $resId;
     $this->view->search = $search;
     $this->view->data = $data;
     $this->view->error = $error;
     $this->view->address_restaurant = $res['street'] . " " . $res['city'] . " " . $res['state'];
     /**
      * Expired year
      */
     $years = array();
     for ($i = date('Y'); $i <= date('Y') + 7; $i++) {
         $years[] = $i;
     }
     $this->view->years = $years;
     /**
      * All province
      */
     $obj_country = new Models_Country();
     $arr_province = $obj_country->getAllProvincesWithCode();
     $this->view->arr_province = $arr_province;
 }
示例#16
0
function CancelRecurrentPayment($profileid)
{
    global $IPNNotifyURL;
    /* Gather the information to make the final call to
       finalize the PayPal payment.  The variable nvpstr
       holds the name value pairs
       */
    $nvpstr = "&PROFILEID=" . urlencode($profileid);
    $nvpstr .= "&ACTION=Cancel";
    $nvpstr .= "&NOTE=" . urlencode(_('This recurring payment was cancelled consecutively to' . ' your upgrade to an unlimited fanship (FOFA)'));
    $nvpstr .= "&NOTIFYURL=" . $IPNNotifyURL;
    /* Make the call to PayPal to finalize payment
       If an error occured, show the resulting errors
       */
    $resArray = hash_call("ManageRecurringPaymentsProfileStatus", $nvpstr);
    /* Display the API response back to the browser.
       If the response from PayPal was a success, display the response parameters'
       If the response was an error, display the errors received using APIError.php.
       */
    $ack = strtoupper($resArray["ACK"]);
    return $resArray;
}
session_start();
$transaction_id = urlencode($_REQUEST['transactionID']);
$refundType = urlencode($_REQUEST['refundType']);
$amount = urlencode($_REQUEST['amount']);
$currency = urlencode($_REQUEST['currency']);
$memo = urlencode($_REQUEST['memo']);
/* Construct the request string that will be sent to PayPal.
   The variable $nvpstr contains all the variables and is a
   name value pair string with & as a delimiter */
$nvpStr = "&TRANSACTIONID={$transaction_id}&REFUNDTYPE={$refundType}&CURRENCYCODE={$currency}&NOTE={$memo}";
if (strtoupper($refundType) == "PARTIAL") {
    $nvpStr = $nvpStr . "&AMT={$amount}";
}
/* Make the API call to PayPal, using API signature.
   The API response is stored in an associative array called $resArray */
$resArray = hash_call("RefundTransaction", $nvpStr);
/* Next, collect the API request in the associative array $reqArray
   as well to display back to the browser.
   Normally you wouldnt not need to do this, but its shown for testing */
$reqArray = $_SESSION['nvpReqArray'];
/* Display the API response back to the browser.
   If the response from PayPal was a success, display the response parameters'
   If the response was an error, display the errors received using APIError.php.
   */
$ack = strtoupper($resArray["ACK"]);
if ($ack != "SUCCESS") {
    $_SESSION['reshash'] = $resArray;
    $location = "APIError.php";
    header("Location: {$location}");
}
?>
示例#18
0
******************************************************/
// clearing the session before starting new API Call
session_unset();
require_once 'CallerService.php';
session_start();
$authorizationID = urlencode($_REQUEST['authorizationID']);
$amount = urlencode($_REQUEST['amount']);
$currency = urlencode($_REQUEST['currency']);
/* Construct the request string that will be sent to PayPal.
   The variable $nvpstr contains all the variables and is a
   name value pair string with & as a delimiter */
$nvpStr = "&AUTHORIZATIONID={$authorizationID}&AMT={$amount}&CURRENCYCODE={$currency}";
/* Make the API call to PayPal, using API signature.
   The API response is stored in an associative array called $resArray */
$resArray = hash_call("DoReauthorization", $nvpStr);
/* Next, collect the API request in the associative array $reqArray
   as well to display back to the browser.
   Normally you wouldnt not need to do this, but its shown for testing */
$reqArray = $_SESSION['nvpReqArray'];
/* Display the API response back to the browser.
   If the response from PayPal was a success, display the response parameters'
   If the response was an error, display the errors received using APIError.php.
   */
$ack = strtoupper($resArray["ACK"]);
if ($ack != "SUCCESS") {
    $_SESSION['reshash'] = $resArray;
    $location = "APIError.php";
    header("Location: {$location}");
}
?>
示例#19
0
function masspay_request($subject = '', $receiver_mail = '', $currency_code = '', $payer_id = '', $amount = '', $unique_id = '', $note = '')
{
    /**
     * Get required parameters from the web form for the request
     */
    $emailSubject = urlencode($subject);
    $receiverType = urlencode($receiver_mail);
    $currency = urlencode($currency_code);
    $nvpstr = '';
    //$count= count($_POST['receiveremail']);
    $receiverEmail = urlencode($payer_id);
    $amount = urlencode($amount);
    $uniqueID = urlencode($unique_id);
    $note = urlencode($note);
    $nvpstr .= "&L_EMAIL0={$receiverEmail}&L_Amt0={$amount}&L_UNIQUEID0={$uniqueID}&L_NOTE0={$note}";
    /* Construct the request string that will be sent to PayPal.
       The variable $nvpstr contains all the variables and is a
       name value pair string with & as a delimiter */
    $nvpstr .= "&EMAILSUBJECT={$emailSubject}&RECEIVERTYPE={$receiverType}&CURRENCYCODE={$currency}";
    /* Make the API call to PayPal, using API signature.
       The API response is stored in an associative array called $resArray */
    $resArray = hash_call("MassPay", $nvpstr);
    //print_r($resArray); exit;
    /* Display the API response back to the browser.
       If the response from PayPal was a success, display the response parameters'
       If the response was an error, display the errors received using APIError.php.
       */
    $ack = strtoupper($resArray["ACK"]);
    if ($ack != "SUCCESS" and $ack != "SUCCESSWITHWARNING") {
        return $resArray;
    } elseif ($ack == "SUCCESS" or $ack == "SUCCESSWITHWARNING") {
        $orderdetails = "<table>";
        foreach ($resArray as $key => $value) {
            $orderdetails .= "<tr><td> {$key}:</td><td>{$value}</td>";
        }
        //send mail to receipient..
        $orderdetails .= "</table>";
        $to = $receiver_mail;
        $subject = $subject;
        $message = $orderdetails;
        $headers = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        // Additional headers
        $headers .= 'From: ' . SITE_EMAIL . '' . "\r\n";
        @mail($to, $subject, $message, $headers);
        return $resArray;
    }
}
Calls CallerService.php and APIError.php.

******************************************************/
// clearing the session before starting new API Call
session_unset();
require_once 'CallerService.php';
session_start();
$authorizationID = urlencode($_REQUEST['authorization_id']);
$note = urlencode($_REQUEST['note']);
/* Construct the request string that will be sent to PayPal.
   The variable $nvpstr contains all the variables and is a
   name value pair string with & as a delimiter */
$nvpStr = "&AUTHORIZATIONID={$authorizationID}&NOTE={$note}";
/* Make the API call to PayPal, using API signature.
   The API response is stored in an associative array called $resArray */
$resArray = hash_call("DOVoid", $nvpStr);
/* Next, collect the API request in the associative array $reqArray
   as well to display back to the browser.
   Normally you wouldnt not need to do this, but its shown for testing */
$reqArray = $_SESSION['nvpReqArray'];
/* Display the API response back to the browser.
   If the response from PayPal was a success, display the response parameters'
   If the response was an error, display the errors received using APIError.php.
   */
$ack = strtoupper($resArray["ACK"]);
if ($ack != "SUCCESS") {
    $_SESSION['reshash'] = $resArray;
    $location = "APIError.php";
    header("Location: {$location}");
}
?>
示例#21
0
errors received.

Called by DoCapture.html.

Calls CallerService.php and APIError.php.

******************************************************/
// clearing the session before starting new API Call
require_once 'CallerService.php';
/* Construct the request string that will be sent to PayPal.
   The variable $nvpstr contains all the variables and is a
   name value pair string with & as a delimiter */
$nvpStr = "";
/* Make the API call to PayPal, using API signature.
   The API response is stored in an associative array called $resArray */
$resArray = hash_call("GetBalance", $nvpStr);
/* Next, collect the API request in the associative array $reqArray
   as well to display back to the browser.
   Normally you wouldnt not need to do this, but its shown for testing */
$reqArray = $_SESSION['nvpReqArray'];
/* Display the API response back to the browser.
   If the response from PayPal was a success, display the response parameters'
   If the response was an error, display the errors received using APIError.php.
   */
$ack = strtoupper($resArray["ACK"]);
if ($ack != "SUCCESS") {
    $_SESSION['reshash'] = $resArray;
    $location = "APIError.php";
    header("Location: {$location}");
}
?>
$totalBillingCycles = urlencode($_POST['totalBillingCycles']);
$profileStartDateDay = $_POST['profileStartDateDay'];
// Day must be padded with leading zero
$padprofileStartDateDay = str_pad($profileStartDateDay, 2, '0', STR_PAD_LEFT);
$profileStartDateMonth = $_POST['profileStartDateMonth'];
// Month must be padded with leading zero
$padprofileStartDateMonth = str_pad($profileStartDateMonth, 2, '0', STR_PAD_LEFT);
$profileStartDateYear = $_POST['profileStartDateYear'];
$profileStartDate = urlencode($profileStartDateYear . '-' . $padprofileStartDateMonth . '-' . $padprofileStartDateDay . 'T00:00:00Z');
/* Construct the request string that will be sent to PayPal.
   The variable $nvpstr contains all the variables and is a
   name value pair string with & as a delimiter */
$nvpstr = "&AMT={$amount}&CREDITCARDTYPE={$creditCardType}&ACCT={$creditCardNumber}&EXPDATE=" . $padDateMonth . $expDateYear . "&CVV2={$cvv2Number}&FIRSTNAME={$firstName}&LASTNAME={$lastName}&STREET={$address1}&CITY={$city}&STATE={$state}" . "&ZIP={$zip}&COUNTRYCODE=US&CURRENCYCODE={$currencyCode}&PROFILESTARTDATE={$profileStartDate}&DESC={$profileDesc}&BILLINGPERIOD={$billingPeriod}&BILLINGFREQUENCY={$billingFrequency}&TOTALBILLINGCYCLES={$totalBillingCycles}";
/* Make the API call to PayPal, using API signature.
   The API response is stored in an associative array called $resArray */
$resArray = hash_call("CreateRecurringPaymentsProfile", $nvpstr);
/* Display the API response back to the browser.
   If the response from PayPal was a success, display the response parameters'
   If the response was an error, display the errors received using APIError.php.
   */
$ack = strtoupper($resArray["ACK"]);
if ($ack != "SUCCESS") {
    $_SESSION['reshash'] = $resArray;
    $location = "../APIError.php";
    header("Location: {$location}");
}
?>

<html>
<head>
    <title>PayPal PHP SDK - CreateRecurringPaymentsProfile API</title>
示例#23
0
        $amount = urlencode($_POST['amount'][$i]);
        $uniqueID = urlencode($_POST['uniqueID'][$i]);
        $note = urlencode($_POST['note'][$i]);
        $nvpstr .= "&L_EMAIL{$j}={$receiverEmail}&L_Amt{$j}={$amount}&L_UNIQUEID{$j}={$uniqueID}&L_NOTE{$j}={$note}";
        $j++;
    }
}
/* Construct the request string that will be sent to PayPal.
   The variable $nvpstr contains all the variables and is a
   name value pair string with & as a delimiter */
$nvpstr .= "&EMAILSUBJECT={$emailSubject}&RECEIVERTYPE={$receiverType}&CURRENCYCODE={$currency}";
echo $nvpstr;
exit;
/* Make the API call to PayPal, using API signature.
   The API response is stored in an associative array called $resArray */
$resArray = hash_call("MassPay", $nvpstr);
/* Display the API response back to the browser.
   If the response from PayPal was a success, display the response parameters'
   If the response was an error, display the errors received using APIError.php.
   */
$ack = strtoupper($resArray["ACK"]);
if ($ack != "SUCCESS") {
    $_SESSION['reshash'] = $resArray;
    $location = "APIError.php";
    header("Location: {$location}");
}
?>

<html>
<head>
    <title>PayPal PHP SDK - MassPay API</title>
示例#24
0
 /**
  * List all meal follow restaurant
  */
 public function indexAction()
 {
     $this->view->headTitle('Cart information');
     $order_id = session_id();
     if (!isset($_SESSION['cart'][$order_id])) {
         $this->_redirect('');
     }
     /**
      * Get restaurant
      */
     $objRes = new Models_Restaurant();
     $res = $objRes->find($_SESSION['cart'][$order_id]['restaurant_id'])->toArray();
     $res = current($res);
     //        echo '<pre>';print_r($_SESSION);//die;
     //        echo '<pre>';print_r($res);die;
     if (false == $res) {
         $this->_redirect('');
     }
     $this->view->session_cart = $_SESSION['cart'][$order_id];
     $this->view->subtotal = $_SESSION['cart'][$order_id]['subtotal'];
     $this->view->tax = $_SESSION['cart'][$order_id]['tax'];
     $this->view->shipping = $_SESSION['cart'][$order_id]['shipping'];
     $this->view->ordertotal = $_SESSION['cart'][$order_id]['ordertotal'];
     $this->view->mark = strtoupper($_SESSION['cart'][$order_id]['order_service']);
     $this->view->date = $_SESSION['cart'][$order_id]['date'];
     $this->view->time = $_SESSION['cart'][$order_id]['time'];
     $data_info = $this->_getParam('data', false);
     $confirm = $this->_getParam('confirm', false);
     /**
      * Remember customer's infomation
      */
     if (false !== $data_info) {
         $_SESSION['cart_customer'] = $data_info;
     }
     $data_info = $_SESSION['cart_customer'];
     $this->view->full_name = $data_info['full_name'];
     $this->view->address = $data_info['address'];
     $this->view->zip_code = $data_info['zip_code'];
     $this->view->phone = $data_info['phone1'] . "." . $data_info['phone2'] . "." . $data_info['phone3'];
     $this->view->cardType = $_SESSION['cart_customer']['card_type'];
     $cardNumber = $_SESSION['cart_customer']['card_number'];
     $cardNumber[4] = 'X';
     $cardNumber[5] = 'X';
     $cardNumber[6] = 'X';
     $cardNumber[7] = 'X';
     $cardNumber[8] = 'X';
     $cardNumber[9] = 'X';
     $cardNumber[10] = 'X';
     $cardNumber[11] = 'X';
     $this->view->cardNumber = $cardNumber;
     $error = '';
     /**
      * Store to DB and redirect
      */
     if (false != $confirm) {
         /**************************************************************************
          * Make payment
          */
         require_once 'libs/paypal/CallerService.php';
         /**
          * Fist name, last name
          */
         $firstName = trim(substr($data_info['full_name'], 0, strpos($data_info['full_name'] . ' ', ' ') + 1));
         $lastName = trim(substr($data_info['full_name'], strlen($firstName)));
         /**
          * Get required parameters from the web form for the request
          */
         $paymentType = urlencode('Sale');
         $firstName = urlencode($firstName);
         $lastName = urlencode($lastName);
         $creditCardType = urlencode($data_info['card_type']);
         $creditCardNumber = urlencode($data_info['card_number']);
         $expDateMonth = urlencode($data_info['card_month']);
         // Month must be padded with leading zero
         $padDateMonth = str_pad($expDateMonth, 2, '0', STR_PAD_LEFT);
         $expDateYear = urlencode($data_info['card_year']);
         $cvv2Number = urlencode($data_info['card_cvv']);
         $address1 = urlencode($data_info['address']);
         $address2 = urlencode('');
         $city = urlencode($data_info['city']);
         $state = urlencode($data_info['state']);
         $zip = urlencode($data_info['zip_code']);
         $amount = urlencode(number_format($_SESSION['cart'][$order_id]['ordertotal'], 2, '.', ''));
         $currencyCode = "CAD";
         //            $state = 'NL';
         $country = 'CA';
         /* Construct the request string that will be sent to PayPal.
            The variable $nvpstr contains all the variables and is a
            name value pair string with & as a delimiter */
         $nvpstr = "&PAYMENTACTION={$paymentType}&AMT={$amount}&CREDITCARDTYPE={$creditCardType}&ACCT={$creditCardNumber}&EXPDATE=" . $padDateMonth . $expDateYear . "&CVV2={$cvv2Number}&FIRSTNAME={$firstName}&LASTNAME={$lastName}&STREET={$address1}&CITY={$city}&STATE={$state}" . "&ZIP={$zip}&COUNTRYCODE={$country}&CURRENCYCODE={$currencyCode}";
         //            echo $nvpstr;die;
         /* Make the API call to PayPal, using API signature.
            The API response is stored in an associative array called $resArray */
         $resArray = hash_call("doDirectPayment", $nvpstr);
         //            echo '<pre>';print_r($resArray);die;
         /* Display the API response back to the browser.
            If the response from PayPal was a success, display the response parameters'
            If the response was an error, display the errors received using APIError.php.
            */
         $ack = strtoupper($resArray["ACK"]);
         if ($ack != "SUCCESS") {
             $_SESSION['card_error_msg'] = @$resArray['L_LONGMESSAGE0'];
             $this->_redirect('restaurant/ship');
         }
         /**
          * End payment
          **************************************************************************/
         //-- begin save into db: vi_order and vi_order_detail
         $arr_order = array('sub_total' => $_SESSION['cart'][$order_id]['subtotal'], 'sales_tax' => $_SESSION['cart'][$order_id]['tax'], 'shipping_fee' => $_SESSION['cart'][$order_id]['shipping'], 'order_total' => $_SESSION['cart'][$order_id]['ordertotal'], 'date' => $_SESSION['cart'][$order_id]['date'], 'time' => $_SESSION['cart'][$order_id]['time'], 'order_service' => $_SESSION['cart'][$order_id]['order_service'], 'full_name' => $data_info['full_name'], 'address' => $data_info['address'], 'suite' => $data_info['note'], 'city' => $data_info['city'], 'state' => $data_info['state'], 'zip_code' => $data_info['zip_code'], 'phone' => $data_info['phone1'] . "." . $data_info['phone2'] . "." . $data_info['phone3'], 'email' => $data_info['email'], 'created_date' => time(), 'restaurant_id' => $_SESSION['cart'][$order_id]['restaurant_id']);
         $objOrder = new Models_Order();
         $bResultOrder = $objOrder->insert($arr_order);
         foreach ($_SESSION['cart'][$order_id] as $key => $value) {
             $arr_order_detail = array('order_id' => $bResultOrder, 'meal_id' => $value['meal_id'], 'name' => $value['name'], 'description' => $value['description'], 'price' => $value['price'], 'quantity' => $value['quantity'], 'total' => $value['total_money']);
             if (!empty($value['name'])) {
                 $objOrderDetail = new Models_OrderDetail();
                 $objOrderDetail->insert($arr_order_detail);
             }
         }
         //-- end save into db: vi_order and vi_order_detail
         /**
          * Send email to admin and user
          */
         $objUser = new Models_User();
         $objMail = new Models_Mail();
         $data = $arr_order;
         $config = Vi_Registry::getConfig();
         $data['created_date'] = date($config['dateFormat'], $data['created_date']);
         $data['card_type'] = $this->view->cardType;
         $data['card_number'] = $this->view->cardNumber;
         //            echo '<pre>';print_r($data);die;
         $cartDetail = "\n            <table width='90%'>\n                <tr>\n                    <td width='55%'></td>\n                    <td width='15%'></td>\n                    <td width='15%'></td>\n                    <td width='15%'></td>\n                </tr>\n                <tr>\n                    <td style='color: #442006; font-weight: bold;'>SHIPPING ADDRESS</td>\n                    <td colspan='3'  style='color: #442006; font-weight: bold;'>PAYMENT METHOD</td>\n                </tr> \n                <tr>\n                   <td valign='top'>\n                       <br/>\n                       <table width='400px;'>\n\n                           <tr>\n                               <td width='30%' align='right' style='background-color: #EEEEEE;'>Full Name:</td>\n                               <td width='70%' style='color: #442006;'>{$data['full_name']}</td>\n                           </tr>\n                           <tr>\n                               <td align='right' style='background-color: #EEEEEE;'>Address:</td>\n                               <td style='color: #442006;'>{$data['address']}</td>\n\n                           </tr>\n                           <tr>\n                               <td align='right' style='background-color: #EEEEEE;'>Postal Code:</td>\n                               <td style='color: #442006;'>{$data['zip_code']}</td>\n                           </tr>\n                           <tr>\n                               <td align='right' style='background-color: #EEEEEE;'>Phone:</td>\n\n                               <td style='color: #442006;'>{$data['phone']}</td>\n                           </tr>\n                       </table>\n                       <br/>\n                       \n                   </td>\n                   <td valign='top'>\n                       <br/>\n                       <table width='400px;'>\n\n                           <tr>\n                               <td width='30%' align='right' style='background-color: #EEEEEE;'>Name:</td>\n                               <td width='70%' style='color: #442006;'>{$res['name']}</td>\n                           </tr>\n                           <tr>\n                               <td align='right' style='background-color: #EEEEEE;'>Address:</td>\n                               <td style='color: #442006;'>{$res['street']}, {$res['city']}, {$res['state']}</td>\n                           </tr>\n                           <tr>\n                               <td width='30%' align='right' style='background-color: #EEEEEE;'>Phone:</td>\n                               <td width='70%' style='color: #442006;'>{$res['phone']}</td>\n                           </tr>\n                           \n                           <tr>\n                               <td colspan='2' style='color: #442006; font-weight: bold;'><br/>PAYMENT METHOD</td>\n                           </tr>\n                           <tr>\n                               <td  align='right' colspan='2'>{$data['card_type']}: {$data['card_number']}</td>\n                           </tr>\n                           \n                       </table>\n                       <br/>\n                   </td>\n\n                </tr>\n                \n                </table>\n                <table>\n                \n                <tr style='background-color: #DDDDDD;'>\n                    <td style='color: #AD5B21; font-weight: bold;'> Meal</td>\n                    <td style='color: #AD5B21; font-weight: bold;'> </td>\n                    <td style='color: #AD5B21; font-weight: bold;'> Quanlity</td>\n                    <td style='color: #AD5B21; font-weight: bold;'> Price</td>\n                    <td style='color: #AD5B21; font-weight: bold;'> Total</td>\n                </tr> ";
         foreach ($_SESSION['cart'][$order_id] as $key => $meal) {
             if (null == $meal['meal_id']) {
                 continue;
             }
             $mealImage = Vi_Registry::getConfig('liveSite') . '/' . $meal['image'];
             if (null != $meal['image']) {
                 $mealImage = '<img src="' . $mealImage . '" style="max-width: 100px;">';
             } else {
                 $mealImage = '';
             }
             if (is_numeric($key)) {
                 $cartDetail .= "\n\t                 <tr>\n\t                    <td style='border-bottom: 1px solid #DDDDDD;'>\n\t                        {$mealImage}\n\t                    </td>\n\t                    <td style='border-bottom: 1px solid #DDDDDD;'>\n\t                        <b>{$meal['name']}</b>\n\t\n\t                        <br/>\n\t                        <p>{$meal['description']}</p>\n\t                    </td>\n\t                    <td style='border-bottom: 1px solid #DDDDDD;'>{$meal['quantity']}</td>\n\t                    <td style='border-bottom: 1px solid #DDDDDD;'>\$" . number_format($meal['price'] * 1.0, 2) . "</td>\n\t                    <td style='border-bottom: 1px solid #DDDDDD;'>\$" . number_format($meal['total_money'] * 1.0, 2) . "</td>\n\t                </tr>";
             }
         }
         $cartDetail .= "   \n                <tr>\n                    <td colspan='2'> </td>\n                    <td> Subtotal </td>\n                    <td>\$" . number_format($data['sub_total'], 2) . "</td>\n\n                </tr>\n                <tr>\n                    <td colspan='2'> </td>\n                    <td> Tax </td>\n                    <td>\$" . number_format($data['sales_tax'], 2) . "</td>\n                </tr>\n                <tr>\n                    <td colspan='2'> </td>\n                    <td> Shipping fee </td>\n\n                    <td>\$" . number_format($data['shipping_fee'], 2) . "</td>\n                </tr>\n                <tr>\n                    <td colspan='2'> </td>\n                    <td> Order total </td>\n                    <td  style='color: #AD5B21; font-weight: bold;'>\$" . number_format($data['order_total'], 2) . "</td>\n                </tr>\n            </table>\n            ";
         $data['card_detail'] = $cartDetail;
         //            echo '<pre>';print_r($data);die;
         $admin = $objUser->getByUserName('admin');
         $objMail->sendHtmlMail('meal_order', $data, array($admin['email'], $data['email'], $res['owner_email']));
         /**
          * Clear session
          */
         unset($_SESSION['cart']);
         unset($_SESSION['cart_customer']);
         /**
          * Redirec to success page
          */
         $objContent = new Models_ScontentLang();
         $this->_redirect($objContent->getUrlWithoutAppBaseUrl(21));
         return;
     }
 }
示例#25
0
function DirectPayment($paymentType, $paymentAmount, $creditCardType, $creditCardNumber, $expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip, $countryCode, $currencyCode, $tag)
{
    //declaring of global variables
    global $conf, $langs;
    global $API_Endpoint, $API_Url, $API_version, $USE_PROXY, $PROXY_HOST, $PROXY_PORT;
    global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE;
    //Construct the parameter string that describes DoDirectPayment
    $nvpstr = "&AMT=" . urlencode($paymentAmount);
    $nvpstr = $nvpstr . "&CURRENCYCODE=" . urlencode($currencyCode);
    $nvpstr = $nvpstr . "&PAYMENTACTION=" . urlencode($paymentType);
    $nvpstr = $nvpstr . "&CREDITCARDTYPE=" . urlencode($creditCardType);
    $nvpstr = $nvpstr . "&ACCT=" . urlencode($creditCardNumber);
    $nvpstr = $nvpstr . "&EXPDATE=" . urlencode($expDate);
    $nvpstr = $nvpstr . "&CVV2=" . urlencode($cvv2);
    $nvpstr = $nvpstr . "&FIRSTNAME=" . urlencode($firstName);
    $nvpstr = $nvpstr . "&LASTNAME=" . urlencode($lastName);
    $nvpstr = $nvpstr . "&STREET=" . urlencode($street);
    $nvpstr = $nvpstr . "&CITY=" . urlencode($city);
    $nvpstr = $nvpstr . "&STATE=" . urlencode($state);
    $nvpstr = $nvpstr . "&COUNTRYCODE=" . urlencode($countryCode);
    $nvpstr = $nvpstr . "&IPADDRESS=" . $_SERVER['REMOTE_ADDR'];
    $nvpstr = $nvpstr . "&INVNUM=" . urlencode($tag);
    $resArray = hash_call("DoDirectPayment", $nvpstr);
    return $resArray;
}
if (isset($startDateStr)) {
    $start_time = strtotime($startDateStr);
    $iso_start = date('Y-m-d\\T00:00:00\\Z', $start_time);
    $nvpStr = "&STARTDATE={$iso_start}";
}
if (isset($endDateStr) && $endDateStr != '') {
    $end_time = strtotime($endDateStr);
    $iso_end = date('Y-m-d\\T24:00:00\\Z', $end_time);
    $nvpStr .= "&ENDDATE={$iso_end}";
}
if ($transactionID != '') {
    $nvpStr = $nvpStr . "&TRANSACTIONID={$transactionID}";
}
/* Make the API call to PayPal, using API signature.
 The API response is stored in an associative array called $resArray */
$resArray = hash_call("TransactionSearch", $nvpStr);
/* Next, collect the API request in the associative array $reqArray
 as well to display back to the browser.
 Normally you wouldnt not need to do this, but its shown for testing */
$reqArray = $_SESSION['nvpReqArray'];
/* Display the API response back to the browser.
 If the response from PayPal was a success, display the response parameters'
 If the response was an error, display the errors received using APIError.php.
 */
$ack = strtoupper($resArray["ACK"]);
if ($ack != "SUCCESS" && $ack != "SUCCESSWITHWARNING") {
    $_SESSION['reshash'] = $resArray;
    $location = "APIError.php";
    header("Location: {$location}");
}
?>
session_unset();
require_once 'CallerService.php';
session_start();
$authorizationID = urlencode($_REQUEST['authorization_id']);
$completeCodeType = urlencode($_REQUEST['CompleteCodeType']);
$amount = urlencode($_REQUEST['amount']);
$invoiceID = urlencode($_REQUEST['invoice_id']);
$currency = urlencode($_REQUEST['currency']);
$note = urlencode($_REQUEST['note']);
/* Construct the request string that will be sent to PayPal.
   The variable $nvpstr contains all the variables and is a
   name value pair string with & as a delimiter */
$nvpStr = "&AUTHORIZATIONID={$authorizationID}&AMT={$amount}&COMPLETETYPE={$completeCodeType}&CURRENCYCODE={$currency}&NOTE={$note}";
/* Make the API call to PayPal, using API signature.
   The API response is stored in an associative array called $resArray */
$resArray = hash_call("DOCapture", $nvpStr);
/* Next, collect the API request in the associative array $reqArray
   as well to display back to the browser.
   Normally you wouldnt not need to do this, but its shown for testing */
$reqArray = $_SESSION['nvpReqArray'];
/* Display the API response back to the browser.
   If the response from PayPal was a success, display the response parameters'
   If the response was an error, display the errors received using APIError.php.
   */
$ack = strtoupper($resArray["ACK"]);
if ($ack != "SUCCESS") {
    $_SESSION['reshash'] = $resArray;
    $location = "APIError.php";
    header("Location: {$location}");
}
?>
示例#28
0
 Calls CallerService.php and APIError.php.

 ******************************************************/
// clearing the session before starting new API Call
session_unset();
require_once 'CallerService.php';
session_start();
$transactionID = urlencode($_REQUEST['transactionID']);
/* Construct the request string that will be sent to PayPal.
 The variable $nvpstr contains all the variables and is a
 name value pair string with & as a delimiter */
$nvpStr = "&TRANSACTIONID={$transactionID}";
/* Make the API call to PayPal, using API signature.
 The API response is stored in an associative array called $resArray */
$resArray = hash_call("gettransactionDetails", $nvpStr);
/* Next, collect the API request in the associative array $reqArray
 as well to display back to the browser.
 Normally you wouldnt not need to do this, but its shown for testing */
$reqArray = $_SESSION['nvpReqArray'];
/* Display the API response back to the browser.
 If the response from PayPal was a success, display the response parameters'
 If the response was an error, display the errors received using APIError.php.
 */
$ack = strtoupper($resArray["ACK"]);
if ($ack != "SUCCESS") {
    $_SESSION['reshash'] = $resArray;
    $location = "APIError.php";
    header("Location: {$location}");
}
?>
示例#29
0
 function purchaseorder($orderid)
 {
     // Paypal Pro code
     $itemprice = 200;
     //$_POST['banprice'];
     $itemname = 'sample items';
     //$_POST['banname'];
     $orderid = '2';
     //$_POST['banid'];
     $_SESSION['orderid'] = $orderid;
     $token = $_REQUEST['token'];
     if (!isset($token)) {
         $currencyCodeType = 'USD';
         $paymentType = 'Sale';
         $personName = 'Vijay Warade';
         //$_REQUEST['contact_name'];
         $SHIPTOSTREET = 'Ribng road 405';
         //$_REQUEST['SHIPTOSTREET'];
         $SHIPTOCITY = 'Huntsville';
         //$_REQUEST['SHIPTOCITY'];
         $SHIPTOSTATE = 'Alabama';
         //$_REQUEST['SHIPTOSTATE'];
         $SHIPTOCOUNTRYCODE = 'US';
         //$_REQUEST['SHIPTOCOUNTRYCODE'];
         $SHIPTOZIP = '35801';
         //$_REQUEST['zip_code'];
         $L_NAME0 = $itemname;
         //$_REQUEST['package_name'];
         $L_AMT0 = $itemprice;
         //$_REQUEST['price'];
         $L_QTY0 = 2;
         $cancelURL = urldecode(HREF_LINK . 'myaccount/cancel/');
         $returnURL = urldecode(HREF_LINK . 'myaccount/thankyou/');
         $itemamt = 0.0;
         $itemamt = $L_AMT0 * $L_QTY0;
         $amt = $itemamt;
         $maxamt = $amt;
         $nvpstr = "";
         /*
          * Setting up the Shipping address details
          */
         $shiptoAddress = "&SHIPTONAME={$personName}&SHIPTOSTREET={$SHIPTOSTREET}&SHIPTOCITY={$SHIPTOCITY}&SHIPTOSTATE={$SHIPTOSTATE}&SHIPTOCOUNTRYCODE={$SHIPTOCOUNTRYCODE}&SHIPTOZIP={$SHIPTOZIP}";
         $nvpstr = "&L_NAME0=" . $L_NAME0 . "&L_AMT0=" . $L_AMT0 . "&L_QTY0=" . $L_QTY0 . "&MAXAMT=" . (string) $maxamt . "&AMT=" . (string) $amt . "&ITEMAMT=" . (string) $itemamt . "&L_PAYMENTREQUEST_0_ITEMCATEGORY0=DIGITAL&L_DESC1=" . $desc . "&ReturnUrl=" . $returnURL . "&CANCELURL=" . $cancelURL . "&CURRENCYCODE=" . $currencyCodeType . "&PAYMENTACTION=" . $paymentType . "&orderid=" . $orderid;
         $nvpstr = $nvpHeader . $nvpstr;
         $resArray = hash_call("SetExpressCheckout", $nvpstr);
         $_SESSION['reshash'] = $resArray;
         $ack = strtoupper($resArray["ACK"]);
         if ($ack == "SUCCESS") {
             // Redirect to paypal.com here
             $token = urldecode($resArray["TOKEN"]);
             $payPalURL = PAYPAL_URL . $token;
             header("Location: " . $payPalURL);
         } else {
             $this->dbobject->redirect(HREF_LINK . 'myaccount/cancel/', 'Authorization Error');
         }
     }
 }
示例#30
0
 function NVP_TransactionDetails($transID)
 {
     //very simple nvp request to get the transaction details of a previous purchase.
     $nvpreq = "&TRANSACTIONID={$transID}";
     $nvpRES = hash_call("GetTransactionDetails", $nvpreq);
     $ack = strtoupper($nvpRES["ACK"]);
     //Return our response array if the command was succesful.
     if ($ack != "SUCCESS" && $ack != "SUCCESSWITHWARNING") {
         return false;
     } else {
         return $nvpRES;
     }
 }