?
Solved

how to change a session variable using PHP

Posted on 2009-05-10
4
Medium Priority
?
215 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

762 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