Ejemplo n.º 1
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);
 }
 /**
  * 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.
  */
 protected function _ConstructPostData($postData, $orders)
 {
     $ccname = $postData['name'];
     $ccTypeName = $postData['cctype'];
     $ccnum = $postData['ccno'];
     $ccexpm = str_pad($postData['ccexpm'], 2, '0', STR_PAD_LEFT);
     $ccexpy = $postData['ccexpy'];
     $ccexp = sprintf("%s%s", $ccexpm, $ccexpy);
     $cccvd = $postData['cccvd'];
     $ccissuenumber = $postData['ccissueno'];
     $ccissuem = $postData['ccissuedatem'];
     $ccissuey = substr($postData['ccissuedatey'], 2, 4);
     $ccissuedate = sprintf("%s%s", $ccissuem, $ccissuey);
     $cardTypes = array('visa' => '0', 'mc' => '1', 'other' => '8', 'switch' => '9', 'solo' => 'S');
     $cctype = $cardTypes[strtolower($ccTypeName)];
     $currency = GetCurrencyCodeByID(GetConfig('DefaultCurrencyID'));
     $merchant = $this->GetMerchantSettings();
     $custip = $this->GetIpAddress();
     $order = current($orders);
     $orderIds = '#' . implode(', #', array_keys($orders));
     $orderdesc = sprintf(GetLang('YourOrderFrom'), $GLOBALS['StoreName']) . ' (' . $orderIds . ')';
     $orderTax = 0;
     if ($order['ordtotalincludestax'] == 0) {
         $orderTax = number_format($this->GetTaxCost(), 2);
     }
     // Fetch the customer details
     $query = sprintf("SELECT custconemail FROM [|PREFIX|]customers WHERE customerid='" . $GLOBALS['ISC_CLASS_DB']->Quote($this->GetCustomerId()) . "'");
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     $customeremail = $GLOBALS['ISC_CLASS_DB']->FetchOne($result);
     // Grab the billing details for the order
     $billingDetails = $this->GetBillingDetails();
     //get bill state in ISO code
     if ($billingDetails['ordbillstateid'] != 0 && GetStateISO2ById($billingDetails['ordbillstateid'])) {
         $billstate = GetStateISO2ById($billingDetails['ordbillstateid']);
     } else {
         $billstate = isc_html_escape($billingDetails['ordbillstate']);
     }
     //if it's a digital order use billing address as shipping address
     if (isset($order['ordisdigital']) && $order['ordisdigital'] == 1) {
         $shippingDetails = array('ordshipstreet1' => $billingDetails['ordbillstreet1'], 'ordshipstreet2' => $billingDetails['ordbillstreet2'], 'ordshipsuburb' => $billingDetails['ordbillsuburb'], 'ordshipzip' => $billingDetails['ordbillzip'], 'ordshipcountrycode' => $billingDetails['ordbillcountrycode']);
         $shipstate = $billstate;
     } else {
         $shippingDetails = $this->GetShippingAddresses();
         $shippingDetails = $shippingDetails[$order['orderid']];
         //get ship state in ISO code
         if ($shippingDetails['ordshipstateid'] != 0 && GetStateISO2ById($shippingDetails['ordshipstateid'])) {
             $shipstate = GetStateISO2ById($shippingDetails['ordshipstateid']);
         } else {
             $shipstate = isc_html_escape($shippingDetails['ordshipstate']);
         }
     }
     // Arrange the data into name/value pairs ready to send
     $pp_values = array('USER' => $merchant['userid'], 'PWD' => $merchant['password'], 'VENDOR' => $merchant['vendorid'], 'PARTNER' => $merchant['partnerid'], 'TENDER' => 'C', 'TRXTYPE' => $merchant['transactionType'], 'NOTIFYURL' => $GLOBALS['ShopPath'] . '/finishorder.php', 'CLIENTIP' => $custip, 'EMAIL' => $customeremail, 'CUSTREF' => $this->GetCustomerId(), 'FIRSTNAME' => $billingDetails['ordbillfirstname'], 'LASTNAME' => $billingDetails['ordbilllastname'], 'STREET' => $billingDetails['ordbillstreet1'] . " " . $billingDetails['ordbillstreet2'], 'CITY' => $billingDetails['ordbillsuburb'], 'STATE' => $billstate, 'ZIP' => $billingDetails['ordbillzip'], 'COUNTRY' => $billingDetails['ordbillcountrycode'], 'SHIPTOSTREET' => $shippingDetails['ordshipstreet1'] . " " . $shippingDetails['ordshipstreet2'], 'SHIPTOCITY' => $shippingDetails['ordshipsuburb'], 'SHIPTOSTATE' => $shipstate, 'SHIPTOZIP' => $shippingDetails['ordshipzip'], 'SHIPTOCOUNTRY' => $shippingDetails['ordshipcountrycode'], 'ACCTTYPE' => $cctype, 'ACCT' => $ccnum, 'CVV2' => $cccvd, 'AMT' => number_format($order['ordgatewayamount'], 2), 'CURRENCY' => $currency, 'CARDISSUE' => $ccissuenumber, 'CARDSTART' => $ccissuedate, 'EXPDATE' => $ccexp, 'ITEMAMT' => number_format($this->GetSubTotal(), 2), 'FREIGHTAMT' => number_format($this->GetShippingCost(), 2), 'HANDLINGAMT' => number_format($this->GetHandlingCost(), 2), 'TAXAMT' => $orderTax, 'INVNUM' => $orderIds, 'MERCHANTSESSIONID' => $_COOKIE['SHOP_ORDER_TOKEN']);
     /*build name value pair string*/
     $paypal_query = '';
     foreach ($pp_values as $key => $value) {
         if ($key == 'USER') {
             $paypal_query .= $key . '[' . strlen($value) . ']=' . $value;
         } else {
             $paypal_query .= '&' . $key . '[' . strlen($value) . ']=' . $value;
         }
     }
     $paypal_query = rtrim($paypal_query, '&');
     return $paypal_query;
 }
