Link to home
Start Free TrialLog in
Avatar of crescue
crescue

asked on

How to send a php varaible to paypal amount buy it now

I have a php file to do some calculations and I want to pass the result to a paypal button (amount)  I have tried by several ways with no result.  I keep getting amount error

I am attaching the htm and php files

I want to be able to send the amount via paypal button

Tnx
testhtm.htm
calc.php
Avatar of Andrew Angell
Andrew Angell
Flag of United States of America image

You aren't echoing the amount.
<input type="hidden" name="amount" value="<?php $total_tax; ?>">

Open in new window


Needs to be:

<input type="hidden" name="amount" value="<?php echo $total_tax; ?>">

Open in new window

Avatar of crescue
crescue

ASKER

I had tried w echo and not echo. I just changed to the way you suggested and I still get the error :

https://www.paypal.com/webapps/shoppingcart/error?flowlogging_id=f2f3c3d887205&code=AMOUNT_ERROR
What is the URL of the page that you're displaying the button on?
Avatar of crescue

ASKER

scalpscreen.net/testhtm.htm

I had attached the 2 files in my prev questions
So when we view source on that page we're actually seeing the PHP in the field value...

<input type="hidden" name="amount" value="<?php echo $total_tax; ?>">

Open in new window


This is because the page is a .htm page.  You need to be running PHP.
Avatar of crescue

ASKER

Ok, I thought I can save it as htm from a previous comment, but I just saved the page as php and NOW it is going a little bit better but still not sending the price.  I get a screen OPEN BUTTON, and it is requesting to enter price in the paypal page, so I guess the price is still blank

my calc.php is : I have tried $total_total, $shipping, $price, price with no dollar sign and still the same

<?php
$price = 10.00;
$qty = filter_input(INPUT_POST, "qty");
$total_price = 0;
$total_tax = 0;
if (isset($qty)){
      $shipping = $qty <= 4 ? 9.95 : 12.95;
      $total_price = number_format(($price * $qty),2);
      $total_tax = number_format($total_price*.0825,2);
      $total_total = number_format($total_price+$total_tax+$shipping,2);
}
echo json_encode(array(
  "price" => $total_price,
  "tax" => $total_tax,
  "shipping" => $shipping,
  "total" => $total_total,
));
So as I did previously, you need to look at the actual output in the browser and see what value is coming out.
Avatar of crescue

ASKER

Yes I do look at the output, but I don't see any value I just see :

https://www.paypal.com/webapps/shoppingcart?flowlogging_id=c3432ad321ba8&mfid=1500242671689_c3432ad321ba8#/checkout/openButton

How or where does the testphp file knows that needs to look in calc.php ?
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.