Ejemplo n.º 1
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.º 2
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($dataSource = array())
		{
			if (empty($dataSource)) {
				$dataSource = $_POST;
			}

			$billfirstname = "";
			$billlastname = "";
			$cccode = "";
			$error = false;

			$requiredFields = array(
				"PayflowPro_name"		=> GetLang('PayflowProEnterName'),
				"PayflowPro_ccno"		=> GetLang('PayflowProEnterCardNumber'),
				"PayflowPro_ccexpm"		=> GetLang('PayflowProEnterCreditCardMonth'),
				"PayflowPro_ccexpy"		=> GetLang('PayflowProEnterCreditCardYear'),
			);

			$requireCVV2 = $this->GetValue("PayflowProEnterCVV2Number");
			if($requireCVV2 == "YES") {
				$requiredFields['PayflowPro_cccode'] = GetLang('PayflowProCreditCardCCV2');
				$cccode = $dataSource['PayflowPro_cccode'];
			}

			foreach($requiredFields as $field => $message) {
				if(!isset($dataSource[$field]) || trim($dataSource[$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, $dataSource['PayflowPro_ccexpm']+1, 0, $dataSource['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'])) {
				// Invalid payflow response
				$this->SetError(GetLang('PayflowProInvalidOrder'));
				return false;
			}

			$ccname = $dataSource['PayflowPro_name'];
			$ccnum = $dataSource['PayflowPro_ccno'];
			$ccexpm = $dataSource['PayflowPro_ccexpm'];
			$ccexpy = $dataSource['PayflowPro_ccexpy'];
			$ccexp = sprintf("%s%s", $ccexpm, $ccexpy);

			$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);

			$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']);

			$billingDetails = $this->GetBillingDetails();

			// Arrange the data into name/value pairs ready to send
			$pp_values = array (
				'USER'		=> $userid,
				'VENDOR'	=> $vendorid,
				'PARTNER'	=> $partnerid,
				'PWD'		=> $password,
				'TENDER'	=> 'C',  // C - Direct Payment using credit card
				'TRXTYPE'	=> $transactionType,  // A - Authorization, S - Sale
				'ACCT'		=> $ccnum,
				'CVV2'		=> $cccode,
				'EXPDATE'	=> $ccexp,
				'AMT'		=> number_format($this->GetGatewayAmount(), 2),
				'CURRENCY'	=> $currency,
				'FIRSTNAME'	=> $billingDetails['ordbillfirstname'],
				'LASTNAME'	=> $billingDetails['ordbilllastname'],
				'STREET'	=> trim($billingDetails['ordbillstreet1'] . " " . $billingDetails['ordbillstreet2']),
				'CITY'		=> $billingDetails['ordbillsuburb'],
				'STATE'		=> $billingDetails['ordbillstate'],
				'ZIP'		=> $billingDetails['ordbillzip'],
				'COUNTRY'	=> $billingDetails['ordbillcountry'],
				'EMAIL'		=> $billingDetails['ordbillemail'],
				'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;
				}
			}

			// send the request
			$nvpArray = $this->SendData($orderIds, $payflowprourl, $paypal_query);

			$responseCode = isc_html_escape($nvpArray['RESULT']);
			$responseMsg = isc_html_escape($nvpArray['RESPMSG']);
			$transactionId = 0;

			// Load the paypal transaction Type
			$transactionType = $this->GetValue('transactiontype');
			if($transactionType == 'A') {
				$fullTransType = 'authorized';
			} elseif ($transactionType == 'S') {
				$fullTransType = 'captured';
			}


			if (isset($nvpArray['PNREF'])) {
				$transactionId = isc_html_escape($nvpArray['PNREF']);
			}
			$success = true;
			$message = '';
			if ($responseCode == 0) {
				if (isset($nvpArray['AVSADDR']) && $nvpArray['AVSADDR'] != "Y") {
					$message = GetLang('AVSCheckFailed');
				}
				if (isset($nvpArray['AVSZIP']) && $nvpArray['AVSZIP'] != "Y") {
					$message = GetLang('AVSCheckFailed');
				}
				if (isset($nvpArray['CVV2MATCH']) && $nvpArray['CVV2MATCH'] != "Y") {
					$message = GetLang('CVV2CheckFailed');
				}
			} else {
				$success = false;
			}


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

			if ($success == true) {
				$payflowProSuccess = sprintf(GetLang('PayflowProSuccess'), $orderIds, $transactionId, $responseCode, $responseMsg." ".$message);
				$GLOBALS['ISC_CLASS_LOG']->LogSystemSuccess(array('payment',  $this->GetName()), $payflowProSuccess, $message);

				$this->SetPaymentStatus(PAYMENT_STATUS_PAID);

				$updatedOrder = array(
					'ordpayproviderid' => $transactionId,
					'ordpaymentstatus' => $fullTransType,
				);

				if($message != '') {
					$extraInfo = $order['extrainfo'];
					//store the message in database
					$paymentMessage = array(
						"payment_message" => $message,
						"cardtype" => Store_CreditCard::getCardType($ccnum),
					);

					// Is there any existing extra info for the pending order?
					if($order['extrainfo'] != "") {
						$extraArray = @unserialize($order['extrainfo']);
						if(is_array($extraArray)) {
							$extraInfo = serialize(@array_merge($extraArray, $paymentMessage));
						}
					}
					else {
						$extraInfo = serialize($paymentMessage);
					}

					$updatedOrder['extrainfo'] = $extraInfo;
				}else{
					$extraInfo = $order['extrainfo'];
					//store the card type in database
					$paymentMessage = array(
						"cardtype" => Store_CreditCard::getCardType($ccnum),
					);
					if($order['extrainfo'] != "") {
						$extraArray = @unserialize($order['extrainfo']);
						if(is_array($extraArray)) {
							$extraInfo = serialize(@array_merge($extraArray, $paymentMessage));
						}
					}
					else {
						$extraInfo = serialize($paymentMessage);
					}

					$updatedOrder['extrainfo'] = $extraInfo;
				}

				$this->UpdateOrders($updatedOrder);

				return true;
			} else {

				// Status was declined or error, show the response message as an error
				$payflowError = sprintf(GetLang('PayflowProError'), $orderIds, $transactionId, $responseCode, $responseMsg);
				switch ($responseCode) {

					case 12: // incorrect card number or expiry date
					case 23: // Invalid account number
					case 24: // Invalid expiration date
					case 50: // Insufficient funds available
						$PendingOrder['paymentstatus'] = 3;
						$GLOBALS['ISC_CLASS_LOG']->LogSystemError(array('payment', $this->GetName()), $payflowError);
						$this->RedirectToOrderConfirmation(GetLang('PayflowProDeclinedRedirect'));
						return true;
					case 13: // referral
						$PendingOrder['paymentstatus'] = 2;
						$GLOBALS['ISC_CLASS_LOG']->LogSystemError(array('payment', $this->GetName()), $payflowError);
						return true;
					default: // a system error or duplicate transactions
						$GLOBALS['ISC_CLASS_LOG']->LogSystemError(array('payment', $this->GetName()), $payflowError);
						return false;
				}
			}

			return false;
		}