Ejemplo n.º 3
0
		protected function _ConstructPostData($postData)
		{
			$transactionid = $this->GetCombinedOrderId();

			$ccname		= $postData['name'];
			$cctype		= $postData['cctype'];
			$ccissueno	= $postData['ccissueno'];
			$ccissuedatem	= $postData['ccissuedatem'];
			$ccissuedatey	= $postData['ccissuedatey'];
			$ccnum		= $postData['ccno'];
			$ccexpm		= $postData['ccexpm'];
			$ccexpy		= $postData['ccexpy'];
			$cccvd		= $postData['cccvd'];

			$bAddress = $this->GetBillingDetails();
			$billState = isc_html_escape($bAddress['ordbillstate']);
			if($bAddress['ordbillstateid'] != 0 && GetStateISO2ById($bAddress['ordbillstateid'])) {
				$billState = GetStateISO2ById($bAddress['ordbillstateid']);
			}
			$billStreet2 = '';
			if (isset($bAddress['ordbillstreet2'])) {
				$billStreet2 = $bAddress['ordbillstreet2'];
			}

			$sAddress = $this->getShippingAddress();
			$shipState = isc_html_escape($sAddress['state']);
			if($sAddress['state_id'] != 0 && GetStateISO2ById($sAddress['state_id'])) {
				$shipState = GetStateISO2ById($sAddress['state_id']);
			}
			$shipStreet2 = '';
			if (isset($sAddress['address_2'])) {
				$shipStreet2 = $sAddress['address_2'];
			}

			$query = "SELECT custconemail
				FROM [|PREFIX|]customers
				WHERE customerid='".$GLOBALS['ISC_CLASS_DB']->Quote($this->GetCustomerId())."'";
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
			$email = $GLOBALS['ISC_CLASS_DB']->FetchOne($result);

			$xml  = '<Order>';
			$xml .= '<StoreID>'.$this->GetValue('storeid').'</StoreID>';
			$xml .= '<Passphrase>'.$this->GetValue('passphrase').'</Passphrase>';
			$xml .= '<Subtotal>'.$this->GetGatewayAmount().'</Subtotal>';
			$xml .= '<PaymentType>CC</PaymentType>';
			$xml .= '<CardAction>'.$this->GetValue('transactiontype').'</CardAction>';
			$xml .= '<CardNumber>'.htmlentities($ccnum).'</CardNumber>';
			$xml .= '<CardExpMonth>'.htmlentities($ccexpm).'</CardExpMonth>';
			$xml .= '<CardExpYear>'.htmlentities($ccexpy).'</CardExpYear>';
			$xml .= '<CardIDNumber>'.htmlentities($cccvd).'</CardIDNumber>';
			$xml .= '<OrderID>'.$GLOBALS['StoreName'].' ISC'.microtime(1).' '.$transactionid.'</OrderID>';

			// ISC-1094: added billing and shipping details
			$xml .= '<Email>'.$email.'</Email>';
			$xml .= '<CustomerIP>'.$this->GetIpAddress().'</CustomerIP>';

			$xml .= '<Bname>'.$bAddress['ordbillfirstname'].' '.$bAddress['ordbilllastname'].'</Bname>';
			$xml .= '<Baddress1>'.$bAddress['ordbillstreet1'].'</Baddress1>';
			$xml .= '<Baddress2>'.$billStreet2.'</Baddress2>';
			$xml .= '<Bcity>'.$bAddress['ordbillsuburb'].'</Bcity>';
			$xml .= '<Bprovince>'.$billState.'</Bprovince>';
			$xml .= '<Bpostalcode>'.$bAddress['ordbillzip'].'</Bpostalcode>';
			$xml .= '<Bcountry>'.$bAddress['ordbillcountrycode'].'</Bcountry>';

			$xml .= '<Sname>'.$sAddress['first_name'].' '.$sAddress['last_name'].'</Sname>';
			$xml .= '<Saddress1>'.$sAddress['address_1'].'</Saddress1>';
			$xml .= '<Saddress2>'.$shipStreet2.'</Saddress2>';
			$xml .= '<Scity>'.$sAddress['city'].'</Scity>';
			$xml .= '<Sprovince>'. $shipState.'</Sprovince>';
			$xml .= '<Spostalcode>'.$sAddress['zip'].'</Spostalcode>';
			$xml .= '<Scountry>'.$sAddress['country_iso2'].'</Scountry>';
			$xml .= '</Order>';

			return $xml;
		}
Ejemplo n.º 4
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");
 }
Ejemplo n.º 5
0
 /**
  * ShowPaymentForm
  * Show a payment form for this particular gateway if there is one.
  * This is useful for gateways that require things like credit card details
  * to be submitted and then processed on the site.
  */
 public function ShowPaymentForm()
 {
     $GLOBALS['PayflowProMonths'] = "";
     $GLOBALS['PayflowProYears'] = "";
     for ($i = 1; $i <= 12; $i++) {
         $stamp = mktime(0, 0, 0, $i, 15, isc_date("Y"));
         $i = str_pad($i, 2, "0", STR_PAD_LEFT);
         if (@$_POST['PayflowPro_ccexpm'] == $i) {
             $sel = "SELECTED";
         } else {
             $sel = "";
         }
         $GLOBALS['PayflowProMonths'] .= sprintf("<option %s value='%s'>%s</option>", $sel, $i, isc_date("M", $stamp));
     }
     for ($i = isc_date("Y"); $i < isc_date("Y") + 10; $i++) {
         if (@$_POST['PayflowPro_ccexpy'] == substr($i, 2, 2)) {
             $sel = 'selected="selected"';
         } else {
             $sel = "";
         }
         $GLOBALS['PayflowProYears'] .= sprintf("<option %s value='%s'>%s</option>", $sel, substr($i, 2, 2), $i);
     }
     $requireCVV2 = $this->GetValue("requirecvv2");
     if ($requireCVV2 == "YES") {
         if (isset($_POST['PayflowPro_cccode'])) {
             $GLOBALS['PayflowProCCV2'] = (int) $_POST['PayflowPro_cccode'];
         }
         $GLOBALS['PayflowProHideCVV2'] = '';
     } else {
         $GLOBALS['PayflowProHideCVV2'] = 'none';
     }
     // Grab the billing details for the order
     $billingDetails = $this->GetBillingDetails();
     $GLOBALS['PayflowProName'] = isc_html_escape($billingDetails['ordbillfirstname'] . ' ' . $billingDetails['ordbilllastname']);
     $GLOBALS['PayflowProBillingAddress'] = isc_html_escape($billingDetails['ordbillstreet1']);
     if ($billingDetails['ordbillstreet2'] != "") {
         $GLOBALS['PayflowProBillingAddress'] .= " " . isc_html_escape($billingDetails['ordbillstreet2']);
     }
     $GLOBALS['PayflowProCity'] = isc_html_escape($billingDetails['ordbillsuburb']);
     if ($billingDetails['ordbillstateid'] != 0 && GetStateISO2ById($billingDetails['ordbillstateid'])) {
         $GLOBALS['PayflowProState'] = GetStateISO2ById($billingDetails['ordbillstateid']);
     } else {
         $GLOBALS['PayflowProState'] = isc_html_escape($billingDetails['ordbillstate']);
     }
     $GLOBALS['PayflowProCountry'] = GetCountryList($billingDetails['ordbillcountry'], false);
     $GLOBALS['PayflowProBillingZip'] = $billingDetails['ordbillzip'];
     // Format the amount that's going to be going through the gateway
     $GLOBALS['OrderAmount'] = FormatPrice($this->GetGatewayAmount());
     // Was there an error validating the payment? If so, pre-fill the form fields with the already-submitted values
     if ($this->HasErrors()) {
         $GLOBALS['PayflowProName'] = isc_html_escape($_POST['PayflowPro_name']);
         $GLOBALS['PayflowProNum'] = isc_html_escape($_POST['PayflowPro_ccno']);
         $GLOBALS['PayflowProBillingAddress'] = isc_html_escape($_POST['PayflowPro_ccaddress']);
         $GLOBALS['PayflowProCity'] = isc_html_escape($_POST['PayflowPro_cccity']);
         $GLOBALS['PayflowProState'] = isc_html_escape($_POST['PayflowPro_ccstate']);
         $GLOBALS['PayflowProBillingZip'] = isc_html_escape($_POST['PayflowPro_zip']);
         $GLOBALS['PayflowProErrorMessage'] = implode("<br />", $this->GetErrors());
         $GLOBALS['PayflowProCountry'] = GetCountryList(isc_html_escape($_POST['PayflowPro_country']), false);
     } else {
         // Hide the error message box
         $GLOBALS['HidePayflowProError'] = "none";
     }
     // Collect their details to send through to Payflow Pro
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("payflowpro");
     return $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true);
 }
