Page 1 of 1

dynamic price with paypal

Posted: Mon Jul 06, 2009 8:58 am
by isaac_cm
Hello,
I read many script from web sites about this but it did not solve my problem, I need to pass a single item to paypal but with dynamic price

so I write a javascript function like this

Code: Select all

function CalculateOrder(form){
  
        document.form.amount.value = <?php echo $FinalTotal + $k_no; ?>;
    
      }
and in onclick event I call this function

Code: Select all

                           <input type="image" src="https://www.paypal.com/DE//LG.gif" border="0" name="submit"  style="width:160px" onClick="CalculateOrder(this.form)">
 
but I get sometimes error that the amount variable is not correct , or no error but I see a bank edit box in the paypal checkout page instead of the total I want

any solution to this ?

Thanks

Re: dynamic price with paypal

Posted: Mon Jul 06, 2009 9:17 am
by onion2k
Is "document.form.amount.value = <?php echo $FinalTotal + $k_no; ?>;" supposed to calculate the form amount based on the values that the user enters into the form? Coz you can't do that. You need it to be entirely Javascript... no PHP.

Re: dynamic price with paypal

Posted: Mon Jul 06, 2009 12:35 pm
by isaac_cm
but php variables hold the values , the values are crom from a post form in a previous page and I read it with $_REQUEST

I see now I can store all $_REQUEST into session and read session variables from javascript, right ? is there any other way ?

thanks

Re: dynamic price with paypal

Posted: Mon Jul 06, 2009 5:10 pm
by isaac_cm
never mind it work but I need now to prevent price change

Re: dynamic price with paypal

Posted: Thu Jul 09, 2009 1:27 pm
by Jonah Bron
readonly="true" is what you're looking for. Apply it to document.form.amount. Or, you can use a hidden element instead of a text element.

Re: dynamic price with paypal

Posted: Thu Jul 09, 2009 1:30 pm
by arjan.top
Jonah Bron wrote:readonly="true" is what you're looking for. Apply it to document.form.amount. Or, you can use a hidden element instead of a text element.
that won't prevent nothing

Re: dynamic price with paypal

Posted: Thu Jul 09, 2009 2:37 pm
by isaac_cm
yes I think the only way is encryption or review each sale and cancel frauds