• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 218
  • Last Modified:

how to change a session variable using PHP

Hi,

I have an order form that passes a price including shipping to Paypal. PayPal then confirms the user, determines the address, and returns the amount and address to a confirmation page form. From this page the user hits submit and the amount is passed and the transaction gets completed.

If the user has a California shipping address I have a function on the confirmation page that calculates the tax. The problem is I cannot get the newly tax calculated total passed in the final phase of the order process. So when he user hits submit from the order confirmation page the amount without the tax gets passed, not the amount with the tax that has been calculated.

This is the 4 steps of my order process.

Price page > Paypal > confirmation Page > Transaction complete page

The problem is, the Price generated at the Price page stays in the URL during the whole transaction. I need to change it at the Confirmation page and pass the new amount in the URL to the Transaction complete page.

Below is the code that I don't understand that I am hoping I can modify.


<!-- confirmation page -->
 
<!-- this is the tax calculation function, nothing wrong here, I just included it for explanation purposes -->
 
$caltax = (($_REQUEST['paymentAmount'] - $_REQUEST['SHIPPINGAMT']) * 0.0925);
 
if ($resArray['SHIPTOSTATE'] == 'CA')
{
$_REQUEST['paymentAmount'] = ($_REQUEST['paymentAmount'] + $caltax);               
}
 
<!-- this is the price variable who's value want to change but cannot figure out how to-->
 
$_SESSION['paymentAmount']=$_REQUEST['paymentAmount'];
 
<!-- Transaction complete page  -->
 
$paymentAmount =urlencode ($_SESSION['paymentAmount']);
 
<!-- This is the code that passes the final amount to complete the transaction  -->
 
$nvpstr='&TOKEN='.$token.'&PAYERID='.$payerID.'&PAYMENTACTION='.$paymentType.'&AMT='.$paymentAmount.'&CURRENCYCODE='.$currCodeType.'&IPADDRESS='.$serverName ;

Open in new window

0
jackie777
Asked:
jackie777
  • 2
  • 2
1 Solution
 
NeoDiffusionCommented:

Hello jackie777,

So far I remember, $_REQUEST['paymentAmount'] and $paymentAmount are two different variables, even if initially containing the same values. Meaning that if $_REQUEST['paymentAmount'] is modified but $paymentAmount is sent back, the original value is sent back, not the modified one (assuming the register global variable are still ON).

So, either do (in the confirmation page):
$paymentAmount = ($_REQUEST['paymentAmount'] + $caltax);  


or change the URL string to contain the modified value.

Rgds,

Werner.
0
 
jackie777Author Commented:
Thanks,

I wasn't getting that they were two different variables, so that was very helpful.

How would I change the URL string to contain the modified value?
0
 
NeoDiffusionCommented:
Just do the change proposed above:
$paymentAmount = ($_REQUEST['paymentAmount'] + $caltax);  

replacing
$_REQUEST['paymentAmount'] = ($_REQUEST['paymentAmount'] + $caltax);              

Rgds,
Werner.
0
 
jackie777Author Commented:
Thanks!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now