Ejemplo n.º 6
0
		/**
		* Sends the order details to Paypal to process
		*
		*/
		public function DoExpressCheckoutPayment()
		{
			if(isset($_COOKIE['SHOP_ORDER_TOKEN'])) {

				$orders = $this->GetOrders();
				reset($orders);
				$order = current($orders);
				$orderId = '#'.implode(', #', array_keys($orders));

				$merchant = $this->GetMerchantSettings();

				if($merchant['testmode'] == 'YES') {
					$transactionURL = $this->_testTransactionURL;
					$transactionURI = $this->_testTransactionURI;
				}
				else {
					$transactionURL = $this->_liveTransactionURL;
					$transactionURI = $this->_liveTransactionURI;
				}

				$response = $_SESSION['CHECKOUT']['PayPalExpressCheckout'];

				// unset PayPalExpress response in session
				unset($_SESSION['CHECKOUT']['PayPalExpressCheckout']);

				$shippingAddress = $this->getShippingAddress();
				if($shippingAddress['state_id'] != 0 && GetStateISO2ById($shippingAddress['state_id'])) {
					$shipstate = GetStateISO2ById($shippingAddress['state_id']);
				}
				else {
					$shipstate = isc_html_escape($shippingAddress['state']);
				}

				$currency = GetCurrencyCodeByID(GetConfig('DefaultCurrencyID'));
				$pp_array = array(
					'METHOD'	=> 'DoExpressCheckoutPayment',
					'USER'		=> $merchant['username'],
					'PWD'		=> $merchant['password'],
					'SIGNATURE'	=> $merchant['signature'],
					'VERSION'	=> '53.0',
					'TOKEN'		=> $response['TOKEN'],
					'PAYERID'	=> $response['PAYERID'],
					'PAYMENTACTION'	=> $merchant['transactionType'],
					'AMT'		=> number_format($order['total_inc_tax'], 2, '.', ''),
					'CURRENCYCODE'	=> $currency,
					'IPADDRESS'	=> $this->GetIpAddress(),
					'INVNUM'	=> $orderId,
					'NAME'		=> $shippingAddress['first_name']." ".$shippingAddress['last_name'],
					'SHIPTOSTREET'	=> $shippingAddress['address_1'],
					'SHIPTOSTREET2'	=> $shippingAddress['address_2'],
					'SHIPTOCITY'	=> $shippingAddress['city'],
					'SHIPTOSTATE'	=> $shipstate,
					'SHIPTOZIP'	=> $shippingAddress['zip'],
					'SHIPTOCOUNTRY'	=> $shippingAddress['country_iso2'],
					'PHONENUM'	=> $shippingAddress['phone'],
					'BUTTONSOURCE'	=> "ISC_ShoppingCart_EC",
					'CUSTOM'	=> $_COOKIE['SHOP_ORDER_TOKEN'] . '_' . $_COOKIE['SHOP_SESSION_TOKEN'],
					'NOTIFYURL'	=> $GLOBALS['ShopPath'].'/checkout.php?action=gateway_ping&provider='.$this->GetId(),
					'L_NAME0'	=> getLang('YourOrderFromX', array('storeName' => getConfig('StoreName'))),
					'L_AMT0'	=> number_format($order['total_inc_tax'],2,'.',''),
					'L_QTY0'	=> 1,
				);

				$paypal_query = '';
				foreach ($pp_array as $key => $value) {
					$paypal_query .= $key.'='.urlencode($value)."&";
				}
				$paypal_query = rtrim($paypal_query, '&');

				$result = $this->_ConnectToProvider($transactionURL, $transactionURI, $paypal_query);
				$nvpArray = $this->_DecodePaypalResult($result);
				$_SESSION['PayPalExpressResponse'] = $nvpArray;

				// verify payment right here to prevent man-in-the-middle attack
				$_REQUEST['o'] = md5(GetConfig('EncryptionToken').$_COOKIE['SHOP_ORDER_TOKEN']);
				$GLOBALS['ISC_CLASS_ORDER'] = GetClass('ISC_ORDER');
				$GLOBALS['ISC_CLASS_ORDER']->HandlePage();
			}
			else {
				// Invalid PayPalExpress response
				$this->SetError(GetLang('PayPalExpressInvalidOrder'));
				return false;
			}
		}
Ejemplo n.º 7
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;
		}
Ejemplo n.º 8
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.
		*/
		protected function _ConstructPostData($postData, $additionalFields=array())
		{
			//if the postdata is got from session then the ccno is encrypted, we need to decrypt it
			if(isset($_SESSION['CHECKOUT']['CardDetails']['ccno']) && $_SESSION['CHECKOUT']['CardDetails']['ccno'] == $postData['ccno']) {
				$ccnum = $this->_CCDecrypt($postData['ccno']);
			} else {
				$ccnum = $postData['ccno'];
			}
			$this->_cardtype = Store_CreditCard::getCardType($ccnum);
			$ccname = $postData['name'];
			$ccTypeName = $postData['cctype'];
			$ccexpm = $postData['ccexpm'];
			$ccexpy = $postData['ccexpy'];
			$ccexp = $ccexpm . $ccexpy;
			$cccvd = $postData['cccvd'];
			$ccissuenumber = $postData['ccissueno'];

			$ccissuem = $postData['ccissuedatem'];
			$ccissuey = $postData['ccissuedatey'];
			$ccissuedate = $ccissuem . $ccissuey;

			$cardTypes = array(
				'VISA'		=> '0',
				'MC'		=> '1',
				'DISCOVER'	=> '2',
				'AMEX'		=> '3',
				'DINERS'	=> '4',
				'JCB'		=> '5',
				'SWITCH'	=> '9',
				'SOLO'		=> 'S',
			);

			$cctype = $cardTypes[$ccTypeName];
			$currency = GetCurrencyCodeByID(GetConfig('DefaultCurrencyID'));

			$merchant = $this->GetMerchantSettings();
			$orders = $this->GetOrders();
			if(empty($orders)) {
				$orderData = LoadPendingOrdersByToken($_COOKIE['SHOP_ORDER_TOKEN']);
				$this->SetOrderData($orderData);
				$orders = $this->GetOrders();
			}
			$custip = $this->GetIpAddress();

			$order = current($orders);
			$orderIds = '#'.implode(', #', array_keys($orders));
			$orderdesc = sprintf(GetLang('YourOrderFrom'), $GLOBALS['StoreName']).' ('.$orderIds.')';


			$orderTax = 0;
			if(getConfig('taxDefaultTaxDisplayOrders') != TAX_PRICES_DISPLAY_INCLUSIVE) {
				$orderTax = number_format($this->GetTaxCost(), 2);
			}

			// Grab the billing details for the order
			$billingDetails = $this->GetBillingDetails();
			$customeremail = $billingDetails['ordbillemail'];

			//get bill state in ISO code
			if($billingDetails['ordbillstateid'] != 0 && GetStateISO2ById($billingDetails['ordbillstateid'])) {
				$billstate = GetStateISO2ById($billingDetails['ordbillstateid']);
			}
			else {
				$billstate = isc_html_escape($billingDetails['ordbillstate']);
			}

			// Get the shipping details
			$shippingAddress = $this->getShippingAddress();

			//get ship state in ISO code
			if($shippingAddress['state_id'] != 0 && GetStateISO2ById($shippingAddress['state_id'])) {
				$shipstate = GetStateISO2ById($shippingAddress['state_id']);
			}
			else {
				$shipstate = isc_html_escape($shippingAddress['state']);
			}

			$amount = $this->GetGatewayAmount();

			// Arrange the data into name/value pairs ready to send
			$pp_values = array (
				'USER'				=> $merchant['userid'],
				'PWD'				=> $merchant['password'],
				'VENDOR'			=> $merchant['vendorid'],
				'PARTNER'			=> $merchant['partnerid'],
				'TENDER'			=> 'C',		//Credit card for Direct Payment transactions
				'TRXTYPE'			=> $merchant['transactionType'],

				/*customer details*/
				'CLIENTIP'			=> $custip,
				'EMAIL'				=> $customeremail,
				'CUSTREF'			=> $this->GetCustomerId(),
				'FIRSTNAME'			=> $billingDetails['ordbillfirstname'],
				'LASTNAME'			=> $billingDetails['ordbilllastname'],
				'STREET'			=> $billingDetails['ordbillstreet1']." ".$billingDetails['ordbillstreet2'],
				'CITY'				=> $billingDetails['ordbillsuburb'],
				'STATE'				=> $billstate,
				'ZIP'				=> $billingDetails['ordbillzip'],
				'COUNTRY'			=> $billingDetails['ordbillcountrycode'],

				/*shipping details*/
				'SHIPTONAME'		=> $shippingAddress['first_name']." ".$shippingAddress['last_name'],
				'SHIPTOSTREET'		=> $shippingAddress['address_1'],
				'SHIPTOSTREET2'		=> $shippingAddress['address_2'],
				'SHIPTOCITY'		=> $shippingAddress['city'],
				'SHIPTOSTATE'		=> $shipstate,
				'SHIPTOZIP'			=> $shippingAddress['zip'],
				'SHIPTOCOUNTRYCODE'	=> $shippingAddress['country_iso2'],
				'SHIPTOPHONENUM'	=> $shippingAddress['phone'],

				/*payment details*/
				'ACCTTYPE'			=> $cctype,
				'ACCT'				=> $ccnum,
				'CVV2'				=> $cccvd,
				'AMT'				=> number_format($amount,2,'.',''),
				'CURRENCY'			=> $currency,
				'CARDISSUE'			=> $ccissuenumber, //Issue number of Switch or Solo card.
				'CARDSTART'			=> $ccissuedate, //Date that Switch or Solo card was issued in mmyy format.
				'EXPDATE'			=> $ccexp,

				/*order details*/
				'INVNUM'			=> $orderIds,
				'MERCHANTSESSIONID'	=> $_COOKIE['SHOP_ORDER_TOKEN'],
				'BUTTONSOURCE'		=> 'ISC_ShoppingCart_DP',
				'NOTIFYURL'			=> $GLOBALS['ShopPath'].'/checkout.php?action=gateway_ping&provider='.$this->GetId(),
				'CUSTOM'			=> $_COOKIE['SHOP_ORDER_TOKEN'] . '_' . $_COOKIE['SHOP_SESSION_TOKEN'],

			);

			if (!empty($additionalFields)) {
				$pp_values = array_merge($pp_values, $additionalFields);
			}

			/*build name value pair string*/
			$paypal_query = '';
			foreach ($pp_values as $key => $value) {
				if($key=='USER') {
					$paypal_query .= $key.'['.strlen($value).']='.$value;
				} else {
					$paypal_query .= '&'.$key.'['.strlen($value).']='.$value;
				}
			}

			$paypal_query = rtrim($paypal_query, '&');
			return $paypal_query;
		}
