I have been on this for a long time now but am unable to figure out the error no matter what I try.
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="sales#mysite.co.uk">
<?php
$result = mysqli_query($DB, "SELECT * FROM salestemp WHERE id = '".$_REQUEST['sid'].
"' ") or die("Error: ".mysqli_error($DB));
$counter = 0;
while($row = mysqli_fetch_array($result))
{
$counter++;
?>
<input type="hidden" name="item_name_<?php echo $counter; ?>"
value="<?php echo urlencode($row['name']); ?>">
<input type="hidden" name="ammount_<?php echo $counter; ?>"
value="<?php echo urlencode($row['price']); ?>">
<input type="hidden" name="item_number_<?php echo $counter; ?>"
value="MD<?php echo urlencode($row['pid']); ?>">
<input type="hidden" name="quantity" value="1">
<?php
}
?>
<input type="hidden" name="currency_code" value="GBP">
<!-- Enable override of buyers's address stored with PayPal . -->
<input type="hidden" name="address_override" value="1">
<!-- Set variables that override the address stored with PayPal. -->
<input type="hidden" name="first_name" value="John">
<input type="hidden" name="last_name" value="Doe">
<input type="hidden" name="address1" value="345 Lark Ave">
<input type="hidden" name="city" value="San Jose">
<input type="hidden" name="state" value="CA">
<input type="hidden" name="zip" value="95121">
<input type="hidden" name="country" value="US">
<input type="image" name="submit" border="0"
src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif"
alt="PayPal - The safer, easier way to pay online">
</form>
When submitting the form I am met with the "Error Detected: Your Cart Is Empty".
Can anyone help me at all please. Thank you very much in advance.
You have 'ammount' instead of 'amount'.
Related
I want to recieve payments from my customers via paypal. And i want to create a system auto confirmation for success/fail payments.
Now i created a function which is below. But when I click to buy button. It redirects to me paypal sanbox page. But i recieve a message like that
Your purchase couldn't be completed
There's a problem with the merchant's PayPal account. Please try again later.
What is the problem ? I'm newbie on Paypal.
public function paypal($products) {
?>
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="paymentaction" value="authorization">
<input type="hidden" name="charset" value="utf-8">
<input type="hidden" name="business" value="cihankusmez#facebook.com">
<input type="hidden" name="currency_code" value="TRY">
<input type="hidden" name="return" value="<?php echo BASE_PATH; ?>paypal.php?do=success">
<input type="hidden" name="cancel_return" value="<?php echo BASE_PATH; ?>paypal.php?do=fail">
<input type="hidden" name="first_name" value="John">
<input type="hidden" name="last_name" value="Doe">
<input type="hidden" name="address1" value="9 Elm Street">
<input type="hidden" name="address2" value="Apt 5">
<input type="hidden" name="city" value="Berwyn">
<input type="hidden" name="state" value="PA">
<input type="hidden" name="zip" value="19312">
<input type="hidden" name="night_phone_a" value="610">
<input type="hidden" name="night_phone_b" value="555">
<input type="hidden" name="night_phone_c" value="1234">
<input type="hidden" name="email" value="jdoe#zyzzyu.com">
<input type="hidden" name="address_override" value="1">
<?php foreach ($products['fields'] as $key => $product) { ?>
<?php $i = $key + 1; ?>
<input type="hidden" name="item_name_<?php echo $i ?>" value="<?php echo strip_tags($product['stock_code']." - ".$product['product']); ?>">
<input type="hidden" name="amount_<?php echo $i ?>" value="<?php echo $product['wholesale_price']; ?>">
<input type="hidden" name="discount_rate_<?php echo $i ?>" value="<?php echo $product['discount_ratio'] ?>">
<input type="hidden" name="quantity_<?php echo $i ?>" value="<?php echo $product['total_quantity']; ?>">
<input type="hidden" name="tax_rate_<?php echo $i ?>" value="<?php echo $product['vat'] ?>">
<?php } ?>
<button id="paypal_button" type="submit" name="paypal_button" class="btn btn-success">
<span class="glyphicon glyphicon-shopping-cart"></span> <?php echo _('PAYPAL ile Satın Al'); ?>
</button>
</form>
<?php }
Check your account on PayPal and verify your sandbox account and apps are there.....mine are gone and hence the error.
this my ipn.php
In my log error file I have reciving this message: Invalid response status: 302
And Im reciving the mail from inside "exception" code, someone know why ? I dont have idea why is failing... Please, I need help!!
Thank you very much
<?php
ini_set('log_errors', true);
ini_set('error_log', dirname(__FILE__).'/ipn_errors.log');
include '../../modelo.php';
include('ipnlistener.php');
$listener = new IpnListener;
$listener->use_sandbox = true;
$listener->use_ssl = false;
$verified = $listener->processIpn($my_post_data);
try {
// $listener->requirePostMethod();
$verified = $listener->processIpn();
mail('mymail#gmail.com', 'TRY ok', 'ok');
} catch (Exception $e) {
error_log($e->getMessage());
mail('mymail#gmail.com', 'Exception', 'nok');
exit(0);
}
mail('mymail#gmail.com', 'final del script', 'include');
?>
And this is my html code:
<form name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="myemailpaypal#yopmail.com">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="item_name" value="<?php echo $product;?>">
<input type="hidden" name="amount" value="<?php echo $amount;?>">
<input type="hidden" name="return" value="http://www.myweb.com/thankspage.php">
<input type="hidden" name="custom" value="<?php echo $bookcode; ?>">
<input type="hidden" name="notify_url" value="http://www.myweb.com/ipn.php">
<input type="image" src="http://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif"
border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
$listener->use_ssl = true;
sandbox needs ssl
I want to add have tax set on individual items with Paypal. For example, I want "One $1" to have tax # 12% whilst the remaining "Two $2", "Three $3", "Four $4" and "Five $5" to have tax at 5%.
<option value="">--- Or Select a Type of Service ---</option>
<option name="tax_1" value="One $1">Hello $20</option>
<option value="Two $2">Bye $30</option>
<option value="Three $3">Tata $45</option>
<option value="Four $4">Bonjour $40</option>
<option value="Five $5">Au Rrevoir $30</option>
Therefore, I use on the form action:
<input type="hidden" name="tax_rate" value="12">
<input type="hidden" name="tax_1" value="6">
But it doesn't work for 6% tax for "One $1". How would I be able to make it work?
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="pointblanc#hotmail.com">
<input type="hidden" name="item_name" value="<?php if($tutorial_type!="") echo $tutorial_amount_arr[0]; else echo "Gift Certificate" ?>">
<input type="hidden" name="item_number" value="Gift Certificate">
<input type="hidden" name="amount" value="<?php if($amountfull="") echo $tutorial_amount_arr[1]; else echo $tutorialamnt; ?>">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="CAD">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="tax_rate" value="12">
<input type="hidden" name="tax_1" value="6">
<input type="hidden" name="return" value="http://www.testtest.com/thankyou.php">
<input type="hidden" name="cancel_return" value="http://www.testtest.com">
<input type="hidden" name="notify_url" value="http://www.testtest.com/ipn.php"/>
<input type="image" border="0" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" align="center" style="margin-right:7px; margin-left:150px">
<input type="hidden" name="custom" value="<?php echo $allcontens; ?>"/>
</form>
small problem with this old paypal button code..
I am trying to get the os0 and os1 to POST back with this script.. I am getting the amount and name, but that is all .. ?
Thanks!
I have a Simple form:
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" style="float:left; width:49.9%">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_cart_SM.gif" border="0" name="submit" alt="description">
<img alt="description" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
<input type="hidden" name="add" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="mm#mm.com">
<input type="hidden" name="item_name" value="Digital Image (Download ONLY)">
<input type="hidden" name="amount" value="6.00">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="cancel_return" value="http://www.website.com/store/sorry.php">
<input type="hidden" name="return" value="http://www.website.com/store/thank_you.php">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="bn" value="PP-ShopCartBF"><!--<br />
Phone Number:<input type="text" name="on1" maxlength="60">-->
<table><tr><td><input type="hidden" name="on0" value="Photo ID"></td>
<td><input name="os0" type="hidden" value="{name}" size="40" maxlength="200"></td></tr><tr><td>
<input type="hidden" name="on1" value="Thumbnail preview"></td>
<td><input name="os1" type="hidden" value="{image_url}/{name}" size="40" maxlength="200"></td></tr></table>
</form> <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" style="float:left; width:49.9%">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="mm#mm.com">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_viewcart_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<input type="hidden" name="display" value="1">
</form>
Once the user buys the product, they auto return w/ PDT enabled and I am trying to get back the variables os0 and os1 -- but nothing is coming back.
I get the amount and the first and last name, but not the option_selection1 or 2 ??
Here is my return script: ( I was trying different variables to see.. but nothing ? )
$firstname = $keyarray['first_name'];
$lastname = $keyarray['last_name'];
$option_name1 = $keyarray['option_name1'];
$option_name2 = $keyarray['option_name2'];
$custom = $keyarray['option_selection1'];
$os1 = $keyarray['os1'];
$option_selection2 = $keyarray['os2'];
$on1 = $keyarray['on1'];
$on2 = $keyarray['on2'];
$os1 = $keyarray['os1'];
$os2 = $keyarray['os2'];
$amount = $keyarray['payment_gross'];
echo ("<p><h3>Thank you for your purchase!</h3></p>");
echo ("<b>Payment Details</b><br>\n");
echo ("<ul><li>Name: $firstname $lastname</li>\n");
echo ("<li>Item: $option_name1</li>\n");
echo ("<li>Item Name: $option_name2</li>\n");
echo ("<li>Item Name 2: $option_selection1</li>\n");
echo ("<li>Item Name 2: $option_selection2</li>\n");
echo ("<li>Item: $custom</li>\n");
echo ("<li>Item: $on1</li>\n");
echo ("<li>Item Name: $on2</li>\n");
echo ("<li>Item Name 2: $os1</li>\n");
echo ("<li>Item Name 2: $os2</li>\n");
echo ("<li>Amount: $amount</li></ul>\n");
echo ("");
}
else if (strcmp ($lines[0], "FAIL") == 0) {
// log for manual investigation
}
Hi did you ever resolve this issue? I have just begun to create a pdt for my website and based on what I have learnt: 'option_name1' will pull the 'on0' label from your form, 'option_name2' will pull the 'on1' label, etc. same with 'option_selection1' (pulls the information entered in the 'os0' text field box) and 'option_selection2'.
So far I've only tried it in the sandbox environment, but I've found https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_IPNandPDTVariables to be useful.
I want to send multiple item names and item prices to PayPal but I am unable to post my item name and price with below code can you please help me?
<form method="post" name="cart" action="https://www.sandbox.paypal.com/cgi-bin/webscr">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="navive_1295939206_biz#gmail.com">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="notify_url" value="http://newzonemedia.com/henry/ipn.php" />
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
<input type="hidden" name="return" value="http://www.example.com/thank_you_kindly.html" />
<?php
//select items for table
$srowcart_dtl = mysql_num_rows($srscart_dtl);
if($srowcart_dtl > 0) {
$cnt=1;
while($srscart_dtl1 = mysql_fetch_assoc($srscart_dtl)) {
?>
<input type="hidden" name="item_name[<?php echo $cnt ?>]" value="<?php echo $srscart_dtl1['cart_iname']; ?>">
<input type="hidden" name="amount[<?php echo $cnt ?>]" value="<?php echo $srscart_dtl1['cart_iprc']; ?>">
<?php
$cnt++;
}
}
?>
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
Create your code like this:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart"> <!-- change _xclick to _cart -->
<input type="hidden" name="upload" value="1"> <!-- add this line in your code -->
<input type="hidden" name="business" value="your_seller_account">
<input type="hidden" name="item_name_1" value="Item Name 1">
<input type="hidden" name="amount_1" value="1.00">
<input type="hidden" name="item_name_2" value="Item Name 2">
<input type="hidden" name="amount_2" value="2.00">
<input type="submit" value="PayPal">
</form>
In addition to the changes suggested by devilprince, the underscores are missing from the line item input tags' name attributes, and also the tags are not proper self-closing tags because the closing / is missing. Correct like so:
<form method="post" name="cart" action="https://www.sandbox.paypal.com/cgi-bin/webscr">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="navive_1295939206_biz#gmail.com">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="notify_url" value="http://newzonemedia.com/henry/ipn.php" />
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
<input type="hidden" name="return" value="http://www.mysite.org/thank_you_kindly.html" />
<?php
// select items for table
$srowcart_dtl = mysql_num_rows($srscart_dtl);
if($srowcart_dtl > 0)
{
$cnt=1;
while($srscart_dtl1 = mysql_fetch_assoc($srscart_dtl))
{
?>
<input type="hidden" name="item_name_[<?php echo $cnt ?>]" value="<?php echo $srscart_dtl1['cart_iname']; ?>"/>
<input type="hidden" name="amount_[<?php echo $cnt ?>]" value="<?php echo $srscart_dtl1['cart_iprc']; ?>"/>
<?php
$cnt++;
}
}
?>
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
(You may also want to escape special characters in the value attribute, at least for the " character in case it shows up in your item name data.)
Just had to figure this out today for a client. Besides item_name_N and amount_N I also used quantity_N, tax_N, and shipping_N (where N is the line item number, starting with 1).
This page has a list of all parameters: PayPal HTML Form Variables, but the question & answers given here are a better real-world example than the trivial examples on the PayPal site.