Ejemplo n.º 3
0
		/**
		 * Process the details entered on the payment form.
		 *
		 * @return boolean True if valid details and payment has been processed. False if not.
		 */
		public function ProcessPaymentForm($dataSource = array())
		{
			if (empty($dataSource)) {
				$dataSource = $_POST;
			}

			$bill_firstname = "";
			$bill_lastname = "";
			$result = "";
			$an_data = "";
			$an_uri = "/gateway/transact.dll";
			$error = false;

			$requiredFields = array(
				"AuthorizeNet_name",
				"AuthorizeNet_ccno",
				"AuthorizeNet_ccexpm",
				"AuthorizeNet_ccexpy"
			);

			$require_cvv2 = $this->GetValue("requirecvv2");
			if($require_cvv2 == "YES") {
				$requiredFields[] = "AuthorizeNet_cccode";
			}

			$missingFields = false;
			foreach($requiredFields as $field) {
				if(!isset($dataSource[$field]) || !$dataSource[$field]) {
					$GLOBALS['ISC_CLASS_LOG']->LogSystemError('php', 'missing field: ' . $field, '');
					$missingFields = true;
				}
			}

			if(isset($_COOKIE['SHOP_ORDER_TOKEN']) && $missingFields == false) {
				$ccname = $dataSource['AuthorizeNet_name'];
				$ccnum = $dataSource['AuthorizeNet_ccno'];
				$ccexpm = $dataSource['AuthorizeNet_ccexpm'];
				$ccexpy = $dataSource['AuthorizeNet_ccexpy'];
				$ccexp = sprintf("%s%s", $ccexpm, $ccexpy);

				if($require_cvv2 == "YES") {
					$cccode = $dataSource['AuthorizeNet_cccode'];
				}

				// Load the Authorize.net merchant ID
				$merchant_id = $this->GetValue("merchantid");

				// Load the tranaction key
				$transaction_key = $this->GetValue("transactionkey");

				// Is Authorize.net setup in test or live mode?
				$test_mode = $this->GetValue("testmode");

				// Load the Authorize.net transaction Type
				$transactionType = $this->GetValue('transactiontype');

				if($test_mode == "YES") {
					$an_url = "https://test.authorize.net/gateway/transact.dll";
					$an_pp_url = "test.authorize.net";
				}
				else {
					$an_url = "https://secure.authorize.net/gateway/transact.dll";
					$an_pp_url = "secure.authorize.net";
				}

				$orders = $this->GetOrders();
				if(count($orders) == 1) {
					list(,$order) = each($orders);
					$invoiceNum = $order['orderid'];
				}
				else {
					$invoiceNum = '';
				}

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

				$addressDetails = $this->GetBillingDetails();

				$shippingAddress = $this->getShippingAddress();

				// Arrange the data into name/value pairs ready to send
				$an_values = array (
					"x_login"				=> $merchant_id,
					"x_version"				=> "3.1",
					"x_delim_char"			=> "|",
					"x_delim_data"			=> "true",
					"x_url"					=> "false",
					"x_duplicate_window"	=> "0",
					"x_type"				=> $transactionType,
					"x_method"				=> "CC",
					"x_tran_key"			=> $transaction_key,
					"x_relay_response"		=> "false",
					"x_card_num"			=> $ccnum,
					"x_exp_date"			=> $ccexp,
					'x_invoice_num'			=> $invoiceNum,
					"x_description"			=> $order_desc,
					"x_amount"				=> $this->GetGatewayAmount(),
					"x_phone"				=> $addressDetails['ordbillphone'],
					"x_first_name"			=> $addressDetails['ordbillfirstname'],
					"x_last_name"			=> $addressDetails['ordbilllastname'],
					"x_address"				=> trim($addressDetails['ordbillstreet1'] . " " . $addressDetails['ordbillstreet2']),
					"x_email"				=> $addressDetails['ordbillemail'],
					"x_city"				=> $addressDetails['ordbillsuburb'],
					"x_state"				=> $addressDetails['ordbillstate'],
					"x_zip"					=> $addressDetails['ordbillzip'],
					"x_country"				=> $addressDetails['ordbillcountry'],
					"x_company"				=> $addressDetails['ordbillcompany'],
					"x_customer_ip"			=> GetIP(),

					//shipping info
					"x_ship_to_first_name"	=> $shippingAddress['first_name'],
					"x_ship_to_last_name"	=> $shippingAddress['last_name'],
					"x_ship_to_address"		=> trim($shippingAddress['address_1'] . " " . $shippingAddress['address_2']),
					"x_ship_to_city"		=> $shippingAddress['city'],
					"x_ship_to_state"		=> $shippingAddress['state'],
					"x_ship_to_zip"			=> $shippingAddress['zip'],
					"x_ship_to_country"		=> $shippingAddress['country'],
					"x_ship_to_company"		=> $shippingAddress['company'],
					"x_ship_to_phone"		=> $shippingAddress['phone'],

					"shop_order_token"		=> $_COOKIE['SHOP_ORDER_TOKEN']
				);

				$require_cvv2 = $this->GetValue("requirecvv2");
				if($require_cvv2 == "YES") {
					$an_values['x_card_code'] = $cccode;
				}

				// Merge the name/value pairs into a string
				foreach($an_values as $k=>$v) {
					$an_data .= sprintf("%s=%s&", $k, urlencode($v));
				}

				$an_data = rtrim($an_data, '&');

				$an_response = $this->ConnectToProvider($an_url, $an_pp_url, $an_data);
				if(!$an_response || empty($an_response)) {
					return false;
				}

				// Ref:
				// http://developer.authorize.net/guides/AIM/Transaction_Response/Response_Code_Details.htm
				// http://developer.authorize.net/guides/AIM/Transaction_Response/Response_Reason_Codes_and_Response_Reason_Text.htm
				$successfulResponses = array(
					// Success
					1 => array(
						1, // This transaction has been approved.
					),
					// Held for Review
					4 => array(
						193, // The transaction is currently under review.
						252, // The transaction was accepted, but is being held for merchant review.
						253, // The transaction was accepted and was authorized, but is being held for merchant review.
					),
				);

				if (isset($successfulResponses[$an_response[0]]) && in_array($an_response[2], $successfulResponses[$an_response[0]])) {
					$extraInfo = '';
					$paymentStatus = '';

					if($transactionType == 'AUTH_ONLY') {
						$paymentStatus = 'authorized';
					} else if ($transactionType == 'AUTH_CAPTURE') {
						$paymentStatus = 'captured';
					}

					//store credit card number, used in refund transaction
					$cc_vars = array(
						"cc_ccno" => substr($ccnum, -4),
						"cardtype" => Store_CreditCard::getCardType($ccnum),
					);

					// Is there any existing extra info for the pending order?
					if($order['extrainfo'] != "") {
						$extraArray = @unserialize($order['extrainfo']);
						if(is_array($extraArray)) {
							$extraInfo = serialize(@array_merge($extraArray, $cc_vars));
						}
					}
					else {
						$extraInfo = serialize($cc_vars);
					}

					// Save the authorization key
					$updatedOrder = array(
						'ordpayproviderid' => $an_response[6],
						'ordpaymentstatus' => $paymentStatus,
						'extrainfo' => $extraInfo
					);

					$this->UpdateOrders($updatedOrder);

					$this->SetPaymentStatus(PAYMENT_STATUS_PAID);

					$GLOBALS['ISC_CLASS_LOG']->LogSystemSuccess(array('payment', $this->GetName()), sprintf(GetLang('AuthorizeNetSuccess'), $invoiceNum));
					return true;
				}
				else {
					// Status was declined or error, show the response message as an error
					if($an_response[2] == 11) {
						$duplicateMessage = sprintf(GetLang('AuthorizeNetErrorDuplicate'), GetConfig('AdminEmail'));
						$this->SetError($duplicateMessage);
					}
					else {
						$this->SetError($an_response[3]);
					}

					if($an_response[0] == 2) {
						$GLOBALS['ISC_CLASS_LOG']->LogSystemError(array('payment', $this->GetName()), sprintf(GetLang('AuthorizeNetErrorDeclined'), $invoiceNum, $an_response[3]) , $an_response[3]);
					}
					else {
						$GLOBALS['ISC_CLASS_LOG']->LogSystemError(array('payment', $this->GetName()), sprintf(GetLang('AuthorizeNetErrorInvalid'), $invoiceNum, $an_response[3]), $an_response[3]);
					}
					return false;
				}
			}
			else {
				// Invalid Authorize.net response
				$this->SetError(GetLang('AuthorizeNetMissingFields'));
				return false;
			}
		}