Ejemplo 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->_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");
	}
Ejemplo n.º 10
0
 /**
  * Sends the order details to Paypal to process
  *
  */
 public function DoExpressCheckoutPayment()
 {
     if (isset($_COOKIE['SHOP_ORDER_TOKEN'])) {
         $orders = $this->GetOrders();
         reset($orders);
         $order = current($orders);
         $orderId = '#' . implode(', #', array_keys($orders));
         $merchant = $this->GetMerchantSettings();
         if ($merchant['testmode'] == 'YES') {
             $transactionURL = $this->_testTransactionURL;
             $transactionURI = $this->_testTransactionURI;
         } else {
             $transactionURL = $this->_liveTransactionURL;
             $transactionURI = $this->_liveTransactionURI;
         }
         $response = $_SESSION['CHECKOUT']['PayPalExpressCheckout'];
         // unset PayPalExpress response in session
         unset($_SESSION['CHECKOUT']['PayPalExpressCheckout']);
         if ($order['ordisdigital']) {
             $addressDetails = $this->GetBillingDetails();
             $shippingDetails = array('firstname' => $addressDetails['ordbillfirstname'], 'lastname' => $addressDetails['ordbilllastname'], 'street1' => $addressDetails['ordbillstreet1'], 'street2' => $addressDetails['ordbillstreet2'], 'city' => $addressDetails['ordbillsuburb'], 'state' => $addressDetails['ordbillstate'], 'zip' => $addressDetails['ordbillzip'], 'countrycode' => $addressDetails['ordbillcountrycode'], 'phone' => $addressDetails['ordbillphone'], 'stateid' => $addressDetails['ordbillstateid']);
         } else {
             $addressDetails = $this->GetShippingAddresses();
             $addressDetails = $addressDetails[$order['orderid']];
             $shippingDetails = array('firstname' => $addressDetails['ordshipfirstname'], 'lastname' => $addressDetails['ordshiplastname'], 'street1' => $addressDetails['ordshipstreet1'], 'street2' => $addressDetails['ordshipstreet2'], 'city' => $addressDetails['ordshipsuburb'], 'state' => $addressDetails['ordshipstate'], 'zip' => $addressDetails['ordshipzip'], 'countrycode' => $addressDetails['ordshipcountrycode'], 'phone' => $addressDetails['ordshipphone'], 'stateid' => $addressDetails['ordshipstateid']);
         }
         if ($shippingDetails['stateid'] != 0 && GetStateISO2ById($shippingDetails['stateid'])) {
             $shipstate = GetStateISO2ById($shippingDetails['stateid']);
         } else {
             $shipstate = isc_html_escape($shippingDetails['state']);
         }
         $currency = GetCurrencyCodeByID(GetConfig('DefaultCurrencyID'));
         $pp_array = array('METHOD' => 'DoExpressCheckoutPayment', 'USER' => $merchant['username'], 'PWD' => $merchant['password'], 'SIGNATURE' => $merchant['signature'], 'VERSION' => '52.0', 'TOKEN' => $response['TOKEN'], 'PAYERID' => $response['PAYERID'], 'PAYMENTACTION' => $merchant['transactionType'], 'AMT' => number_format($order['ordgatewayamount'], 2, '.', ''), 'CURRENCYCODE' => $currency, 'IPADDRESS' => $this->GetIpAddress(), 'ITEMAMT' => number_format($this->GetSubTotal(), 2, '.', ''), 'SHIPPINGAMT' => number_format($this->GetShippingCost(), 2, '.', ''), 'HANDLINGAMT' => number_format($this->GetHandlingCost(), 2, '.', ''), 'TAXAMT' => number_format($this->GetTaxCost(), 2, '.', ''), 'INVNUM' => $orderId, 'NAME' => $shippingDetails['firstname'] . " " . $shippingDetails['lastname'], 'SHIPTOSTREET' => $shippingDetails['street1'], 'SHIPTOSTREET2' => $shippingDetails['street2'], 'SHIPTOCITY' => $shippingDetails['city'], 'SHIPTOSTATE' => $shipstate, 'SHIPTOZIP' => $shippingDetails['zip'], 'SHIPTOCOUNTRY' => $shippingDetails['countrycode'], 'PHONENUM' => $shippingDetails['phone'], 'BUTTONSOURCE' => "Interspire_cart_EC_AU");
         $paypal_query = '';
         foreach ($pp_array as $key => $value) {
             $paypal_query .= $key . '=' . urlencode($value) . "&";
         }
         $paypal_query = rtrim($paypal_query, '&');
         $result = $this->_ConnectToProvider($transactionURL, $transactionURI, $paypal_query);
         $nvpArray = $this->_DecodePaypalResult($result);
         $_SESSION['PayPalExpressResponse'] = $nvpArray;
         $token = md5(GetConfig('EncryptionToken') . $_COOKIE['SHOP_ORDER_TOKEN']);
         header(sprintf("Location:%s/finishorder.php?o=%s", $GLOBALS['ShopPathSSL'], $token));
     } else {
         // Invalid PayPalExpress response
         $this->SetError(GetLang('PayPalExpressInvalidOrder'));
         return false;
     }
 }
