public function check_payments_against_shopping_baskets($session_id, $payment_amount_to_be_checked, $payment_currency_to_be_checked)
 {
     $database = $this->get_database();
     $shopping_baskets_table = $database->get_table('hpi_shop_shopping_baskets');
     $shopping_baskets = $shopping_baskets_table->get_shopping_baskets_for_session($session_id);
     $customer_region = $shopping_baskets[0]->get_customer_region();
     $payment_currency = $customer_region->get_currency();
     $payment_amount_unformatted = $shopping_baskets_table->get_total_for_session($session_id);
     $payment_amount = new Shop_SumOfMoney($payment_amount_unformatted, $payment_currency);
     if ($payment_amount_to_be_checked == $payment_amount->get_as_string(FALSE) && $payment_currency_to_be_checked == $payment_currency->get_iso_4217_code()) {
         return TRUE;
     }
     return FALSE;
 }
    // name
    $product = $shopping_basket->get_product();
    $paypal_form->add_hidden_input('item_name_' . $i, $product->get_name());
    // product_id
    $paypal_form->add_hidden_input('item_number_' . $i, $product->get_id());
    // price
    $product_currency_price = $product->get_product_currency_price($currency->get_id());
    $product_price = new Shop_SumOfMoney($product_currency_price->get_price(), $currency);
    $paypal_form->add_hidden_input('amount_' . $i, $product_price->get_as_string(FALSE));
    // quantity
    $paypal_form->add_hidden_input('quantity_' . $i, $shopping_basket->get_quantity());
    // shipping 1
    $shipping_price = new Shop_SumOfMoney($product->get_first_shipping_price_for_current_session(), $currency);
    $paypal_form->add_hidden_input('shipping_' . $i, $shipping_price->get_as_string(FALSE));
    // shipping 2
    $shipping2_price = new Shop_SumOfMoney($product->get_additional_shipping_price_for_current_session(), $currency);
    $paypal_form->add_hidden_input('shipping2_' . $i, $shipping2_price->get_as_string(FALSE));
    $i++;
}
// Address Override
$customer = $log_in_manager->get_user();
$address = $customer->get_address();
$paypal_form->add_hidden_input('address_override', '1');
$paypal_form->add_hidden_input('first_name', $customer->get_first_name());
$paypal_form->add_hidden_input('last_name', $customer->get_last_name());
$paypal_form->add_hidden_input('address1', $address->get_street_address());
$paypal_form->add_hidden_input('city', $address->get_locality());
$paypal_form->add_hidden_input('zip', $address->get_postal_code());
$paypal_form->add_hidden_input('country', $address->get_country_name());
$paypal_submit_input = new HTMLTags_Input();
$paypal_submit_input->set_attribute_str('type', 'submit');
 /**
  * Returns a UL that tells the customer about this product.
  *
  * Details:
  * 	- Price
  * 	- The date the product was first listed
  * 	- The availability of the product.
  */
 public function get_product_details_ul()
 {
     $product = $this->get_element();
     $product_details_ul = new HTMLTags_UL();
     /*
      * The price.
      */
     $product_price_li = new HTMLTags_LI();
     //                $product_price_li->append_str_to_content('Price: ');
     $product_price_span = new HTMLTags_Span();
     $product_price_span->set_attribute_str('class', 'price');
     $database = $product->get_database();
     $customer_regions_table = $database->get_table('hpi_shop_customer_regions');
     $customer_region = $customer_regions_table->get_row_by_id($_SESSION['customer_region_id']);
     $currency = $customer_region->get_currency();
     $product_currency_price = $product->get_product_currency_price($currency->get_id());
     #print_r($product_currency_price);
     //
     //                $product_price_span
     //                        ->append_str_to_content($currency->get_symbol());
     //                $product_price_span
     //                        ->append_str_to_content($product_currency_price->get_price());
     $sum_of_money = new Shop_SumOfMoney($product_currency_price->get_price(), $currency);
     $product_price_span->append_str_to_content($sum_of_money->get_as_string());
     $product_price_li->append_tag_to_content($product_price_span);
     $product_details_ul->append_tag_to_content($product_price_li);
     /*
      * When the product was listed.
      */
     //
     //                $product_listed_li = new HTMLTags_LI();
     //                $product_listed_li->append_str_to_content('Listed: ');
     //                $product_listed_abbr = new HTMLTags_Abbr();
     //                $product_listed_abbr->set_attribute_str('class', 'dtlisted');
     //                $date_added = $product->get_added();
     //                $datetime_iso8601 = Formatting_DateTime::datetime_to_ISO8601($date_added);
     //                $product_listed_abbr->set_attribute_str('title', $datetime_iso8601);
     //                $datetime_human_readable =
     //                        Formatting_DateTime::datetime_to_human_readable($date_added);
     //                $product_listed_abbr->append_str_to_content($datetime_human_readable);
     //                $product_listed_li->append_tag_to_content($product_listed_abbr);
     //                $product_details_ul->append_tag_to_content($product_listed_li);
     //
     /*
      * The availability of the product.
      */
     $product_availability_li = new HTMLTags_LI();
     //                $product_availability_li->append_str_to_content('Availability: ');
     $product_availability_span = new HTMLTags_Span();
     $product_availability_span->set_attribute_str('class', 'availability');
     if (!$product->uses_stock_level()) {
         $product_availability_span->append_str_to_content('In Stock');
     } else {
         if ($product->is_out_of_stock()) {
             $product_availability_span->append_str_to_content('Out of Stock');
         } else {
             #print_r($product->get_available_stock_level());exit;
             $product_availability_span->append_str_to_content($product->get_available_stock_level() . ' in Stock');
         }
     }
     $product_availability_li->append_tag_to_content($product_availability_span);
     $product_details_ul->append_tag_to_content($product_availability_li);
     return $product_details_ul;
 }
    $product_price = new Shop_SumOfMoney($product_currency_price->get_price(), $currency);
    $str_basket .= $product_price->get_as_string(FALSE) . ':';
    // Line Total (unit * quantity)
    $product_currency_price = $product->get_product_currency_price($currency->get_id());
    $line_total = new Shop_SumOfMoney($product_currency_price->get_price() * $shopping_basket->get_quantity(), $currency);
    $str_basket .= $line_total->get_as_string(FALSE) . ':';
}
$shipping_price = new Shop_SumOfMoney($shopping_baskets_table->get_shipping_total_for_current_session($customer_region_id), $currency);
//Delivery Total
$str_basket .= 'Delivery:1::::' . $shipping_price->get_as_string(FALSE);
######################################
// Now to build the VSP Form crypt field.  For more details see the VSP Form Protocol 2.22
$strPost = "VendorTxCode=" . $strVendorTxCode;
/** As generated above **/
//print_r($customer_region);exit;
$shopping_baskets_total = new Shop_SumOfMoney($shopping_baskets_table->get_total_for_current_session($customer_region->get_id()), $currency);
$strPost = $strPost . "&Amount=" . $shopping_baskets_total->get_as_string(FALSE);
// Formatted to 2 decimal places with leading digit
$strPost = $strPost . "&Currency=" . $currency->get_iso_4217_code();
// Up to 100 chars of free format description
$description_str = ProtxPayments_PaymentsManager::get_site_description();
$strPost = $strPost . "&Description=" . $description_str;
/* The SuccessURL is the page to which VSP Form returns the customer if the transaction is successful 
** You can change this for each transaction, perhaps passing a session ID or state flag if you wish */
$strPost = $strPost . "&SuccessURL=" . $strYourSiteFQDN . "?section=plug-ins&module=shop&page=payment-confirmed-protx&session=" . session_id();
/* The FailureURL is the page to which VSP Form returns the customer if the transaction is unsuccessful
** You can change this for each transaction, perhaps passing a session ID or state flag if you wish */
$strPost = $strPost . "&FailureURL=" . $strYourSiteFQDN . "?section=plug-ins&module=shop&page=payment-cancelled";
$strPost = $strPost . "&CustomerName=" . $customer->get_first_name() . $customer->get_last_name();
$strPost = $strPost . "&CustomerEMail=" . $customer->get_email_address();
$strPost = $strPost . "&VendorEMail=" . $strVendorEMail;
 public function get_checkout_shopping_basket_for_current_session_table()
 {
     $shopping_baskets_table = $this->get_element();
     $database = $shopping_baskets_table->get_database();
     $customer_regions_table = $database->get_table('hpi_shop_customer_regions');
     $customer_region = $customer_regions_table->get_row_by_id($_SESSION['customer_region_id']);
     $currency = $customer_region->get_currency();
     $shopping_baskets_table = $this->get_element();
     $checkout_shopping_basket_table = new HTMLTags_Table();
     $checkout_shopping_basket_table->set_attribute_str('id', 'shopping-basket-table');
     $caption = new HTMLTags_Caption('Your Shopping Basket');
     $checkout_shopping_basket_table->append_tag_to_content($caption);
     // THEAD
     $thead = new HTMLTags_THead();
     $thead_tr = new HTMLTags_TR();
     $name_th = new HTMLTags_TH('Name');
     $price_th = new HTMLTags_TH('Unit Price');
     $quantity_th = new HTMLTags_TH('Amount');
     $sub_total_th = new HTMLTags_TH('Sub-Total');
     $thead_tr->append_tag_to_content($name_th);
     $thead_tr->append_tag_to_content($price_th);
     $thead_tr->append_tag_to_content($quantity_th);
     $thead_tr->append_tag_to_content($sub_total_th);
     $thead->append_tag_to_content($thead_tr);
     $checkout_shopping_basket_table->append_tag_to_content($thead);
     // TFOOT
     $tfoot = new HTMLTags_TFoot();
     $blank_td = new HTMLTags_TD('');
     // TFOOT - sub-total-tr
     $tfoot_sub_total_tr = new HTMLTags_TR();
     $sub_total_price = new Shop_SumOfMoney($shopping_baskets_table->get_sub_total_for_current_session($customer_region), $currency);
     $sub_total_th = new HTMLTags_TH('Sub-Total');
     $sub_total_td = new HTMLTags_TD($sub_total_price->get_as_string());
     $tfoot_sub_total_tr->append_tag_to_content($blank_td);
     $tfoot_sub_total_tr->append_tag_to_content($blank_td);
     $tfoot_sub_total_tr->append_tag_to_content($sub_total_th);
     $tfoot_sub_total_tr->append_tag_to_content($sub_total_td);
     $tfoot->append_tag_to_content($tfoot_sub_total_tr);
     // TFOOT - shipping-tr
     $shipping_price = new Shop_SumOfMoney($shopping_baskets_table->get_shipping_total_for_current_session($customer_region->get_id()), $currency);
     $tfoot_shipping_tr = new HTMLTags_TR();
     $shipping_th = new HTMLTags_TH('Shipping');
     $shipping_td = new HTMLTags_TD($shipping_price->get_as_string());
     $tfoot_shipping_tr->append_tag_to_content($blank_td);
     $tfoot_shipping_tr->append_tag_to_content($blank_td);
     $tfoot_shipping_tr->append_tag_to_content($shipping_th);
     $tfoot_shipping_tr->append_tag_to_content($shipping_td);
     $tfoot->append_tag_to_content($tfoot_shipping_tr);
     // TFOOT - total-tr
     $total_price = new Shop_SumOfMoney($shopping_baskets_table->get_total_for_current_session($customer_region->get_id()), $currency);
     $tfoot_total_tr = new HTMLTags_TR();
     $total_th = new HTMLTags_TH('Total');
     $total_td = new HTMLTags_TD($total_price->get_as_string());
     $tfoot_total_tr->append_tag_to_content($blank_td);
     $tfoot_total_tr->append_tag_to_content($blank_td);
     $tfoot_total_tr->append_tag_to_content($total_th);
     $tfoot_total_tr->append_tag_to_content($total_td);
     $tfoot->append_tag_to_content($tfoot_total_tr);
     $checkout_shopping_basket_table->append_tag_to_content($tfoot);
     // TBODY
     $tbody = new HTMLTags_TBody();
     try {
         $shopping_baskets = $shopping_baskets_table->get_shopping_baskets_for_current_session();
     } catch (Exception $e) {
     }
     if (count($shopping_baskets) > 0) {
         foreach ($shopping_baskets as $shopping_basket) {
             $shopping_basket_renderer = $shopping_basket->get_renderer();
             $shopping_basket_tr = $shopping_basket_renderer->get_checkout_shopping_basket_tr();
             $tbody->append_tag_to_content($shopping_basket_tr);
         }
     }
     $checkout_shopping_basket_table->append_tag_to_content($tbody);
     return $checkout_shopping_basket_table;
 }
 public function get_checkout_shopping_basket_tr()
 {
     $shopping_basket = $this->get_element();
     $product = $shopping_basket->get_product();
     $database = $shopping_basket->get_database();
     $customer_regions_table = $database->get_table('hpi_shop_customer_regions');
     $customer_region = $customer_regions_table->get_row_by_id($_SESSION['customer_region_id']);
     $currency = $customer_region->get_currency();
     $product_currency_price = $product->get_product_currency_price($currency->get_id());
     $full_tr = new HTMLTags_TR();
     $name_and_image_td = $this->get_product_td();
     //                $name_td = new HTMLTags_TD($product->get_name());
     $product_price = new Shop_SumOfMoney($product_currency_price->get_price(), $currency);
     $sub_total_price = new Shop_SumOfMoney($shopping_basket->get_sub_total(), $currency);
     $price_td = new HTMLTags_TD($product_price->get_as_string());
     $quantity_td = new HTMLTags_TD($shopping_basket->get_quantity());
     $sub_total_td = new HTMLTags_TD($sub_total_price->get_as_string());
     $full_tr->append_tag_to_content($name_and_image_td);
     $full_tr->append_tag_to_content($price_td);
     $full_tr->append_tag_to_content($quantity_td);
     $full_tr->append_tag_to_content($sub_total_td);
     return $full_tr;
 }