Jump to content


Photo

Bank connection for payment not working...Help please....


  • Please log in to reply
3 replies to this topic

#1 modigy

modigy
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts
  • LocationMadrid, Spain

Posted 11 October 2006 - 12:02 AM

Hello All!!

I am in the final moments of a project I have been working on.  The most important item is to complete the connection to the bank for a customer to make a purchase.  The project I am working on has been to upgrade the client's website visually and in part add some features.  However, the payment portion of the site does not need to be upgraded...they want to continue using it.

Here's my problem:  I am using the same php code as the 'old' site.  However, the code doesn't seem to work in my newly designed page.  After a customer has added an item to the 'shopping cart' they can click 'checkout' and they will be directed to the 'checkout.php' page where they then click a link that opens up a small popup window that connects to the bank so that they can input their credit card information. 

Currently my checkout.php page has the exact same code as the old checkout.php page.  The only difference (as far as I can tell) is the newly designed format (the new css style and images). 

Additionally, if I simply replace the new checkout.php with the old checkout.php everything works fine.  I don't have to change anything and it just works!

Is it possible that the css style is affecting PHP?  I'm going crazy trying to figure this out!!  Please Help!!

Thanks soo much in advance,

M
Code now, you'll get all the sleep you need when your Dead!!

#2 modigy

modigy
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts
  • LocationMadrid, Spain

Posted 11 October 2006 - 12:10 AM

I can't seem to post my code...and I'm using the 'code' tags as recommended...nor can I seem to attach a file...I'm not having a good day  :-[


M
Code now, you'll get all the sleep you need when your Dead!!

#3 modigy

modigy
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts
  • LocationMadrid, Spain

Posted 11 October 2006 - 12:21 AM

Perhaps it would help if I give you the website address to view the page in action:

www.madridbooks.com

I would hate for anyone to have to create an account to view the issue, but if you do I would greatly appreciate it.  Also here is my php code:

Above header info -
<?php
	session_start();	
	$selectedArray = $_SESSION['selectedArray'];
	 
	 // Get the shipping costs
	$database=mysql_pconnect('localhost','jandj_root');
	mysql_select_db('shipping');
	$query="select * from jandj_jandj.shipping limit 1";
	$result=mysql_query($query);
	$column=mysql_fetch_array($result);
		 
	$freeShippingThreshold = $column[0]; // Value after which shipping is free
	$shippingCostPerItem =  $column[1];  // Shipping cost per book
	$paymentType = '3'; // 3 = Credit, 1 - Cash, 2 - Check
 
?>

<?php include("sha.php"); ?>

<?php

// Constants for the business
$url_tpvv='https://sis.sermepa.es/sis/realizarPago';
//$url_tpvv='http://wapdd.visa.es/sis/realizarPago ';
$clave='blahblahblahblah';  // Ds_MerchantSignature
$name='J and J Books and Coffee';
$code='blahblahblah';  				// ds_merchantCode
$terminal='1';  				// 1 - Euros 	3 - dollars

// Create order number 1 larger than largest order number in database
 $database=mysql_pconnect('localhost','jandj_root');
 mysql_select_db('sales');
 $query="select MAX(referenceNum) as ID from jandj_jandj.sales";
 $result=mysql_query($query);
 $column=mysql_fetch_array($result);
 $orderNum=$column[0]+1;	// Make the new order number 1 larger than the largest reference number on file
 //
 

 
 $language='2'; 				// Ds_Merchant_ConsumerLanguage    2 - English  (1 - Spanish)
 $currency='978'; 				//  978 = Euros, (840 = dollars)

 $responseURL='http://www.jandjbooksandcoffee.net/paymentdenied2.php'; // makes no difference

?>

In the body -