Ejemplo n.º 11
0
	protected function _ConstructPostData($postData)
	{

		$billingDetails = $this->GetBillingDetails();
		$billState = '';
		if ($billingDetails['ordbillcountrycode'] == 'US' || $billingDetails['ordbillcountrycode'] == 'CA') {
			$billState = GetStateISO2ById($billingDetails['ordbillstateid']);
		}

		$shippingDetails = $this->getShippingAddress();
		$shipState = '';
		if ($shippingDetails['country_iso2'] == 'US' || $shippingDetails['country_iso2'] == 'CA') {
			$shipState = GetStateISO2ById($shippingDetails['state_id']);
		}


		switch ($postData['cctype']) {
			case 'VISA':
				$cctype = '001';
				break;
			case 'MC':
				$cctype = '002';
				break;
			case 'AMEX':
				$cctype = '003';
				break;
			case 'DISCOVER':
				$cctype = '004';
				break;
			case 'DINERS':
				$cctype = '005';
				break;
			case 'JCB':
				$cctype = '007';
				break;
			case 'MAESTRO':
			case 'SOLO':
				$cctype = '024';
				break;
			case 'LASER':
				$cctype = '035';
				break;
		}

		$quote = getCustomerQuote();

		$xml = array(
			'merchantID' => $this->GetValue('merchantid'),
			'merchantReferenceCode' => $this->GetCombinedOrderId(),
			'ccAuthService' => array(
				'run' => 'true',
			),
			'clientLibrary' => 'PHP',
			'clientLibraryVersion' => phpversion(),
			'clientEnvironment' => php_uname(),
			'billTo' => array(
				'firstName' 	=> $billingDetails['ordbillfirstname'],
				'lastName'		=> $billingDetails['ordbilllastname'],
				'company'		=> $billingDetails['ordbillcompany'],
				'street1'		=> $billingDetails['ordbillstreet1'],
				'city'			=> $billingDetails['ordbillsuburb'],
				'state'			=> $billState,
				'country'		=> $billingDetails['ordbillcountrycode'],
				'postalCode'	=> $billingDetails['ordbillzip'],
				'email'			=> $billingDetails['ordbillemail'],
				'phoneNumber'	=> $billingDetails['ordbillphone'],
			),
			'shipTo' => array(
				'firstName' 	=> $shippingDetails['first_name'],
				'lastName'		=> $shippingDetails['last_name'],
				'company'		=> $shippingDetails['company'],
				'street1'		=> $shippingDetails['address_1'],
				'street2'		=> $shippingDetails['address_2'],
				'city'			=> $shippingDetails['city'],
				'state'			=> $shipState,
				'country'		=> $shippingDetails['country_iso2'],
				'postalCode'	=> $shippingDetails['zip'],
				'email'			=> $shippingDetails['email'],
				'phoneNumber'	=> $shippingDetails['phone'],
			),
			'purchaseTotals' => array(
				'currency' => GetCurrencyCodeByID($this->GetCurrency()),
				'grandTotalAmount' => number_format($this->GetGatewayAmount(), 2, '.', ''),
			),
		);

		$ip = GetIP();
		if ($ip) {
			$xml['billTo']['ipAddress'] = $ip;
		}

		// are we doing a sale ?
		if ($this->GetValue('transactiontype') == 'SALE') {
			$xml['ccCaptureService'] = array(
				'run' => 'true',
			);
		}

		$card = array(
			'fullName'			=> $postData['name'],
			'accountNumber' 	=> $postData['ccno'],
			'expirationMonth' 	=> $postData['ccexpm'],
			'expirationYear' 	=> '20' . $postData['ccexpy'],
			'cardType' 			=> $cctype,
		);
		if ($this->GetValue('cardcode') == 'YES') {
			$card['cvNumber'] = $postData['cccvd'];
		}
		if ($this->CardTypeRequiresIssueNoOrDate($postData['cctype'])) {
			$card['issueNumber'] = $postData['ccissueno'];
			$card['startMonth'] = $postData['ccissuedatem'];
			$card['startYear'] = $postData['ccissuedatey'];
		}

		$xml['card'] = $card;

		// add items to order
		$x = 0;
		$items = array();
		foreach ($quote->getItems() as /** @var ISC_QUOTE_ITEM */$item) {
			$itemXml = array(
				'productName' 	=> $item->getName(),
				'productSKU'	=> $item->getSku(),
				'unitPrice'		=> number_format($item->getPrice(), '2', '.', ''),
				'quantity'		=> $item->getQuantity(),
				'id'			=> (string)$x,
			);

			$items[] = $itemXml;

			$x++;
		}

		if (!empty($items)) {
			$xml['items'] = $items;
		}

		return $xml;
	}
