Exemplo n.º 1
0
 public function populate_order_country_codes()
 {
     $query = "SELECT * FROM [|PREFIX|]orders";
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     while ($order = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         $billId = GetCountryISO2ById($order['ordbillcountryid']);
         $shipId = GetCountryISO2ById($order['ordshipcountryid']);
         $updatedOrder = array("ordbillcountrycode" => $billId, "ordshipcountrycode" => $shipId);
         if (!$GLOBALS['ISC_CLASS_DB']->UpdateQuery("orders", $updatedOrder, "orderid='" . $order['orderid'] . "'")) {
             $this->SetError($GLOBALS['ISC_CLASS_DB']->GetErrorMsg());
             return false;
         }
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  *	Redirect the customer to WorldPay's site to enter their payment details
  */
 public function TransferToProvider()
 {
     $total = $this->GetGatewayAmount();
     $this->_installid = trim($this->GetValue("installid"));
     $this->_currency = $this->GetValue("currency");
     $testmode_on = $this->GetValue("testmode");
     // Load the pending order
     $billingDetails = $this->GetBillingDetails();
     $phone = $billingDetails['ordbillphone'];
     $phone = preg_replace("#[^\\+0-9]+#", "", $phone);
     $country = GetCountryISO2ById($billingDetails['ordbillcountryid']);
     if ($testmode_on == "YES") {
         $this->_testmode = "100";
     } else {
         $this->_testmode = "0";
     }
     $hiddenFields = array('address' => $billingDetails['ordbillstreet1'] . ' ' . $billingDetails['ordbillstreet2'], 'country' => $country, 'postcode' => $billingDetails['ordbillzip'], 'tel' => $phone, 'email' => $billingDetails['ordbillemail'], 'instId' => $this->_installid, 'cartId' => $_COOKIE['SHOP_ORDER_TOKEN'], 'M_customerToken' => $_COOKIE['SHOP_SESSION_TOKEN'], 'currency' => $this->_currency, 'amount' => $total, 'desc' => sprintf(GetLang('YourOrderFromX'), GetConfig('StoreName')), 'testMode' => $this->_testmode);
     $this->RedirectToProvider('https://select.worldpay.com/wcc/purchase', $hiddenFields);
 }
Exemplo n.º 3
0
 /**
  *	Redirect the customer to PayPal's site to enter their payment details
  */
 public function TransferToProvider()
 {
     $total = $this->GetGatewayAmount();
     $this->_email = $this->GetValue("email");
     $testmode_on = $this->GetValue("testmode");
     if ($testmode_on == "YES") {
         $paypal_url = "https://www.sandbox.paypal.com/cgi-bin/webscr";
     } else {
         $paypal_url = "https://www.paypal.com/cgi-bin/webscr";
     }
     $billingDetails = $this->GetBillingDetails();
     $country = GetCountryISO2ById($billingDetails['ordbillcountryid']);
     // If US phone numbers, we need to format them appropriately
     $phone_1 = $phone_2 = $phone_3 = $state = '';
     $phone = $billingDetails['ordbillphone'];
     if ($country == "US") {
         // Numbers only
         $phone = str_replace("+1", "", $phone);
         $phone = preg_replace("#[^0-9]+#", "", $phone);
         if (strlen($phone) == 10) {
             $phone_1 = substr($phone, 0, 3);
             $phone_2 = substr($phone, 3, 3);
             $phone_3 = substr($phone, 6, 4);
         }
         $state = GetStateISO2ById($billingDetails['ordbillstateid']);
     } else {
         $phone = preg_replace("#[^\\+0-9]+#", "", $phone);
         $phone_2 = $phone;
     }
     $orders = $this->GetOrders();
     $orderIds = array();
     foreach ($orders as $order) {
         $orderIds[] = '#' . $order['orderid'];
     }
     $orderIdAppend = '(' . implode(', ', $orderIds) . ')';
     $currency = GetDefaultCurrency();
     $hiddenFields = array('cmd' => '_ext-enter', 'redirect_cmd' => '_xclick', 'business' => $this->_email, 'rm' => 2, 'amount' => number_format($total, 2, '.', ''), 'no_shipping' => 1, 'tax' => 0, 'no_note' => 1, 'currency_code' => $currency['currencycode'], 'item_name' => sprintf(GetLang('YourOrderFromX'), GetConfig('StoreName')) . ' ' . $orderIdAppend, 'custom' => $_COOKIE['SHOP_ORDER_TOKEN'] . '_' . $_COOKIE['SHOP_SESSION_TOKEN'], 'return' => GetConfig('ShopPathSSL') . '/finishorder.php', 'cancel_return' => GetConfig('ShopPathSSL') . '/cart.php', 'notify_url' => GetConfig('ShopPathSSL') . '/checkout.php?action=gateway_ping&provider=' . $this->GetId(), 'first_name' => $billingDetails['ordbillfirstname'], 'last_name' => $billingDetails['ordbilllastname'], 'email' => $billingDetails['ordbillemail'], 'address1' => $billingDetails['ordbillstreet1'], 'address2' => $billingDetails['ordbillstreet2'], 'day_phone_a' => $phone_1, 'day_phone_b' => $phone_2, 'day_phone_c' => $phone_3, 'night_phone_a' => $phone_1, 'night_phone_b' => $phone_2, 'night_phone_c' => $phone_3, 'country' => $country, 'zip' => $billingDetails['ordbillzip'], 'city' => $billingDetails['ordbillsuburb'], 'state' => $state, 'address_override' => 1, 'no_shipping' => 1);
     $this->RedirectToProvider($paypal_url, $hiddenFields);
 }
Exemplo n.º 4
0
	public function __construct($customerId = null)
	{
		// use the same settings as orders by default
		$this->setDoubleOptIn(GetConfig('EmailIntegrationOrderDoubleOptin'));
		$this->setSendWelcome(GetConfig('EmailIntegrationOrderSendWelcome'));

		if (!$customerId) {
			return;
		}

		$entity = new ISC_ENTITY_CUSTOMER();

		$data = $entity->get($customerId);
		if (!$data) {
			throw new Interspire_EmailIntegration_Subscription_Exception();
		}

		unset($data['custpassword']);

		$this->_data = $data;
		unset($data);

		$this->setSubscriptionIP($this->_data['custregipaddress']);

		// customer custom form fields

		/** @var ISC_FORM */
		$form = $GLOBALS["ISC_CLASS_FORM"];

		// populate empty form fields as a starting point -- this makes exports of imported customers work OK because they may not have a custformsessionid, or this ensures that export data is current with configured form fields even if the stored form fields are out of date
		$formFields = $form->getFormFields(FORMFIELDS_FORM_ACCOUNT);
		foreach ($formFields as /** @var ISC_FORMFIELD_BASE */$formField) {
			if ($formField->getFieldPrivateId()) {
				continue;
			}
			$this->_data[$formField->getFieldId()] = '';
		}

		// load saved data for this customer
		if (isId($this->_data['custformsessionid'])) {
			$customFields = $form->getSavedSessionData($this->_data['custformsessionid']);
			foreach ($customFields as $fieldId => $value) {
				$this->_data['FormField_' . $fieldId] = $value;
			}
		}

		// for email integration purposes, money values must be stored in an array as both numeric and formatted to allow for translation to both number fields and text fields, while maintaining currency information
		SetupCurrency();
		$moneyFields = array('custstorecredit');
		foreach ($moneyFields as $moneyFieldId) {
			$this->_data[$moneyFieldId] = array(
				'numeric' => $this->_data[$moneyFieldId],
				'formatted' => FormatPriceInCurrency($this->_data[$moneyFieldId]),
			);
		}

		unset($this->_data['addresses']); // the addresses provided by entity class are mixed billing/shipping addresses, can't be sure so discard them
		// find last used _billing_ address for this customer by non-deleted orders
		$order = $GLOBALS['ISC_CLASS_DB']->FetchRow("SELECT ordformsessionid, ordbillstreet1, ordbillstreet2, ordbillsuburb, ordbillstate, ordbillzip, ordbillcountryid FROM `[|PREFIX|]orders` WHERE ordcustid = " . (int)$customerId . " AND deleted = 0 ORDER BY orddate DESC LIMIT 1");
		if (is_array($order)) {
			// create fields specifically for email integration based on customer data

			if (isId($order['ordformsessionid'])) {
				$customFields = $form->getSavedSessionData($order['ordformsessionid']);
				foreach ($customFields as $fieldId => $value) {
					$this->_data['CustomerSubscription_Address_FormField_' . $fieldId] = $value;
				}
			}

			$this->_data['CustomerSubscription_Address'] = array(
				'addr1' => $order['ordbillstreet1'],
				'addr2' => $order['ordbillstreet2'],
				'city' => $order['ordbillsuburb'],
				'state' => $order['ordbillstate'],
				'zip' => $order['ordbillzip'],
				'country' => GetCountryById($order['ordbillcountryid']),
				'countryiso2' => GetCountryISO2ById($order['ordbillcountryid']),
				'countryiso3' => GetCountryISO3ById($order['ordbillcountryid']),
			);

			$this->_data['CustomerSubscription_Address_address1'] = $this->_data['CustomerSubscription_Address']['addr1'];
			$this->_data['CustomerSubscription_Address_address2'] = $this->_data['CustomerSubscription_Address']['addr2'];
			$this->_data['CustomerSubscription_Address_city'] = $this->_data['CustomerSubscription_Address']['city'];
			$this->_data['CustomerSubscription_Address_state'] = $this->_data['CustomerSubscription_Address']['state'];
			$this->_data['CustomerSubscription_Address_zip'] = $this->_data['CustomerSubscription_Address']['zip'];
			$this->_data['CustomerSubscription_Address_country'] = $this->_data['CustomerSubscription_Address']['country'];
			$this->_data['CustomerSubscription_Address_countryiso2'] = $this->_data['CustomerSubscription_Address']['countryiso2'];
			$this->_data['CustomerSubscription_Address_countryiso3'] = $this->_data['CustomerSubscription_Address']['countryiso3'];
		}

		// transform customer group data if available
		if ($this->_data['customergroup']) {
			$this->_data['customergroupid'] = $this->_data['customergroup']['customergroupid'];
			$this->_data['groupname'] = $this->_data['customergroup']['groupname'];
		}
		else
		{
			$this->_data['customergroupid'] = '';
			$this->_data['groupname'] = '';
		}
		unset($this->_data['customergroup']);
	}
Exemplo n.º 5
0
 /**
  * Get the shipping quote and display it in a form
  */
 public function TestQuoteResult()
 {
     // Add a single test item
     $this->AddItem($_POST['delivery_weight']);
     $this->_deliverytype = $_POST['delivery_type'];
     $this->_origincountry = GetCountryISO2ByName(GetConfig('CompanyCountry'));
     $this->_originzip = GetConfig('CompanyZip');
     $this->_destcountry = GetCountryISO2ById($_POST['delivery_country']);
     $this->_destzip = $_POST['delivery_postcode'];
     $result = '';
     if (in_array($this->_deliverytype, $this->internationalTypes)) {
         if ($this->_origincountry == $this->_destcountry) {
             $this->SetError(GetLang('RoyalMailShipInternationalToLocalError'));
         } else {
             $result = $this->GetQuote();
         }
     } else {
         if ($this->_origincountry == $this->_destcountry) {
             $result = $this->GetQuote();
         } else {
             $this->SetError(GetLang('RoyalMailShipLocalToInternationalError'));
         }
     }
     // Next actually retrieve the quote
     if (!is_object($result) && !is_array($result)) {
         $GLOBALS['Color'] = "red";
         $GLOBALS['Status'] = GetLang('StatusFailed');
         $GLOBALS['Label'] = GetLang('ShipErrorMessage');
         $GLOBALS['Message'] = implode('<br />', $this->GetErrors());
     } else {
         $GLOBALS['Color'] = "green";
         $GLOBALS['Status'] = GetLang('StatusSuccess');
         $GLOBALS['Label'] = GetLang('ShipQuotePrice');
         // Get each available shipping option and display it
         $GLOBALS['Message'] = "";
         if (!is_array($result)) {
             $result = array($result);
         }
         foreach ($result as $quote) {
             if (count($result) > 1) {
                 $GLOBALS['Message'] .= "<li>";
             }
             $GLOBALS['Message'] .= $quote->getdesc(false) . " - " . $quote->getprice() . " GBP";
             if (count($result) > 1) {
                 $GLOBALS['Message'] .= "</li>";
             }
         }
     }
     $GLOBALS['Image'] = $this->_image;
     $this->ParseTemplate("module.royalmail.testresult");
 }
 /**
  * Set the shipping restrictions in the google filter module format for the default zone
  * so we can add it as part of the shipping rules
  *
  * @return void
  **/
 private function AddDefaultShippingRestrictions($zone)
 {
     switch ($zone['locationtype']) {
         case 'zip':
             foreach ($zone['locations'] as $location) {
                 $this->defaultZoneGFilter->AddExcludedPostalArea(GetCountryISO2ById($location['locationcountryid']));
             }
             return false;
             break;
         case 'state':
             foreach ($zone['locations'] as $location) {
                 $country = GetCountryISO2ById($location['locationcountryid']);
                 $state = GetStateISO2ById($location['locationvalueid']);
                 if (empty($state)) {
                     $state = GetStateById($location['locationvalueid']);
                 }
                 if (empty($location['locationvalueid']) && $country == 'US') {
                     // If they have selected all states in the us, handle it differently
                     $this->defaultZoneGFilter->SetExcludedCountryArea('ALL');
                     break 2;
                 } elseif (empty($location['locationvalueid'])) {
                     continue;
                 }
                 if ($country == 'US' && $this->GetDefaultCurrencyCode() == 'USD') {
                     $this->defaultZoneGFilter->AddExcludedStateArea($state);
                 } else {
                     $this->defaultZoneGFilter->AddExcludedPostalArea($country, $state);
                 }
             }
             break;
         case 'country':
             foreach ($zone['locations'] as $location) {
                 $this->defaultZoneGFilter->AddExcludedPostalArea(GetCountryISO2ById($location['locationvalueid']));
             }
             break;
     }
 }
    /**
     *	Redirect the customer to LinkPointConnect's site to enter their payment details
     */
    public function TransferToProvider()
    {
        $pendingdata = $_SESSION['CHECKOUT']['PENDING_DATA'];
        $itemcost = $this->GetSubTotal();
        $shippingcost = $this->GetShippingCost() + $this->GetHandlingCost();
        $taxcost = $this->GetTaxCost();
        $total = $this->GetGatewayAmount();
        $this->_storenumber = $this->GetValue("storenumber");
        $transactiontype = $this->GetValue("transactiontype");
        $testmode_on = $this->GetValue("testmode");
        $gatewayprovider = $this->GetValue("gatewayprovider");
        if ($testmode_on == "YES") {
            if ($gatewayprovider == 'lp') {
                $linkpointconnect_url = "https://staging.linkpt.net/lpc/servlet/lppay";
            } else {
                $linkpointconnect_url = "https://www.staging.yourpay.com/lpcentral/servlet/lppay";
            }
        } else {
            if ($gatewayprovider == 'lp') {
                $linkpointconnect_url = "https://www.linkpointcentral.com/lpc/servlet/lppay";
            } else {
                $linkpointconnect_url = "https://secure.linkpt.net/lpcentral/servlet/lppay";
            }
        }
        // Load the pending order
        $order = LoadPendingOrderByToken($_COOKIE['SHOP_ORDER_TOKEN']);
        $bcountry = GetCountryISO2ById($order['ordbillcountryid']);
        $scountry = GetCountryISO2ById($order['ordshipcountryid']);
        // Fetch the customer details
        $query = sprintf("SELECT * FROM [|PREFIX|]customers WHERE customerid='%s'", $GLOBALS['ISC_CLASS_DB']->Quote($order['ordcustid']));
        $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
        $customer = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
        $phone = $customer['custconphone'];
        $phone = preg_replace("#[^\\+0-9]+#", "", $phone);
        //if it's us, we need to have find the us state code
        if ($bcountry == "US") {
            $bstate = GetStateISO2ById($order['ordbillstateid']);
            $bstate_name = 'bstate';
        } else {
            $bstate = $order['ordbillstate'];
            $bstate_name = 'bstate2';
        }
        if ($scountry == "US") {
            $sstate = GetStateISO2ById($order['ordshipstateid']);
            $sstate_name = 'sstate';
        } else {
            $sstate = $order['ordshipstate'];
            $sstate_name = 'sstate2';
        }
        ?>
				<html>
					<head>
						<title><?php 
        echo GetLang('RedirectingToLinkPointConnect');
        ?>
</title>
					</head>

					<body onload="document.forms[0].submit()">
						<a href="javascript:void(0)" onclick="document.forms[0].submit()" style="color:gray; font-size:12px"><?php 
        echo GetLang('ClickIfNotRedirected');
        ?>
</a>
						<form name="linkpointconnect" id="linkpointconnect" action="<?php 
        echo $linkpointconnect_url;
        ?>
" method="post">
							<input type="hidden" name="mode" value="fullpay">
							<input type="hidden" name="chargetotal" value="<?php 
        echo $total;
        ?>
">
							<input type="hidden" name="tax" value="<?php 
        echo $taxcost;
        ?>
">
							<input type="hidden" name="shipping" value="<?php 
        echo $shippingcost;
        ?>
">
							<input type="hidden" name="subtotal" value="<?php 
        echo $itemcost;
        ?>
">



							<input type="hidden" name="storename" value="<?php 
        echo $this->_storenumber;
        ?>
">
							<input type="hidden" name="txntype" value="<?php 
        echo $transactiontype;
        ?>
">

							<input type="hidden" name="bname" value="<?php 
        echo isc_html_escape($order['ordbillfirstname'] . ' ' . $order['ordbilllastname']);
        ?>
" />
							<input type="hidden" name="email" value="<?php 
        echo isc_html_escape($customer['custconemail']);
        ?>
" />
							<input type="hidden" name="phone" value="<?php 
        echo $phone;
        ?>
" />


							<input type="hidden" name="baddr1" value="<?php 
        echo isc_html_escape($order['ordbillstreet1']);
        ?>
" />
							<input type="hidden" name="baddr2" value="<?php 
        echo isc_html_escape($order['ordbillstreet2']);
        ?>
" />
							<input type="hidden" name="bcountry" value="<?php 
        echo isc_html_escape($bcountry);
        ?>
" />
							<input type="hidden" name="bzip" value="<?php 
        echo isc_html_escape($order['ordbillzip']);
        ?>
" />
							<input type="hidden" name="bcity" value="<?php 
        echo isc_html_escape($order['ordbillsuburb']);
        ?>
" />
							<input type="hidden" name="<?php 
        echo isc_html_escape($bstate_name);
        ?>
" value="<?php 
        echo isc_html_escape($bstate);
        ?>
" />


							<input type="hidden" name="sname" value="<?php 
        echo isc_html_escape($order['ordshipfirstname'] . ' ' . $order['ordshiplastname']);
        ?>
" />
							<input type="hidden" name="saddr1" value="<?php 
        echo isc_html_escape($order['ordshipstreet1']);
        ?>
" />
							<input type="hidden" name="saddr2" value="<?php 
        echo isc_html_escape($order['ordshipstreet2']);
        ?>
" />
							<input type="hidden" name="scountry" value="<?php 
        echo isc_html_escape($scountry);
        ?>
" />
							<input type="hidden" name="szip" value="<?php 
        echo isc_html_escape($order['ordshipzip']);
        ?>
" />
							<input type="hidden" name="scity" value="<?php 
        echo isc_html_escape($order['ordshipsuburb']);
        ?>
" />
							<input type="hidden" name="<?php 
        echo isc_html_escape($sstate_name);
        ?>
" value="<?php 
        echo isc_html_escape($sstate);
        ?>
" />


						</form>
					</body>
				</html>
			<?php 
        exit;
    }
Exemplo n.º 8
0
		/**
		* Get the shipping quote and display it in a form
		*/
		public function TestQuoteResult()
		{

			// Add a single test item - dimensions needed for Intershipper
			$this->additem($_POST['delivery_weight'], $_POST['delivery_length'], $_POST['delivery_width'], $_POST['delivery_height'], 1, "Item #1");

			$this->_username = $this->GetValue("username");
			$this->_password = $this->GetValue("password");
			$this->_shipclasses = $this->GetValue("shipclasses");
			$this->_destinationtype = $this->GetValue("destinationtype");
			$this->_shippingmethod = $this->GetValue("shippingmethod");
			$this->_packingmethod = $this->GetValue("packingmethod");
			$this->_packagingtype = $this->GetValue("packagingtype");
			$this->_sort = $this->GetValue("sort");
			$this->_carriers = $_POST['delivery_carriers'];
			$this->_destzip = $_POST['delivery_zip'];
			$this->_destcountry = GetCountryISO2ById($_POST['delivery_country']);

			$result = $this->GetQuote();

			if(!is_object($result) && !is_array($result)) {
				$GLOBALS['Color'] = "red";
				$GLOBALS['Status'] = GetLang('StatusFailed');
				$GLOBALS['Label'] = GetLang('ShipErrorMessage');
				$GLOBALS['Message'] = implode('<br />', $this->GetErrors());
			}
			else {
				$GLOBALS['Color'] = "green";
				$GLOBALS['Status'] = GetLang('StatusSuccess');
				$GLOBALS['Label'] = GetLang('ShipQuotePrice');

				// Get each available shipping option and display it
				$GLOBALS['Message'] = "";

				if(!is_array($result)) {
					$result = array($result);
				}

				foreach($result as $quote) {
					if(count($result) > 1) {
						$GLOBALS['Message'] .= "<li>";
					}

					if($quote->gettransit() != -1) {
						if($quote->gettransit() == 0) {
							// Same day
							$transit = ", today";
						}
						else {
							$transit = ", " . $quote->gettransit() . " day(s)";
						}
					}
					else {
						$transit = "";
					}

					$GLOBALS['Message'] .= $quote->getdesc(false) . " - $" . number_format($quote->getprice(), GetConfig('DecimalPlaces')) . " USD" . $transit;

					if(count($result) > 1) {
						$GLOBALS['Message'] .= "</li>";
					}
				}
			}

			$GLOBALS['Image'] = $this->_image;
			$this->ParseTemplate("module.intershipper.testresult");
		}
Exemplo n.º 9
0
 /**
  * Get the shipping quote and display it in a form
  */
 public function TestQuoteResult()
 {
     // Add a single test item - no dimensions needed for FedEx
     $this->additem($_POST['delivery_weight']);
     // Setup all of the shipping variables
     $this->_deliverytype = $_POST['delivery_type'];
     $this->_origincountry = GetCountryISO2ByName(GetConfig('CompanyCountry'));
     $this->_originzip = GetConfig('CompanyZip');
     $this->_destcountry = GetCountryISO2ById($_POST['delivery_country']);
     $this->_deststate = GetStateISO2ById($_POST['delivery_state']);
     $this->_destzip = $_POST['delivery_zip'];
     $this->_service = $_POST['service_type'];
     $this->_carriercode = $_POST['delivery_type'];
     $this->_dropofftype = $this->GetValue("dropofftype");
     $this->_accountno = $this->GetValue("accountno");
     $this->_meterno = $this->GetValue("meterno");
     $this->_packagingtype = $this->GetValue("packagingtype");
     $this->_ratetype = $this->GetValue("ratetype");
     // Next actually retrieve the quote
     $result = $this->GetQuote();
     if (!is_object($result) && !is_array($result)) {
         $GLOBALS['Color'] = "red";
         $GLOBALS['Status'] = GetLang('StatusFailed');
         $GLOBALS['Label'] = GetLang('ShipErrorMessage');
         $GLOBALS['Message'] = implode('<br />', $this->GetErrors());
     } else {
         $GLOBALS['Color'] = "green";
         $GLOBALS['Status'] = GetLang('StatusSuccess');
         $GLOBALS['Label'] = GetLang('ShipQuotePrice');
         // Get each available shipping option and display it
         $GLOBALS['Message'] = "";
         if (!is_array($result)) {
             $result = array($result);
         }
         foreach ($result as $quote) {
             if (count($result) > 1) {
                 $GLOBALS['Message'] .= "<li>";
             }
             $GLOBALS['Message'] .= $quote->getdesc(false) . " - \$" . $quote->getprice() . " USD";
             if (count($result) > 1) {
                 $GLOBALS['Message'] .= "</li>";
             }
         }
     }
     $GLOBALS['Image'] = $this->_image;
     $this->ParseTemplate("module.fedex.testresult");
 }
Exemplo n.º 10
0
 /**
  * Get the shipping quote and display it in a form
  */
 public function TestQuoteResult()
 {
     // Add a single test item - no dimensions needed for UPS
     $this->AddItem($_POST['delivery_weight'], $_POST['delivery_length'], $_POST['delivery_width'], $_POST['delivery_height']);
     $this->_deliverytype = $_POST['delivery_type'];
     $this->_origincountry = GetCountryISO2ByName(GetConfig('CompanyCountry'));
     $this->_originzip = GetConfig('CompanyZip');
     $this->_destcountry = GetCountryISO2ById($_POST['delivery_country']);
     $this->_destzip = $_POST['delivery_postcode'];
     // Next actually retrieve the quote
     $result = $this->GetQuote();
     if (!is_object($result) && !is_array($result)) {
         $GLOBALS['Color'] = "red";
         $GLOBALS['Status'] = GetLang('StatusFailed');
         $GLOBALS['Label'] = GetLang('ShipErrorMessage');
         $GLOBALS['Message'] = implode('<br />', $this->GetErrors());
     } else {
         $GLOBALS['Color'] = "green";
         $GLOBALS['Status'] = GetLang('StatusSuccess');
         $GLOBALS['Label'] = GetLang('ShipQuotePrice');
         // Get each available shipping option and display it
         $GLOBALS['Message'] = "";
         if (!is_array($result)) {
             $result = array($result);
         }
         foreach ($result as $quote) {
             if (count($result) > 1) {
                 $GLOBALS['Message'] .= "<li>";
             }
             $GLOBALS['Message'] .= $quote->getdesc(false) . " - \$" . $quote->getprice() . " AUD, " . $quote->gettransit() . " day(s)";
             if (count($result) > 1) {
                 $GLOBALS['Message'] .= "</li>";
             }
         }
     }
     $GLOBALS['Image'] = $this->_image;
     $this->ParseTemplate("module.auspost.testresult");
 }
Exemplo n.º 11
0
 /**
  * ProcessPaymentForm
  * Process and validate input from a payment form for this particular
  * gateway.
  *
  * @return boolean True if valid details and payment has been processed. False if not.
  */
 public function ProcessPaymentForm()
 {
     $billfirstname = "";
     $billlastname = "";
     $error = false;
     $requiredFields = array("PayflowPro_name" => GetLang('PayflowProEnterName'), "PayflowPro_ccno" => GetLang('PayflowProEnterCardNumber'), "PayflowPro_ccaddress" => GetLang('PayflowProEnterBillingAddress'), "PayflowPro_ccexpm" => GetLang('PayflowProEnterCreditCardMonth'), "PayflowPro_ccexpy" => GetLang('PayflowProEnterCreditCardYear'), "PayflowPro_zip" => GetLang('PayflowProEnterPostcode'), "PayflowPro_cccity" => GetLang('PayflowProEnterCity'), "PayflowPro_ccstate" => GetLang('PayflowProEnterState'), "PayflowPro_country" => GetLang('PayflowProEnterCountry'));
     $requireCVV2 = $this->GetValue("PayflowProEnterCVV2Number");
     if ($requireCVV2 == "YES") {
         $requiredFields['PayflowPro_cccode'] = GetLang('PayflowProCreditCardCCV2');
     }
     foreach ($requiredFields as $field => $message) {
         if (!isset($_POST[$field]) || trim($_POST[$field]) == '') {
             $this->SetError($message);
             return false;
         }
     }
     $currentMY = isc_mktime(0, 0, 0, isc_date('m') + 1, 0, isc_date('y'));
     $cardMY = isc_mktime(0, 0, 0, $_POST['PayflowPro_ccexpm'] + 1, 0, $_POST['PayflowPro_ccexpy']);
     if ($currentMY > $cardMY) {
         $this->SetError(GetLang('PayflowProCreditCardExpired') . isc_date('m/y', $currentMY) . " - " . isc_date('m/y', $cardMY));
         return false;
     }
     if (isset($_COOKIE['SHOP_ORDER_TOKEN'])) {
         $ccname = $_POST['PayflowPro_name'];
         $ccnum = $_POST['PayflowPro_ccno'];
         $ccaddress = $_POST['PayflowPro_ccaddress'];
         $cccity = $_POST['PayflowPro_cccity'];
         $ccstate = $_POST['PayflowPro_ccstate'];
         $ccexpm = $_POST['PayflowPro_ccexpm'];
         $ccexpy = $_POST['PayflowPro_ccexpy'];
         $ccexp = sprintf("%s%s", $ccexpm, $ccexpy);
         $cczip = $_POST['PayflowPro_zip'];
         $cccode = $_POST['PayflowPro_cccode'];
         $cccountry = $_POST['PayflowPro_country'];
         $query = "Select currencycode from [|PREFIX|]currencies Where currencyid = '" . $GLOBALS['ISC_CLASS_DB']->Quote(GetConfig('DefaultCurrencyID')) . "'";
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         $currency = $GLOBALS['ISC_CLASS_DB']->FetchOne($result);
         // Split the billing name up into firstname and last name
         $billdetails = explode(" ", $ccname);
         for ($i = 0; $i < count($billdetails) - 1; $i++) {
             $billfirstname .= $billdetails[$i] . " ";
         }
         $billfirstname = trim($billfirstname);
         $billlastname = $billdetails[count($billdetails) - 1];
         $orders = $this->GetOrders();
         $orderIds = '#' . implode(', #', array_keys($orders));
         // Load the paypal vendor ID
         $vendorid = $this->GetValue('vendorid');
         // Load the paypal partner ID
         $partnerid = $this->GetValue('partnerid');
         // Load the paypal partner ID
         $userid = $this->GetValue('userid');
         // Load the paypal password
         $password = $this->GetValue('password');
         // Is payflow setup in test or live mode?
         $testmode = $this->GetValue('testmode');
         // Load the paypal transaction Type
         $transactionType = $this->GetValue('transactiontype');
         if ($testmode == 'YES') {
             $payflowprourl = 'https://pilot-payflowpro.paypal.com';
         } else {
             $payflowprourl = 'https://payflowpro.paypal.com';
         }
         $custip = GetIP();
         $orderdesc = sprintf(GetLang('YourOrderFrom'), $GLOBALS['StoreName']);
         // Fetch the customer details
         $query = sprintf("SELECT * FROM [|PREFIX|]customers WHERE customerid='" . $GLOBALS['ISC_CLASS_DB']->Quote($this->GetCustomerId()) . "'");
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         $customer = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
         // Arrange the data into name/value pairs ready to send
         $pp_values = array('USER' => $userid, 'VENDOR' => $vendorid, 'PARTNER' => $partnerid, 'PWD' => $password, 'TENDER' => 'C', 'TRXTYPE' => $transactionType, 'ACCT' => $ccnum, 'CVV2' => $cccode, 'EXPDATE' => $ccexp, 'AMT' => number_format($this->GetGatewayAmount(), 2), 'CURRENCY' => $currency, 'FIRSTNAME' => $billfirstname, 'LASTNAME' => $billlastname, 'STREET' => $ccaddress, 'CITY' => $cccity, 'STATE' => $ccstate, 'ZIP' => $cczip, 'COUNTRY' => GetCountryISO2ById($cccountry), 'EMAIL' => $customer['custconemail'], 'CUSTIP' => $custip, 'INVNUM' => $orderIds, 'ORDERDESC' => $orderdesc, 'VERBOSITY' => 'MEDIUM');
         $paypal_query = '';
         foreach ($pp_values as $key => $value) {
             if ($key == 'USER') {
                 $paypal_query .= $key . '[' . strlen($value) . ']=' . $value;
             } else {
                 $paypal_query .= '&' . $key . '[' . strlen($value) . ']=' . $value;
             }
         }
         $nvpArray = $this->SendData($orderIds, $payflowprourl, $paypal_query);
         $_SESSION['PayflowResponse'] = $nvpArray;
         ob_end_clean();
         $token = md5(GetConfig('EncryptionToken') . $_COOKIE['SHOP_ORDER_TOKEN']);
         header(sprintf("Location:%s/finishorder.php?o=%s", $GLOBALS['ShopPathSSL'], $token));
     } else {
         // Invalid payflow response
         $this->SetError(GetLang('PayflowProInvalidOrder'));
         return false;
     }
 }
Exemplo n.º 12
0
	/**
	 * To save the defined eBay listing template
	 *
	 * @param string $error Referenced variable to store an error message in if saving is unsuccessfull
	 * @param int $templateId The optional template to update instead. If 0 a new template is created.
	 * @return mixed Returns the template Id if saved successfully, FALSE otherwise
	 */
	public function SaveEbayTemplate(&$error, $templateId = 0)
	{
		// site we're listing on
		$siteId = (int)$_POST['siteId'];

		// set up basic template variables
		$templateName = $_POST['templateName'];
		$templateIsDefault = isset($_POST['templateAsDefault']);
		$privateListing = isset($_POST['privateListing']);

		// set up category variables
		$categoryOptions = $_POST['primaryCategoryOptions'];
		$secondaryCategoryOptions = array();
		$primaryCategoryId = $categoryOptions['category_id'];
		$secondaryCategoryId = 0;
		$secondaryCategoryName = '';
		$primaryStoreCategoryId = 0;
		$primaryStoreCategoryName = '';
		$secondaryStoreCategoryId = 0;
		$secondaryStoreCategoryName = '';

		if (!empty($_POST['secondaryCategoryOptions'])) {
			$secondaryCategoryId = $_POST['secondaryCategoryOptions']['category_id'];
			$secondaryCategoryName = $_POST['secondaryCategoryOptions']['name'];
			$secondaryCategoryOptions = $_POST['secondaryCategoryOptions'];
		}

		if (!empty($_POST['primaryStoreCategoryOptions'])) {
			$primaryStoreCategoryId = $_POST['primaryStoreCategoryOptions']['category_id'];
			$primaryStoreCategoryName = $_POST['primaryStoreCategoryOptions']['name'];
		}

		if (!empty($_POST['secondaryStoreCategoryOptions'])) {
			$secondaryStoreCategoryId = $_POST['secondaryStoreCategoryOptions']['category_id'];
			$secondaryStoreCategoryName = $_POST['secondaryStoreCategoryOptions']['name'];
		}

		// item details
		$quantityToSell = 1;
		if ($_POST['quantityType'] == 'more') {
			$quantityToSell = (int)$_POST['quantityMore'];
		}
		if ($quantityToSell < 1) {
			$quantityToSell = 1;
		}

		$useItemPhoto = isset($_POST['useItemPhoto']);

		$lotSize = 0;
		if (isset($_POST['lotSize'])) {
			$lotSize = (int)$_POST['lotSize'];
		}
		if ($lotSize < 0) {
			$lotSize = 0;
		}

		$useProductImage = isset($_POST['useItemPhoto']);

		// item location
		$locationCountry = (int)$_POST['locationCountry'];
		$locationCountryCode = GetCountryISO2ById($locationCountry);

		$locationZip = $_POST['locationZip'];
		$locationCityState = $_POST['locationCityState'];

		$prices = array();

		// selling method
		$sellingMethod = $_POST['sellingMethod'];

		// Online Auction
		if ($sellingMethod == 'Chinese') {
			// reserve price
			$useReservePrice = isset($_POST['useReservePrice']);
			if ($useReservePrice) {
				$reservePriceOption = $_POST['reservePriceOption'];

				$price = array(
					'price_type'	=> self::RESERVE_PRICE_TYPE,
					'selected_type' => $reservePriceOption
				);

				if ($reservePriceOption == 'PriceExtra') {
					$price['calculate_operator'] = $_POST['reservePricePlusOperator'];
					$price['calculate_option'] = $_POST['reservePricePlusType'];
					if ($price['calculate_option'] == 'amount') {
						$price['calculate_price'] = DefaultPriceFormat($_POST['reservePricePlusValue']);
					}
					else {
						$price['calculate_price'] = (double)$_POST['reservePricePlusValue'];
					}
				}
				elseif ($reservePriceOption == 'CustomPrice') {
					$price['price'] = DefaultPriceFormat($_POST['reservePriceCustomValue']);
				}

				$prices[] = $price;
			}

			// start price
			$startPriceOption = $_POST['startPriceOption'];

			$price = array(
				'price_type'	=> self::STARTING_PRICE_TYPE,
				'selected_type' => $startPriceOption
			);

			if ($startPriceOption == 'PriceExtra') {
				$price['calculate_operator'] = $_POST['startPricePlusOperator'];
				$price['calculate_option'] = $_POST['startPricePlusType'];
				if ($price['calculate_option'] == 'amount') {
					$price['calculate_price'] = DefaultPriceFormat($_POST['startPricePlusValue']);
				}
				else {
					$price['calculate_price'] = (double)$_POST['startPricePlusValue'];
				}
			}
			elseif ($startPriceOption == 'CustomPrice') {
				$price['price'] = DefaultPriceFormat($_POST['startPriceCustomValue']);
			}

			$prices[] = $price;

			// buy it now
			if (isset($_POST['useBuyItNowPrice'])) {
				$buyItNowPriceOption = $_POST['buyItNowPriceOption'];

				$price = array(
					'price_type'	=> self::BUY_PRICE_TYPE,
					'selected_type' => $buyItNowPriceOption
				);

				if ($buyItNowPriceOption == 'PriceExtra') {
					$price['calculate_operator'] = $_POST['buyItNowPricePlusOperator'];
					$price['calculate_option'] = $_POST['buyItNowPricePlusType'];
					if ($price['calculate_option'] == 'amount') {
						$price['calculate_price'] = DefaultPriceFormat($_POST['buyItNowPricePlusValue']);
					}
					else {
						$price['calculate_price'] = (double)$_POST['buyItNowPricePlusValue'];
					}
				}
				elseif ($buyItNowPriceOption == 'CustomPrice') {
					$price['price'] = DefaultPriceFormat($_POST['buyItNowPriceCustomValue']);
				}

				$prices[] = $price;
			}

			// auction duration
			$listingDuration = $_POST['auctionDuration'];
		}
		// Fixed item listing
		else {
			$fixedBuyItNowPriceOption = $_POST['fixedBuyItNowPriceOption'];

			$price = array(
				'price_type'	=> self::STARTING_PRICE_TYPE,
				'selected_type' => $fixedBuyItNowPriceOption
			);

			if ($fixedBuyItNowPriceOption == 'PriceExtra') {
				$price['calculate_operator'] = $_POST['fixedBuyItNowPricePlusOperator'];
				$price['calculate_option'] = $_POST['fixedBuyItNowPricePlusType'];
				if ($price['calculate_option'] == 'amount') {
					$price['calculate_price'] = DefaultPriceFormat($_POST['fixedBuyItNowPricePlusValue']);
				}
				else {
					$price['calculate_price'] = (double)$_POST['fixedBuyItNowPricePlusValue'];
				}
			}
			elseif ($fixedBuyItNowPriceOption == 'CustomPrice') {
				$price['price'] = DefaultPriceFormat($_POST['fixedBuyItNowPriceCustomValue']);
			}

			$prices[] = $price;

			// auction duration
			$listingDuration = $_POST['fixedDuration'];
		}


		// payment options
		$paymentMethods = array();
		if (isset($_POST['paymentMethods'])) {
			foreach ($_POST['paymentMethods'] as $paymentMethod) {
				$paymentMethods[] = $paymentMethod;
			}
		}
		// manually add paypal in if required since it wont be posted (disabled form field)
		if ($categoryOptions['paypal_required']) {
			$paymentMethods[] = 'PayPal';
		}

		$paypalEmail = $_POST['paypalEmailAddress'];

		// shipping options
		$useInternationalShipping = isset($_POST['yesInternationalShipping']);
		$useDomesticShipping = false;
		if ($_POST['domesticShipping'] == 'specify') {
			$useDomesticShipping = true;
		}

		$shippingAreas = array(
			'domestic'		=> $useDomesticShipping,
			'international'	=> $useInternationalShipping
		);

		$dispatchTimeMax = 0;
		if (isset($_POST['handlingTime'])) {
			$dispatchTimeMax = (int)$_POST['handlingTime'];
		}

		// sales tax
		$useSalesTax = false;
		if (!empty ($_POST['salesTax']) && $_POST['salesTax'] == '1') {
			$useSalesTax = (bool)$_POST['salesTax'];
		}
		$salesTaxState = '';
		$salesTaxPercentage = 0;
		$salesTaxIncludesShippingCost = false;

		if ($useSalesTax) {
			$salesTaxState = $_POST['salesTaxState'];
			$salesTaxPercentage = DefaultPriceFormat($_POST['salesTaxPercentage'], false);
			$salesTaxIncludesShippingCost = isset($_POST['salesTaxIncludeShippingCost']);
		}


		// other options
		$checkoutInstructions = $_POST['checkoutInstructions'];

		// returns
		$acceptReturns = isset($_POST['acceptReturns']);
		$returnOfferAs =  '';
		if (isset($_POST['refundOption'])) {
			$returnOfferAs= $_POST['refundOption'];
		}
		$returnsPeriod = '';
		if (isset($_POST['returnsWithin'])) {
			$returnsPeriod = $_POST['returnsWithin'];
		}
		$returnCostPaidBy = '';
		if (isset($_POST['returnCostPaidBy'])) {
			$returnCostPaidBy = $_POST['returnCostPaidBy'];
		}
		$additionalPolicyInfo = '';
		if (isset($_POST['additionalPolicyInfo'])) {
			$additionalPolicyInfo = $_POST['additionalPolicyInfo'];
		}

		// upgrade options
		$counterStyle = $_POST['hitCounter'];

		$galleryOption = $_POST['galleryOption'];
		$galleryDuration = '';
		if ($galleryOption == 'Featured') {
			$galleryDuration = $_POST['galleryDuration'];
		}

		$listingFeatures = array();
		if (isset($_POST['listingFeature'])) {
			$listingFeatures = $_POST['listingFeature'];
		}

		$acceptBestOffer = false; // where did this option go?

		// our template data to insert
		$newTemplate = array(
			'name'					=> $templateName,
			'enabled'				=> 1,
			'user_id'				=> $this->auth->GetUserId(),
			'site_id'				=> $siteId,
			'is_default'			=> $templateIsDefault,
			'is_private'			=> $privateListing,

			'quantities'			=> $quantityToSell,
			'use_prod_image'		=> $useItemPhoto,
			'lot_size'				=> $lotSize,

			'listing_type'			=> $sellingMethod,
			'listing_duration'		=> $listingDuration,

			'primary_category_options' 	=> serialize($categoryOptions),
			'secondary_category_options' 	=> serialize($secondaryCategoryOptions),
			'primary_category_id'		=> $primaryCategoryId,
			'secondary_category_id'		=> $secondaryCategoryId,
			'secondary_category_name'	=> $secondaryCategoryName,
			'store_category1_id'		=> $primaryStoreCategoryId,
			'store_category1_name'		=> $primaryStoreCategoryName,
			'store_category2_id'		=> $secondaryStoreCategoryId,
			'store_category2_name'		=> $secondaryStoreCategoryName,

			'accept_best_offer'		=> $acceptBestOffer,

			'payment_method'		=> serialize($paymentMethods),
			'paypal_email'			=> $paypalEmail,
			'payment_instruction'	=> $checkoutInstructions,

			'item_country'			=> $locationCountryCode,
			'item_zip'				=> $locationZip,
			'item_city'				=> $locationCityState,

			'accept_return'			=> $acceptReturns,
			'return_offer_as'		=> $returnOfferAs,
			'return_period'			=> $returnsPeriod,
			'return_cost_by'		=> $returnCostPaidBy,
			'return_policy_description' 	=> $additionalPolicyInfo,

			'use_domestic_shipping'			=> $useDomesticShipping,
			'use_international_shipping'	=> $useInternationalShipping,
			'handling_time'			=> $dispatchTimeMax,

			'use_salestax'			=> $useSalesTax,
			'sales_tax_states'		=> $salesTaxState,
			'salestax_percent'		=> $salesTaxPercentage,
			'salestax_inc_shipping'	=> $salesTaxIncludesShippingCost,

			'counter_style'			=> $counterStyle,
			'gallery_opt'			=> $galleryOption,
			'featured_gallery_duration' => $galleryDuration,
			'listing_opt'			=> serialize($listingFeatures),

			'date_added'			=> time()
		);

		if (!$this->db->StartTransaction()) {
			$error = $this->db->Error();
			return false;
		}

		if ($templateId) {
			if (!$this->db->UpdateQuery('ebay_listing_template', $newTemplate, 'id = ' . $templateId)) {
				$this->db->RollbackTransaction();
				$error = $this->db->Error();
				return false;
			}

			// delete old prices and shipping settings
			$this->db->DeleteQuery('ebay_listing_prices', 'WHERE ebay_listing_template_id = ' . $templateId);
			$query = 'DELETE es.*, ess.* FROM [|PREFIX|]ebay_shipping es, [|PREFIX|]ebay_shipping_serv ess WHERE ess.ebay_shipping_id = es.id AND es.ebay_listing_template_id = ' . $templateId;
			$this->db->Query($query);
		}
		else {
			// create new template
			$templateId = $this->db->InsertQuery('ebay_listing_template', $newTemplate);
		}

		if (!$templateId) {
			$this->db->RollbackTransaction();
			$error = $this->db->Error();
			return false;
		}

		// add the prices
		foreach ($prices as $price) {
			$price['ebay_listing_template_id'] = $templateId;

			if (!$this->db->InsertQuery('ebay_listing_prices', $price)) {
				$this->db->RollbackTransaction();
				$error = $this->db->Error();
				return false;
			}
		}

		// Saving Shipping Details
		foreach ($shippingAreas as $shippingArea => $enable) {
			// Skip if the shipping area isn't enabled
			if (!$enable) {
				continue;
			}

			// Skip the Freight shipping as there is nothing to be saved
			$shippingType = $_POST[$shippingArea . 'ShippingType'];
			$offerPickup = 0;

			$getItFast = 0;
			if (isset($_POST[$shippingArea . 'YesGetItFast'])) {
				$getItFast = 1;
			}

			$freeShipping = 0;

			$handlingCost = 0;
			if (isset($_POST[$shippingArea . 'HandlingCost'])) {
				$handlingCost = DefaultPriceFormat($_POST[$shippingArea . 'HandlingCost']);
			}

			$shippingPackage = '';
			$services = array();

			switch ($shippingType) {
				case 'Flat':
					// local pickup only available for domestic
					if (!empty($_POST[$shippingArea . 'LocalPickup'])) {
						$offerPickup = 1;
					}
					if (!empty($_POST[$shippingArea . 'YesFreeFlatShipping'])) {
						$freeShipping = 1;
					}


					foreach ($_POST[$shippingArea . 'ShippingServFlat'] as $index => $shippingService) {
						if (!$shippingService['Type']) {
							continue;
						}

						$shipToLocations = array();
						if (!empty($shippingService['ShipTo'])) {
							// only support once service currently, but store as array for future use
							$shipToLocations = array($shippingService['ShipTo']);
						}

						if ($freeShipping && $index == 0) {
							$cost = 0;
							$additionalCost = 0;
						}
						else {
							$cost = DefaultPriceFormat($shippingService['Cost']);
							$additionalCost = DefaultPriceFormat($shippingService['MoreCost']);
						}

						$services[] = array (
							'ebay_shipping_id' => 0,
							'name' => $shippingService['Type'],
							'cost' => $cost,
							'additional_cost' => $additionalCost,
							'ship_to_locations' => serialize($shipToLocations),
						);
					}
					break;
				case 'Calculated':
					$shippingPackage = $_POST[$shippingArea . 'ShippingPackage'];

					if (!empty($_POST[$shippingArea . 'YesFreeCalculatedShipping'])) {
						$freeShipping = 1;
					}

					foreach ($_POST[$shippingArea . 'ShippingServCalculated'] as $shippingService) {
						if (!$shippingService['Type']) {
							continue;
						}

						$shipToLocations = array();
						if (!empty($shippingService['ShipTo'])) {
							// only support once service currently, but store as array for future use
							$shipToLocations = array($shippingService['ShipTo']);
						}

						$services[] = array (
							'ebay_shipping_id' => 0,
							'name' => $shippingService['Type'],
							'cost' => 0,
							'additional_cost' => 0,
							'ship_to_locations' => serialize($shipToLocations),
						);
					}
					break;
			}

			// Save the shipping data
			$shippingData = array(
				'ebay_listing_template_id' 	=> $templateId,
				'area' 						=> $shippingArea,
				'cost_type' 				=> $shippingType,
				'offer_pickup' 				=> $offerPickup,
				'is_free_shipping' 			=> $freeShipping,
				'handling_cost' 			=> $handlingCost,
				'package_type' 				=> $shippingPackage,
				'get_it_fast' 				=> $getItFast,
			);
			$eBayShippingId = $this->db->InsertQuery("ebay_shipping", $shippingData);
			if (!$eBayShippingId) {
				$this->db->RollbackTransaction();
				$error = $this->db->Error();
				return false;
			}

			// Save Shipping Services to the database
			foreach ($services as $serviceData) {
				$serviceData['ebay_shipping_id'] = (int)$eBayShippingId;
				if(!$this->db->InsertQuery("ebay_shipping_serv", $serviceData)) {
					$this->db->RollbackTransaction();
					$error = $this->db->Error();
					return false;
				}
			}
		}

		$this->db->CommitTransaction();

		FlashMessage(GetLang('EbayTemplateSavedSuccessfully'), MSG_SUCCESS, '', 'EbayListingTemplate');

		return $templateId;
	}
Exemplo n.º 13
0
	/**
	* Get the shipping quote and display it in a form
	*/
	public function TestQuoteResult()
	{

		// Add a single test item - no dimensions needed for FedEx
		$this->additem($_POST['delivery_weight']);

		// Setup all of the shipping variables
		$this->_destcountry = GetCountryISO2ById($_POST['delivery_country']);
		$this->_deststate = GetStateISO2ById($_POST['delivery_state']);
		$this->_destzip = $_POST['delivery_zip'];
		$this->_service = $_POST['service_type'];

		// Fedex doesn't allow non US/CA/MX intra-country service (eg. AU to AU), raise an error
		if (!in_array($this->_origin_country['country_iso'], $this->_intracountrycountries) && $this->_origin_country['country_iso'] == $this->_destcountry) {
			$this->SetError(GetLang('FedExIntraCountryError'));
			$result = false;
		}
		else {
			// Next actually retrieve the quote
			$result = $this->GetQuote();
		}

		if(!is_object($result) && !is_array($result)) {
			$GLOBALS['Color'] = "red";
			$GLOBALS['Status'] = GetLang('StatusFailed');
			$GLOBALS['Label'] = GetLang('ShipErrorMessage');
			$GLOBALS['Message'] = implode('<br />', $this->GetErrors());
		}
		else {
			$GLOBALS['Color'] = "green";
			$GLOBALS['Status'] = GetLang('StatusSuccess');
			$GLOBALS['Label'] = GetLang('ShipQuotePrice');

			// Get each available shipping option and display it
			$GLOBALS['Message'] = "";

			if(!is_array($result)) {
				$result = array($result);
			}

			foreach($result as $quote) {
				if(count($result) > 1) {
					$GLOBALS['Message'] .= "<li>";
				}

				$GLOBALS['Message'] .= $quote->getdesc(false) . " - $" . $quote->getprice() . " USD";

				if(count($result) > 1) {
					$GLOBALS['Message'] .= "</li>";
				}
			}
		}

		$GLOBALS['Image'] = $this->_image;
		$this->ParseTemplate("module.fedex.testresult");
	}
Exemplo n.º 14
0
		/**
		* Get the shipping quote and display it in a form
		*/
		public function TestQuoteResult()
		{

			// Add a single test item - no dimensions needed for UPS
			$this->additem($_POST['delivery_weight']);

			// Setup all of the shipping variables
			$this->_deliverytype = $_POST['delivery_type'];
			$this->_destcountry = GetCountryISO2ById($_POST['delivery_country']);
			$this->_destzip = $_POST['delivery_zip'];
			$this->_shippingrate = $this->GetValue("shippingrate");
			$this->_packagingtype = $this->GetValue("packagingtype");
			if($_POST['delivery_destination'] == 'COM') {
				$this->_destination = "0";
			} else {
				$this->_destination = "1";
			}
			// Convert the weight to pounds
			$this->_weight = ConvertWeight($this->_weight, 'pounds');


			$result = $this->GetQuote();

			if(!is_object($result) && !is_array($result)) {
				$GLOBALS['Color'] = "red";
				$GLOBALS['Status'] = GetLang('StatusFailed');
				$GLOBALS['Label'] = GetLang('ShipErrorMessage');
				$GLOBALS['Message'] = implode('<br />', $this->GetErrors());
			}
			else {
				$GLOBALS['Color'] = "green";
				$GLOBALS['Status'] = GetLang('StatusSuccess');
				$GLOBALS['Label'] = GetLang('ShipQuotePrice');

				// Get each available shipping option and display it
				$GLOBALS['Message'] = "";

				if(!is_array($result)) {
					$result = array($result);
				}

				foreach($result as $quote) {
					if(count($result) > 1) {
						$GLOBALS['Message'] .= "<li>";
					}

					$GLOBALS['Message'] .= $quote->getdesc(false) . " - $" . number_format($quote->getprice(), GetConfig('DecimalPlaces')) . " USD";

					if(count($result) > 1) {
						$GLOBALS['Message'] .= "</li>";
					}
				}
			}

			$GLOBALS['Image'] = $this->_image;
			$this->ParseTemplate("module.ups.testresult");
		}
Exemplo n.º 15
0
		/**
		*	Redirect the customer to LinkPointConnect's site to enter their payment details
		*/
		public function TransferToProvider()
		{
			// deduct tax and shipping from gateway amount instead of $this->GetSubTotal as that function doesn't factor in any discounts,
			// which results in a gateway error if subtotal + shipping + tax != charge (gateway) amount
			$subtotal = $this->GetGatewayAmount() - $this->GetTaxCost() - $this->GetShippingCost() - $this->GetHandlingCost();
			$subtotal = number_format($subtotal, 2, '.', '');

			$shippingcost = number_format($this->GetShippingCost() + $this->GetHandlingCost(), 2, '.', '');
			$taxcost = number_format($this->GetTaxCost(), 2, '.', '');

			$total = number_format($this->GetGatewayAmount(), 2, '.', '');

			$this->_storenumber = $this->GetValue("storenumber");
			$transactiontype = $this->GetValue("transactiontype");
			$testmode_on = $this->GetValue("testmode");

			if($testmode_on == "YES") {
				$linkpointconnect_url = "https://www.staging.linkpointcentral.com/lpc/servlet/lppay";
			} else {
				$linkpointconnect_url = "https://www.linkpointcentral.com/lpc/servlet/lppay";
			}

			// Load the pending order
			$order = LoadPendingOrderByToken($_COOKIE['SHOP_ORDER_TOKEN']);

			$shippingAddress = $this->getShippingAddress();

			$bcountry = GetCountryISO2ById($order['ordbillcountryid']);
			$scountry = $shippingAddress['country_iso2'];

			$phone = $order['ordbillphone'];
			$phone = preg_replace("#[^\+0-9]+#", "", $phone);

			//if it's us, we need to have find the us state code
			if($bcountry == "US") {
				$bstate = GetStateISO2ById($order['ordbillstateid']);
				$bstate_name='bstate';
			} else {
				$bstate = $order['ordbillstate'];
				$bstate_name='bstate2';
			}

			$billstate = 'name="' . $bstate_name . '" value="' . isc_html_escape($bstate) . '"';

			if($scountry == "US") {
				$sstate = GetStateISO2ById($shippingAddress['state_id']);
				$sstate_name='sstate';
			} else {
				$sstate = $shippingAddress['state'];
				$sstate_name='sstate2';
			}

			$shipstate = 'name="' . $sstate_name . '" value="' . isc_html_escape($sstate) . '"';

			?>
				<html>
					<head>
						<title><?php echo GetLang('RedirectingToLinkPointConnect'); ?></title>
					</head>

					<body onload="document.forms[0].submit()">
						<a href="javascript:void(0)" onclick="document.forms[0].submit()" style="color:gray; font-size:12px"><?php echo GetLang('ClickIfNotRedirected'); ?></a>
						<form name="linkpointconnect" id="linkpointconnect" action="<?php echo $linkpointconnect_url; ?>" method="post">
							<input type="hidden" name="mode" value="fullpay">
							<input type="hidden" name="chargetotal" value="<?php echo $total;?>">
							<input type="hidden" name="tax" value="<?php echo $taxcost;?>">
							<input type="hidden" name="shipping" value="<?php echo $shippingcost;?>">
							<input type="hidden" name="subtotal" value="<?php echo $subtotal;?>">



							<input type="hidden" name="storename" value="<?php echo $this->_storenumber;?>">
							<input type="hidden" name="txntype" value="<?php echo $transactiontype;?>">

							<input type="hidden" name="bname" value="<?php echo isc_html_escape($order['ordbillfirstname'].' '.$order['ordbilllastname']); ?>" />
							<input type="hidden" name="email" value="<?php echo isc_html_escape($order['ordbillemail']); ?>" />
							<input type="hidden" name="phone" value="<?php echo $phone; ?>" />


							<input type="hidden" name="baddr1" value="<?php echo isc_html_escape($order['ordbillstreet1']); ?>" />
							<input type="hidden" name="baddr2" value="<?php echo isc_html_escape($order['ordbillstreet2']); ?>" />
							<input type="hidden" name="bcountry" value="<?php echo isc_html_escape($bcountry); ?>" />
							<input type="hidden" name="bzip" value="<?php echo isc_html_escape($order['ordbillzip']); ?>" />
							<input type="hidden" name="bcity" value="<?php echo isc_html_escape($order['ordbillsuburb']); ?>" />
							<input type="hidden" <?php echo $billstate; ?> />


							<input type="hidden" name="sname" value="<?php echo isc_html_escape($shippingAddress['first_name'].' '.$shippingAddress['last_name']); ?>" />
							<input type="hidden" name="saddr1" value="<?php echo isc_html_escape($shippingAddress['address_1']); ?>" />
							<input type="hidden" name="saddr2" value="<?php echo isc_html_escape($shippingAddress['address_2']); ?>" />
							<input type="hidden" name="scountry" value="<?php echo isc_html_escape($scountry); ?>" />
							<input type="hidden" name="szip" value="<?php echo isc_html_escape($shippingAddress['zip']); ?>" />
							<input type="hidden" name="scity" value="<?php echo isc_html_escape($oshippingAddressrder['city']); ?>" />
							<input type="hidden" <?php echo $shipstate; ?> />


						</form>
					</body>
				</html>
			<?php
			exit;
		}