Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

PayPal paynow button price from variable

Thread began 4/02/2010 10:36 pm by JBWebWorks | Last modified 12/28/2011 3:00 pm by wombat.56339078 | 4938 views | 9 replies |

JBWebWorks

PayPal paynow button price from variable

I am wondering if you can get the price for a paypal buy now button from a hidden field on a previous page form that redirects to the page with the paypal buy now button.

I tried this in the price input on the paypal form
<input type="hidden" name="amount" value="<?php echo((isset($_POST["hiddenFieldad_price"]))?$_POST["hiddenFieldad_price"]:"") ?>" />

It didn't work. When taken to paypal it has no price and a text field for the user to enter a price.

thanks for your help,
Jim Balthrop

Sign in to reply to this post

Jason ByrnesWebAssist

It is possible to do what you are describing.

To be able to tell why the code you supplied is not working, I would need to see the page in action, please send a link where I could see you page.

Sign in to reply to this post

JBWebWorks

Jason

The page with the paypal buy now button
paypal_vehicle.php

The page that fills the hiddenfield with the amount
sell_your_vehicle02.php

The page with the form that has the hidden field with the amount and redirects to the paypal page
sell_your_vehicle03.php

The form has some validation

thanks for your help

Sign in to reply to this post

JBWebWorks

Jason,

I got it to work with a session variable

PayPal input is this

<input type="hidden" name="amount" value="<?php echo $_SESSION['vehicle_adprice']; ?>" />

Added the session start code at the top of page
<?php if(!session_id()) session_start(); ?>

Would it matter if i did not have the session start code when trying to get the information
like this? (which i couldn't get to work)
<input type="hidden" name="amount" value="<?php echo((isset($_POST["hiddenFieldad_price"]))?$_POST["hiddenFieldad_price"]:"") ?>" />


thanks for your help,
Jim Balthrop

Sign in to reply to this post

Jason ByrnesWebAssist

when a form posts, the information is available only while the action page is loading. Once the action page has finished loading or redirects to another page, the form information is no longer available.

since your page at sell_your_vehicle03.php posts to itself, then redirects to the sell_your_vehicle02.php page, the form data is lost when the redirect occurs.

using the session variable is the only way to be able to pass the value between the two pages.

Sign in to reply to this post

tiziano.demaria432868

I have the same problem

Hello,

i have the same issue and I'm not able to get out

I give you here the example of the code. Many "values" are given by PHP variables.

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="item_name" value="$product_name" />
<input type="hidden" name="item_quantity" value="$quantity" />
<input type="hidden" name="amount" id="item_price" value="$basket">
...
...
</form>

the value on $basket depends from the choices of the client. Checking the page source once shown in the browser, the value of $basket is correctly shown.

At this point if you click on PayNow, all the data are passaed correctly eccept "$basket". I mean, the page of PayPal shows an empty input field where the client can write what she wants.

Anybody can help me please?

Sign in to reply to this post

Jason ByrnesWebAssist

please post a link where i can see the problem.

Sign in to reply to this post

tiziano.demaria432868

Originally Said By: Jason Byrnes
  please post a link where i can see the problem.  


Hello Jason

The site is protected by password in this moment, because it's under development.
Anywhow I worked all the night to solve this issue.

I found it a couple of hours ago. The fault was mine.
I was using a created PayPal button, using the code that PayPal assigns to the buttons.

The fact is that, with their buttons, I cannot assign a value to that field from my website.
When I use their button , I have to fix the parameters in their form, and I'm not allowed to use anything else.

The solution was and is: to avoid their buttons.
Just creating the form as I published in my first message here, I can use all the parameters I want, and these are created by several functions in the website itself.
I didn't know that, that's why I was creating confused things.
I'm sorry for my mistakes.

A "mistery" stays the return page.
Indeed in this case, if I write:

<input type="hidden" name="return" valuer="http://www.mysite.com/return_page.php" />

PayPal appends in GET (I wanted in POST but I have not clue how to do it) some flag,
like:

http://www.mysite.com/return_page.php?tx=36T195469W138745N&st=Completed&amt=10.45&cc=EUR&cm=&item_number=2



while if I want to have added some my flags to the one of PayPal, like this example:

<input type="hidden" name="return" value="http://www.mysite.com/return_page.php?sid=$sid&type=$type" /> where $sid and $type are generated by my PHP script, what I get back is something like:

http://www.mysite.com/return_page.php??sid=20&type=tapes



and PayPal doesn't add anything like it should. Indeed I expected to have back:

http://www.mysite.com/return_page.php??sid=20&type=tapes&tx=36T195469W138745N&st=Completed&amt=10.45&cc=EUR&cm=&item_number=2



but it doesn't :-(

Sign in to reply to this post

Jason ByrnesWebAssist

paypal does not allow you add variables to the return URL.

Sign in to reply to this post

wombat.56339078

to tiziano - regarding passing data from form to thank-you page

"...tx=36T195469W138745N&st=Completed&amt=10.45&cc=EUR&cm=&item_number=2..."

If you include the data in the pay now button form hidden tag "custom" value the data will be returned in the "cm=" NVP.

If the data is multi field then simply include a separator between fields (ie use "|" char is common... something that won't appear in the field values).

Then simply expand the "custom" ("cm") value in to each item value by splitting with the (ie) "|" char again when received via GET in the thank-you page.

The query string you receive (above) is correct and safe. It is supplied that way so a basic thank-you page can be dynamically created with minimal info.

BUT to then capture a confirmed UN-TAINTED (secure and correct) full transaction record your dynamic page must use the "tx" value with your PDT key in a handshake with the PP server which once confirmed legit will return the transaction record in full ending the handshake with a POST data stream which your dynamic PDT page can then parse as desired.

Whether you receive the PDT query string (above) and subsequent POST data stream, or nothing, or a simple get query string, depends on your PP profiles PDT setup. It is complicated to follow on the PP site PDT page help info I know but I think yours appears to be set OK for as I explained.

**So, try using the "custom" hidden tag embedded with the carry-over data and it will be sent to your thank-you page post payment in the "cm" NVP.

PS NEVER rely on the full PDT process to update dbs etc with the transaction record captured this way, only for display purposes. It is on record many payers simply surf on elsewhere from the PP payment results page, or their browser / ISP connection crashes and consequently the PDT (thank-you page) db record parsing never takes place (USE THE DISCREET IPN process ALSO to reliably do that seconds before hand).

Hope that helps some bod.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...