Ejemplo n.º 12
0
		/**
		*	Redirect the customer to Protx's site to enter their payment details
		*/
		public function TransferToProvider()
		{
			$currency = GetDefaultCurrency();

			$crypt_after = "";
			$shipping_address = "";
			$shipping_zip = "";
			$total = number_format($this->GetGatewayAmount(),2,'.','');
			$this->_vendorname = $this->GetValue("vendorname");
			$this->_encryptionpassword = $this->GetValue("encryptionpassword");
			$testmode_on = $this->GetValue("testmode");

			if($testmode_on == "YES") {
				$this->_protxurl = "https://test.sagepay.com/gateway/service/vspform-register.vsp";
			}
			else if ($testmode_on == "SIMULATOR") {
				$this->_protxurl = "https://test.sagepay.com/Simulator/VSPFormGateway.asp";
			}
			else {
				$this->_protxurl = "https://live.sagepay.com/gateway/service/vspform-register.vsp";
			}


			$description = GetLang('ProtxYourOrderFromX') . str_replace("&#39;", "'", $GLOBALS['StoreName']);

			$billingDetails = $this->GetBillingDetails();

			$billState = '';
			if($billingDetails['ordbillcountrycode'] == 'US') {
				$billState = GetStateISO2ById($billingDetails['ordbillstateid']);
			}

			if($this->IsDigitalOrder()) {
				$ShippingAddress = array(
					'firstname' => $billingDetails['ordbillfirstname'],
					'lastname'	=> $billingDetails['ordbilllastname'],
					'address1'	=> $billingDetails['ordbillstreet1'],
					'address2'	=> $billingDetails['ordbillstreet2'],
					'city'		=> $billingDetails['ordbillsuburb'],
					'state'		=> $billState,
					'country'	=> $billingDetails['ordbillcountrycode'],
					'postcode'	=> $billingDetails['ordbillzip']
				);
			} else {
				$shippingAddress = $this->getShippingAddress();
				$shipState = '';
				if($shippingAddress['country_iso2'] == 'US') {
					$shipState = GetStateISO2ById($shippingAddress['state_id']);
				}

				$ShippingAddress = array(
					'firstname' => $shippingAddress['first_name'],
					'lastname'	=> $shippingAddress['last_name'],
					'address1'	=> $shippingAddress['address_1'],
					'address2'	=> $shippingAddress['address_2'],
					'city'		=> $shippingAddress['city'],
					'state'		=> $shipState,
					'country'	=> $shippingAddress['country_iso2'],
					'postcode'	=> $shippingAddress['zip']
				);
			}

			$data = array(
						'VendorTxCode'		=> $_COOKIE['SHOP_ORDER_TOKEN'] . "_" . rand(1,100000),
						'Amount'			=> $total,
						'Currency'			=> $currency['currencycode'],
						'Description'		=> $description,
						'SuccessURL'		=> $GLOBALS['ShopPath'].'/finishorder.php',
						'FailureURL'		=> $GLOBALS['ShopPath'].'/finishorder.php?protx_failure=true',
						'CustomerName'		=> str_replace("&", "", $billingDetails['ordbillfirstname'].' '.$billingDetails['ordbilllastname']),
						'CustomerEMail'		=> str_replace("&", "", $billingDetails['ordbillemail']),
						'VendorEMail'		=> str_replace("&", "", GetConfig('OrderEmail')),
						'ContactNumber'		=> str_replace("&", "", $billingDetails['ordbillphone']),

						'BillingSurname'	=> str_replace("&", "", $billingDetails['ordbilllastname']),
						'BillingFirstnames'	=> str_replace("&", "", $billingDetails['ordbillfirstname']),
						'BillingAddress1'	=> str_replace("&", "", $billingDetails['ordbillstreet1']),
						'BillingAddress2'	=> str_replace("&", "", $billingDetails['ordbillstreet2']),
						'BillingCity'		=> str_replace("&", "", $billingDetails['ordbillsuburb']),
						'BillingState'		=> str_replace("&", "", $billState),
						'BillingPostCode'	=> str_replace("&", "", $billingDetails['ordbillzip']),
						'BillingCountry'	=> str_replace("&", "", $billingDetails['ordbillcountrycode']),

						'DeliverySurname'	=> str_replace("&", "", $ShippingAddress['lastname']),
						'DeliveryFirstnames'=> str_replace("&", "", $ShippingAddress['firstname']),
						'DeliveryAddress1'	=> str_replace("&", "", $ShippingAddress['address1']),
						'DeliveryAddress2'	=> str_replace("&", "", $ShippingAddress['address2']),
						'DeliveryCity'		=> str_replace("&", "", $ShippingAddress['city']),
						'DeliveryState'		=> str_replace("&", "", $ShippingAddress['state']),
						'DeliveryPostCode'	=> str_replace("&", "", $ShippingAddress['postcode']),
						'DeliveryCountry'	=> str_replace("&", "", $ShippingAddress['country'])
			);

			$crypt_before = '';
			// Build the XOR'd crypt string as per the Protx documentation
			foreach ($data as $key => $value) {
				$crypt_before .= $key."=".$value."&";
			}
			$crypt_before = rtrim($crypt_before, '&');

			// Base 64 encode to make it binary-safe
			$crypt_after = $this->simplexor($crypt_before, $this->_encryptionpassword);
			$crypt_after = base64_encode($crypt_after);
			?>
				<html>
					<head>
						<title><?php echo GetLang('RedirectingToProtx'); ?></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 action="<?php echo $this->_protxurl; ?>" method="post">
							<input type="hidden" name="VPSProtocol" value="2.23">
							<input type="hidden" name="TxType" value="PAYMENT">
							<input type="hidden" name="Vendor" value="<?php echo htmlentities($this->_vendorname); ?>">
							<input type="hidden" name="Crypt" value="<?php echo $crypt_after; ?>">
						</form>
					</body>
				</html>
			<?php
		}
