Solved

how to change a session variable using PHP

Posted on 2009-05-10
4
211 Views
Last Modified: 2012-05-06
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
Comment
Question by:jackie777
  • 2
  • 2
4 Comments
 
LVL 10

Expert Comment

by:NeoDiffusion
ID: 24349280

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
 

Author Comment

by:jackie777
ID: 24349579
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
 
LVL 10

Accepted Solution

by:
NeoDiffusion earned 500 total points
ID: 24349676
Just do the change proposed above:
$paymentAmount = ($_REQUEST['paymentAmount'] + $caltax);  

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

Rgds,
Werner.
0
 

Author Closing Comment

by:jackie777
ID: 31579936
Thanks!
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question