Ejemplo n.º 4
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 = str_pad($postData['ccexpm'], 2, '0', STR_PAD_LEFT);
			$ccexpy = $postData['ccexpy']+2000;
			$ccexp = sprintf("%s%s", $ccexpm, $ccexpy);
			$cccvd = $postData['cccvd'];

			$startDateM = $postData['ccissuedatem'];
			$startDateY = $postData['ccissuedatey'] + 2000;
			$startDate = $startDateM . $startDateY;

			$cardMap = array(
				'VISA' 		=> 'Visa',
				'MC'		=> 'MasterCard',
				'AMEX'		=> 'Amex',
				'DISCOVER'	=> 'Discover',
				'MAESTRO'	=> 'Maestro',
				'SWITCH'	=> 'Maestro',
				'SOLO'		=> 'Solo',
			);

			$cctype = $cardMap[$ccTypeName];

			$currency = GetCurrencyCodeByID(GetConfig('DefaultCurrencyID'));

			$merchant = $this->GetMerchantSettings();

			//load all orders for this transaction
			$orders = $this->GetOrders();
			if(empty($orders)) {
				$orderData = LoadPendingOrdersByToken($_COOKIE['SHOP_ORDER_TOKEN']);
				$this->SetOrderData($orderData);
				$orders = $this->GetOrders();
			}
			$order = current($orders);
			$orderIds = '#'.implode(', #', array_keys($orders));

			$orderdesc = sprintf(GetLang('YourOrderFrom'), $GLOBALS['StoreName']).' ('.$orderIds.')';
			$custip = $this->GetIpAddress();

			// 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) {
				$shipstate = GetStateISO2ById($shippingAddress['state_id']);
			}
			else {
				$shipstate = isc_html_escape($shippingAddress['state']);
			}

			// Arrange the data into name/value pairs ready to send
			$pp_values = array (

				'METHOD'			=> 'DoDirectPayment',
				'USER'				=> $merchant['username'],
				'PWD'				=> $merchant['password'],
				'SIGNATURE'			=> $merchant['signature'],
				'VERSION'			=> '61.0',
				'PAYMENTACTION'		=> $merchant['transactionType'],

				/*customer details*/
				'IPADDRESS'			=> $custip,
				'FIRSTNAME'			=> $billingDetails['ordbillfirstname'],
				'LASTNAME'			=> $billingDetails['ordbilllastname'],
				'STREET'			=> $billingDetails['ordbillstreet1']." ".$billingDetails['ordbillstreet2'],
				'CITY'				=> $billingDetails['ordbillsuburb'],
				'STATE'				=> $billstate,
				'ZIP'				=> $billingDetails['ordbillzip'],
				'COUNTRYCODE'		=> $billingDetails['ordbillcountrycode'],
				'EMAIL'				=> $customeremail,
				'PHONENUM'			=> $billingDetails['ordbillphone'],

				/*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*/
				'CREDITCARDTYPE'	=> $cctype,
				'ACCT'				=> $ccnum,
				'EXPDATE'			=> $ccexp,
				'CVV2'				=> $cccvd,
				'CURRENCYCODE'		=> $currency,
				'AMT'				=> number_format($order['total_inc_tax'],2,'.',''),

				'INVNUM'			=> $orderIds,
				'BUTTONSOURCE'		=> 'ISC_ShoppingCart_DP',
			);

			if ($this->CardTypeHasIssueNo($ccTypeName)) {
				$pp_values['STARTDATE'] = $startDate;
				$pp_values['ISSUENUMBER'] = $postData['ccissueno'];
			}

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

			$paypal_query = http_build_query($pp_values);

			return $paypal_query;
		}