Ejemplo n.º 13
0
		protected function _ConstructPostData($postData)
		{
			$ccname 		= $postData['name'];
			$cctype 		= $postData['cctype'];
			$ccissueno 		= $postData['ccissueno'];
			$ccissuedatem 	= $postData['ccissuedatem'];
			$ccissuedatey 	= $postData['ccissuedatey'];
			$ccnum 			= $postData['ccno'];
			$ccexpm 		= $postData['ccexpm'];
			$ccexpy 		= $postData['ccexpy'];
			$cccvd 			= $postData['cccvd'];

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

			$billingDetails = $this->GetBillingDetails();


			$data['publisher-name'] 	= $this->GetValue('accountname');
			$data['mode'] 				= 'auth';

			if (isset($_SERVER['REMOTE_ADDR'])) {
				$data['ipaddress'] = $_SERVER['REMOTE_ADDR'];
			} else {
				// if REMOTE_ADDR isn't defined this is probably being called from a unit test
				$data['ipaddress'] = '0.0.0.0';
			}

			if ($billingDetails['ordbillcountrycode'] == 'US' || $billingDetails['ordbillcountrycode'] == 'CA') {
				$billState = GetStateISO2ById($billingDetails['ordbillstateid']);
				$billProvince = "";
			}
			else {
				$billState = "ZZ";
				$billProvince = $billingDetails['ordbillstate'];
			}

			$data['order-id']			= $this->GetCombinedOrderId();
			$data['convert'] 			= 'underscores';
			$data['authtype'] 			= 'authpostauth';
			$data['paymethod']			= 'credit';
			$data['dontsndmail'] 		= 'yes';
			$data['shipinfo'] 			= 1;
			$data['easycart'] 			= 1;

			$data["email"] 				= $billingDetails['ordbillemail'];
			$data["address1"]			= $billingDetails['ordbillstreet1'];
			$data["address2"] 			= $billingDetails['ordbillstreet2'];
			$data["city"] 				= $billingDetails['ordbillsuburb'];
			$data["state"]	 			= $billState;
			$data["province"]			= $billProvince;
			$data["zip"] 				= $billingDetails['ordbillzip'];
			$data["country"] 			= $billingDetails['ordbillcountrycode'];
			$data["phone"]				= $billingDetails['ordbillphone'];

			$data["card-number"] 		= $ccnum;
			$data["card-name"] 			= $ccname;
			$data["card-amount"] 		= $amount;
			$data["card-exp"] 			= $ccexpm . "/" . $ccexpy;
			$data["card-cvv"] 			= $cccvd;

			$data["card-address1"]		= $billingDetails['ordbillstreet1'];
			$data["card-address2"]		= $billingDetails['ordbillstreet2'];
			$data["card-city"]			= $billingDetails['ordbillsuburb'];
			$data["card-state"]			= $billState;
			$data["card-prov"]			= $billProvince;
			$data["card-zip"]			= $billingDetails['ordbillzip'];
			$data["card-country"]		= $billingDetails['ordbillcountrycode'];

			if (in_array($cctype, array('MAESTRO', 'SWITCH', 'SOLO'))) {
				$data['cardissuenum'] = $ccissueno;
				$data['cardstartdate'] = $ccissuedatem . "/" . $ccissuedatey;
			}

			return http_build_query($data);
		}
    /**
     *	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;
    }
Ejemplo n.º 15
0
		protected function _ConstructPostData($postData)
		{
			$transactionid	= $this->GetCombinedOrderId();

			$pendingOrder = LoadPendingOrderByToken();
			$description = sprintf(GetLang('ProtxVspDirectOrderFromX'), $transactionid, $GLOBALS['StoreName']);

			$ccname 		= $postData['name'];
			$cctype 		= $postData['cctype'];

			$ccissueno 		= $postData['ccissueno'];
			$ccissuedatem 	= $postData['ccissuedatem'];
			$ccissuedatey 	= $postData['ccissuedatey'];

			$ccnum 			= $postData['ccno'];
			$ccexpm 		= $postData['ccexpm'];
			$ccexpy 		= $postData['ccexpy'];
			$cccvd 			= $postData['cccvd'];

			$currency = GetDefaultCurrency();

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

			$billState = '';
			if($pendingOrder['ordbillcountrycode'] == 'US') {
				$billState = GetStateISO2ById($pendingOrder['ordbillstateid']);
			}

			$shippingAddress = $this->getShippingAddress();
			$shipState = '';
			if($shippingAddress['country_iso2'] == 'US') {
				$shipState = GetStateISO2ById($shipingAddress['state_id']);
			}

			$TransType = 'DEFERRED';
			if($this->GetValue('transactiontype')) {
				$TransType = $this->GetValue('transactiontype');
			}

			// Contstruct the POST data
			$vspdirect_post = array(
				'VPSProtocol'		=> '2.23',
				'TxType'			=> $TransType,
				'Vendor' 			=> $this->GetValue("vendorname"),
				'VendorTxCode' 		=> 'ISC-'.$transactionid,
				'Description'		=> $description,

				'CardType' 			=> $cctype,
				'CardNumber' 		=> $ccnum,
				'CardHolder' 		=> $ccname,
				'ExpiryDate' 		=> $ccexpm.$ccexpy,
				'Amount' 			=> $amount,
				'Currency' 			=> $currency['currencycode'],

				'BillingSurname'	=> $pendingOrder['ordbilllastname'],
				'BillingFirstnames'	=> $pendingOrder['ordbillfirstname'],
				'BillingAddress1'	=> $pendingOrder['ordbillstreet1'],
				'BillingAddress2'	=> $pendingOrder['ordbillstreet2'],
				'BillingCity'		=> $pendingOrder['ordbillsuburb'],
				'BillingState'		=> $billState,
				'BillingPostCode' 	=> $pendingOrder['ordbillzip'],
				'BillingCountry'	=> $pendingOrder['ordbillcountrycode'],
				'BillingPhone' 		=> $pendingOrder['ordbillphone'],

				'DeliverySurname'	=> $shippingAddress['last_name'],
				'DeliveryFirstnames'=> $shippingAddress['first_name'],
				'DeliveryAddress1'	=> $shippingAddress['address_1'],
				'DeliveryAddress2'	=> $shippingAddress['address_2'],
				'DeliveryCity'		=> $shippingAddress['city'],
				'DeliveryState'		=> $shipState,
				'DeliveryPostCode' 	=> $shippingAddress['zip'],
				'DeliveryCountry'	=> $shippingAddress['country_iso2'],
				'DeliveryPhone' 	=> $shippingAddress['phone'],


			);

			if ($this->CardTypeHasIssueDate($cctype)) {
				$vspdirect_post['StartDate'] 	= $ccissuedatem . $ccissuedatey;
			}

			if ($this->CardTypeHasIssueNo($cctype)) {
				$vspdirect_post['IssueNumber'] 	= $ccissueno;
			}

			if ($this->CardTypeRequiresCVV2($cctype)) {
				$vspdirect_post['CV2'] 			= $cccvd;
			}

			return http_build_query($vspdirect_post);
		}
Ejemplo n.º 16
0
 /**
  * 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;
     }
 }
 /**
  * Sends the order details to Paypal to process
  *
  */
 public function DoExpressCheckoutPayment()
 {
     if (isset($_COOKIE['SHOP_ORDER_TOKEN'])) {
         $orders = $this->GetOrders();
         reset($orders);
         $order = current($orders);
         $orderIds = '#' . implode(', #', array_keys($orders));
         $order_desc = sprintf(GetLang('YourOrderFrom'), $GLOBALS['StoreName']) . ' (' . $orderIds . ')';
         $merchant = $this->GetMerchantSettings();
         if ($merchant['testmode'] == 'YES') {
             $transactionURL = $this->_testTransactionURL;
             $transactionURI = $this->_testTransactionURI;
         } else {
             $transactionURL = $this->_liveTransactionURL;
             $transactionURI = $this->_liveTransactionURI;
         }
         $response = $_SESSION['CHECKOUT']['PayPalExpressCheckout'];
         // unset PayPalPaymentsPro response in session
         unset($_SESSION['CHECKOUT']['PayPalExpressCheckout']);
         $shippingDetails = $this->GetShippingAddresses();
         $shippingDetails = $shippingDetails[$order['orderid']];
         if ($shippingDetails['ordshipstateid'] != 0 && GetStateISO2ById($shippingDetails['ordshipstateid'])) {
             $shipstate = GetStateISO2ById($shippingDetails['ordshipstateid']);
         } else {
             $shipstate = isc_html_escape($shippingDetails['ordshipstate']);
         }
         $currency = GetCurrencyCodeByID(GetConfig('DefaultCurrencyID'));
         $pp_array = array('METHOD' => 'DoExpressCheckoutPayment', 'USER' => $merchant['username'], 'PWD' => $merchant['password'], 'SIGNATURE' => $merchant['signature'], 'VERSION' => '52.0', 'TOKEN' => $response['TOKEN'], 'PAYERID' => $response['PAYERID'], 'PAYMENTACTION' => $merchant['transactionType'], 'AMT' => number_format($order['ordgatewayamount'], 2, '.', ''), 'CURRENCYCODE' => $currency, 'IPADDRESS' => $this->GetIpAddress(), 'ITEMAMT' => number_format($this->GetSubTotal(), 2, '.', ''), 'SHIPPINGAMT' => number_format($this->GetShippingCost(), 2, '.', ''), 'HANDLINGAMT' => number_format($this->GetHandlingCost(), 2, '.', ''), 'TAXAMT' => number_format($this->GetTaxCost(), 2, '.', ''), 'INVNUM' => $orderIds, 'NAME' => $shippingDetails['ordshipfirstname'] . " " . $shippingDetails['ordshiplastname'], 'SHIPTOSTREET' => $shippingDetails['ordshipstreet1'], 'SHIPTOSTREET2' => $shippingDetails['ordshipstreet2'], 'SHIPTOCITY' => $shippingDetails['ordshipsuburb'], 'SHIPTOSTATE' => $shipstate, 'SHIPTOZIP' => $shippingDetails['ordshipzip'], 'SHIPTOCOUNTRY' => $shippingDetails['ordshipcountrycode'], 'PHONENUM' => $shippingDetails['ordshipphone']);
         $paypal_query = http_build_query($pp_array);
         $result = $this->_ConnectToProvider($transactionURL, $transactionURI, $paypal_query);
         $nvpArray = $this->_DecodePaypalResult($result);
         $_SESSION['PayPalPaymentsProResponse'] = $nvpArray;
         $token = md5(GetConfig('EncryptionToken') . $_COOKIE['SHOP_ORDER_TOKEN']);
         header(sprintf("Location:%s/finishorder.php?o=%s", $GLOBALS['ShopPathSSL'], $token));
     } else {
         // Invalid PayPalPaymentsPro response
         $this->SetError(GetLang('PayPalPaymentsProInvalidOrder'));
         return false;
     }
 }
    /**
     * Generate the payment form to collect payment details and pass them back
     * to the payment provider.
     *
     * @return string The generated payment form.
     */
    public function ShowPaymentForm()
    {
        // Authorize.net needs HTTPS, so if it's not on then stop
        if (!strtolower($_SERVER['HTTPS']) == "on") {
            ob_end_clean();
            ?>
					<script type="text/javascript">
						alert("<?php 
            echo GetLang('AuthorizeNetNoSSLError');
            ?>
");
						document.location.href="<?php 
            echo $GLOBALS['ShopPath'];
            ?>
/checkout.php?action=confirm_order";
					</script>
				<?php 
            die;
        }
        $GLOBALS['AuthorizeNetMonths'] = "";
        $GLOBALS['AuthorizeNetYears'] = "";
        for ($i = 1; $i <= 12; $i++) {
            $stamp = mktime(0, 0, 0, $i, 15, isc_date("Y"));
            $i = str_pad($i, 2, "0", STR_PAD_LEFT);
            if (@$_POST['AuthorizeNet_ccexpm'] == $i) {
                $sel = 'selected="selected"';
            } else {
                $sel = "";
            }
            $GLOBALS['AuthorizeNetMonths'] .= sprintf("<option %s value='%s'>%s</option>", $sel, $i, isc_date("M", $stamp));
        }
        for ($i = isc_date("Y"); $i < isc_date("Y") + 10; $i++) {
            if (@$_POST['AuthorizeNet_ccexpy'] == substr($i, 2, 2)) {
                $sel = 'selected="selected"';
            } else {
                $sel = "";
            }
            $GLOBALS['AuthorizeNetYears'] .= sprintf("<option %s value='%s'>%s</option>", $sel, substr($i, 2, 2), $i);
        }
        $require_cvv2 = $this->GetValue("requirecvv2");
        if ($require_cvv2 == "YES") {
            if (isset($_POST['AuthorizeNet_cccode'])) {
                $GLOBALS['AuthorizeNetCCV2'] = (int) $_POST['AuthorizeNet_cccode'];
            }
            $GLOBALS['AuthorizeNetHideCVV2'] = '';
        } else {
            $GLOBALS['AuthorizeNetHideCVV2'] = 'none';
        }
        // Grab the billing details for the order
        $billingDetails = $this->GetBillingDetails();
        $GLOBALS['AuthorizeNetName'] = isc_html_escape($billingDetails['ordbillfirstname'] . ' ' . $billingDetails['ordbilllastname']);
        $GLOBALS['AuthorizeNetBillingAddress'] = isc_html_escape($billingDetails['ordbillstreet1']);
        if ($billingDetails['ordbillstreet2'] != "") {
            $GLOBALS['AuthorizeNetBillingAddress'] .= " " . isc_html_escape($billingDetails['ordbillstreet2']);
        }
        $GLOBALS['AuthorizeNetCity'] = isc_html_escape($billingDetails['ordbillsuburb']);
        if ($billingDetails['ordbillstateid'] != 0 && GetStateISO2ById($billingDetails['ordbillstateid'])) {
            $GLOBALS['AuthorizeNetState'] = GetStateISO2ById($billingDetails['ordbillstateid']);
        } else {
            $GLOBALS['AuthorizeNetState'] = isc_html_escape($billingDetails['ordbillstate']);
        }
        $GLOBALS['AuthorizeNetBillingZip'] = isc_html_escape($billingDetails['ordbillzip']);
        // Format the amount that's going to be going through the gateway
        $GLOBALS['OrderAmount'] = CurrencyConvertFormatPrice($this->GetGatewayAmount());
        // Was there an error validating the payment? If so, pre-fill the form fields with the already-submitted values
        if ($this->HasErrors()) {
            $GLOBALS['AuthorizeNetName'] = isc_html_escape($_POST['AuthorizeNet_name']);
            $GLOBALS['AuthorizeNetNum'] = isc_html_escape($_POST['AuthorizeNet_ccno']);
            $GLOBALS['AuthorizeNetBillingAddress'] = isc_html_escape($_POST['AuthorizeNet_ccaddress']);
            $GLOBALS['AuthorizeNetCity'] = isc_html_escape($_POST['AuthorizeNet_cccity']);
            $GLOBALS['AuthorizeNetState'] = isc_html_escape($_POST['AuthorizeNet_ccstate']);
            $GLOBALS['AuthorizeNetBillingZip'] = isc_html_escape($_POST['AuthorizeNet_zip']);
            $GLOBALS['AuthorizeNetErrorMessage'] = implode("<br />", $this->GetErrors());
        } else {
            // Hide the error message box
            $GLOBALS['HideAuthorizeNetError'] = "none";
        }
        // Collect their details to send through to Authorize.NET
        $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("authorizenet");
        return $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true);
    }