<?php
	// Display main message
    // echo'<p>'.$message.'</p><p>&nbsp;</p>';
   
 	$right="right";
	$left="left";
	
	// Get the information on the selected book from the database
	$database=mysql_pconnect('localhost','jandj_root');
	mysql_select_db('books');
	$total = '0';
	
	if (count($selectedArray) > 0) {				// If the shopping cart is not empty...
		foreach ($selectedArray as $value) {      // For each book id in the shopping cart...
			// Get the book information
			$query="select * from jandj_jandj.books where id=".$value." and display='JJ' limit 1";
			$result=mysql_query($query);
			$column=mysql_fetch_array($result);
			$image=$column[7];
			$title=$column[1];
			$priceAct=$column[13];
			$pricePub=$column[12];
			$author=$column[3];
			$id=$column[0];
			
			$align = $left; 
		
			$total=$total+$priceAct;
		
			// Display the information of the selected book
			echo '<div id="book">	<p><font color="#006633" face="Geneva, Arial, Helvetica, sans-serif"><b>';
			echo $title; 
			echo '<br></b></font>
				<b><font color="#000000" size="1" face="Geneva, Arial, Helvetica, sans-serif">
				by '.$author.'
			   </font></b>
			   <br>
				<b><font color="#FF0000" size="2" face="Geneva, Arial, Helvetica, sans-serif">
				J &amp; J price: '.$priceAct.' &#8364;
			   </font></b>
		
				</p></div><hr>';
		 }  
		
		// Display the Subtotal
		echo '<p><font color="#00FF00"><b> Subtotal: '.number_format($total,2).' &#8364</b></font><br><br>';

		// Check to see if buyer qualifies for free shipping
		if ($total> $freeShippingThreshold) {
			$shippingcost = '0';
		} else {
			$shippingcost = count($selectedArray) * $shippingCostPerItem;
		}
		
		// Display totals			
		echo '<font color="#00FF00"><b>Shipping Fees: '.number_format($shippingcost,2).' &#8364</b></font></p>';
		$grandtotal = $total+$shippingcost;
		echo '<p><font color="#00FF00"><b> Total: '.number_format($grandtotal,2).' &#8364</b></font><br><br>';
		
		// Since the Caixa Cataluyna assumes that the last two digits are the decimals of the amount
		// multiply the grand total by 100 to make the last two digits represent the decimal part
		$amount = $grandtotal*100;  
		
		
	} else {  // if count($selectedArray) > 0
		// The shopping cart is empty
		echo '<font color="#006633" face="Geneva, Arial, Helvetica, sans-serif"><b>';
		echo "Your shopping cart is currently empty. <br><br>  "; 
		echo 'To add books to your shopping cart, go to the <a href="browse.php">Browse page</a> ';
		echo 'and select some of our titles.<br><br>';
		echo '</b></font><br>';
		exit;
	}
	
	 // Store the order number into the database so in case
	 // order is rejected for being a duplicate we don't end up
	 // using the same order number
	 $status= '1'; 									// 1 - placing the order
	 $_SESSION['sessionOrderNum'] = $orderNum;  	// Track the order number for when we return from Caixa Cataluyna

	 $submit="insert into jandj_jandj.sales values ('','".$customerID."',NOW(),'".$grandtotal."','".$paymentType."','".$status."','".$orderNum."')";
	 $result=mysql_query($submit);
	 // echo 'insert $result = '.$result.'<br>$submit='.$submit;
	if ($result)
	{
		// New sales record was created. Move along
	}
	else {
		echo 'A database error has occurred.  We were not able to generate a sales reference number for this transaction.
				Please contact <a href="mailto:info@jandjbooksandcoffee.com">info@jandjbooksandcoffee.com</a> or <b>91 521 85 76</b> for assistance.';
		exit;
	}

	echo 'To proceed with credit card authorization click on Charge to Credit.  You will be taken to 
		the Caixa Cataluyna credit authorization page.  Once the charge has been authorized or declined, 
		click on the <img src="images/close.gif" align="absmiddle"> button to proceed with the rest of the checkout procedure. 
		<b>It is very important that you use the <img src="images/close.gif" align="absmiddle"> button to proceed and not 
		close the window in any other fashion.  Otherwise the order may be delayed or cancelled.</b>';
	echo '<br>';
		
?>

	
	
<?php  // Submittal form
	echo "<form name=compra action=$url_tpvv method=post target=tpv>
		
			<input type=hidden name=Ds_Merchant_Amount value='$amount'>
			<input type=hidden name=Ds_Merchant_Currency value='$currency'>
			<input type=hidden name=Ds_Merchant_Order  value='$orderNum'>
			<input type=hidden name=Ds_Merchant_MerchantCode value='$code'>
			<input type=hidden name=Ds_Merchant_Terminal value='$terminal'>
			<input type=hidden name=Ds_Merchant_ConsumerLanguage value='$language'>
			<input type=hidden name=Ds_Merchant_MerchantURL value='$responseURL'>
				";
			// Compute hash to sign form data
			// $signature=sha1_hex($amount,$orderNum,$code,$currency,$clave);
			$sha = new SHA;
			$message = $amount.$orderNum.$code.$currency.$clave;
					
			$digest1 = $sha->hash_string($message);
			$signature = strtoupper ($sha->hash_to_string( $digest1 ));
					
	echo "<input type=hidden name=Ds_Merchant_MerchantSignature value='$signature'>
				
		  <a href='javascript:calc()'>Charge to Credit <img src='images/tpvirtual.jpg' width='50' height='50' border='1' ALT='TPV Virtual'></a>
		
		</form>";
?>

Thanks,


M
Code now, you'll get all the sleep you need when your Dead!!

#4 modigy

modigy
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts
  • LocationMadrid, Spain

Posted 12 October 2006 - 01:14 PM

Hi All,

I could really use some help with this problem.  Please let me know if I haven't given enough information, the topic is inappropriate for this particular forum, etc. 

Thanks,


M
Code now, you'll get all the sleep you need when your Dead!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users