Ejemplo n.º 19
0
		/**
		* Sends the order details to Paypal to process
		*
		*/
		public function DoExpressCheckoutPayment()
		{
			if(isset($_COOKIE['SHOP_ORDER_TOKEN'])) {
				$orders = $this->GetOrders();
				reset($orders);
				$order = current($orders);
				$orderIds = '#'.implode(', #', array_keys($orders));
				$order_desc = sprintf(GetLang('YourOrderFrom'), $GLOBALS['StoreName']).' ('.$orderIds.')';

				$merchant = $this->GetMerchantSettings();

				if($merchant['testmode'] == 'YES') {
					$transactionURL = $this->_testTransactionURL;
					$transactionURI = $this->_testTransactionURI;
				}
				else {
					$transactionURL = $this->_liveTransactionURL;
					$transactionURI = $this->_liveTransactionURI;
				}

				$amount = $this->GetGatewayAmount();

				$response = $_SESSION['CHECKOUT']['PayPalExpressCheckout'];

				// unset PayPalPaymentsPro response in session
				unset($_SESSION['CHECKOUT']['PayPalExpressCheckout']);

				$shippingAddress = $this->getShippingAddress();
				if($shippingAddress['state_id'] != 0 && GetStateISO2ById($shippingAddress['state_id'])) {
					$shipstate = GetStateISO2ById($shippingAddress['state_id']);
				}
				else {
					$shipstate = isc_html_escape($shippingAddress['state']);
				}
				$currency = GetCurrencyCodeByID(GetConfig('DefaultCurrencyID'));
				$pp_array = array(
					'METHOD'	=> 'DoExpressCheckoutPayment',
					'USER'		=> $merchant['username'],
					'PWD'		=> $merchant['password'],
					'SIGNATURE'	=> $merchant['signature'],
					'VERSION'	=> '53.0',
					'TOKEN'		=> $response['TOKEN'],
					'PAYERID'	=> $response['PAYERID'],
					'PAYMENTACTION'	=> $merchant['transactionType'],
					'AMT'		=> number_format($amount,2,'.',''),
					'CURRENCYCODE'	=> $currency,
					'IPADDRESS'	=> $this->GetIpAddress(),
					'INVNUM'	=> $orderIds,
					'NAME'		=> $shippingAddress['first_name']." ".$shippingAddress['last_name'],
					'SHIPTOSTREET'	=> $shippingAddress['address_1'],
					'SHIPTOSTREET2'	=> $shippingAddress['address_2'],
					'SHIPTOCITY'	=> $shippingAddress['city'],
					'SHIPTOSTATE'	=> $shipstate,
					'SHIPTOZIP'	=> $shippingAddress['zip'],
					'SHIPTOCOUNTRY'	=> $shippingAddress['country_iso2'],
					'PHONENUM'	=> $shippingAddress['phone'],
					'BUTTONSOURCE'	=> "ISC_ShoppingCart_EC",
					'CUSTOM'	=> $_COOKIE['SHOP_ORDER_TOKEN'] . '_' . $_COOKIE['SHOP_SESSION_TOKEN'],
					'NOTIFYURL'	=> $GLOBALS['ShopPath'].'/checkout.php?action=gateway_ping&provider='.$this->GetId(),
				);

				$paypal_query = http_build_query($pp_array);

				$result = $this->_ConnectToProvider($transactionURL, $transactionURI, $paypal_query);
				//$nvpArray = $this->_DecodePaypalResult($result);
				//$_SESSION['PayPalPaymentsProResponse'] = $nvpArray;


				if($this->_HandleResponse($result)) {
					$success = 1;
				} else {
					$success = 0;
				}

				$_REQUEST['o'] = md5(GetConfig('EncryptionToken').$_COOKIE['SHOP_ORDER_TOKEN']);
				$_REQUEST['success'] = $success;
				$GLOBALS['ISC_CLASS_ORDER'] = GetClass('ISC_ORDER');
				$GLOBALS['ISC_CLASS_ORDER']->HandlePage();
			}
			else {
				// Invalid PayPalPaymentsPro response
				$this->SetError(GetLang('PayPalPaymentsProInvalidOrder'));
				return false;
			}
		}