PayPal shopping cart button markup error? - php

I'm getting this error message when testing my Add to Cart functionality using PayPal.
PayPal is very misleading with what fields and values I should be using. For example it says the cmd field should have _cart as value if the button is an Add to Cart, but I've found a working example using -s_xclick (which doesn't work for me).
Here is my markup:
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Specify an Add to Cart button. -->
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="add" value="1">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="Product Two">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="business" value="HY3MQABS97HT">
<span>£200</span><input type="hidden" name="amount" value="200"> <!-- <input type="image" name="submit" border="0"src="https://www.paypal.com/en_US/i/btn/btn_cart_LG.gif"alt="PayPal - The safer, easier way to pay online"> -->
<input type="image" name="submit" border="0" src="http://www.karenrothwell.com/wp-content/themes/twentyten/images/addToBasketSmall.png" alt="PayPal - The safer, easier way to pay online">
</form>
What am I missing that would cause it not work? All seems in order to me!

The business 'HY3MQABS97HT' is invalid. Is it perhaps for a Sandbox account? Then you'll need to change https://www.paypal.com/cgi-bin/webscr to https://www.sandbox.paypal.com/cgi-bin/webscr
Note: The difference between _cart and _s-xclick is that _cart is used for unencrypted buttons, and _s-xclick is used for 'hosted' buttons (details stored with PayPal).

This works for me: its the same fields that you are using, the difference is i've used my email address for business field replacing yours

Related

Paypal Button Not Working - We are sorry error

I am trying to integrate PayPal to my website. My requirement is that I want to pass a computer generated amount to PayPal to make payment of that amount.
But when I make payment using button , I am taken to website for payment, Where I login using sandbox account and make payment. But when I make payment I get a message saying
We’re sorry Things don’t appear to be working at the moment.
I searched about the possible problem's from similar questions asked and implemented the suggested fix's which is Hosting a button in a server and providing different parameters , But no luck. Here's the code I am using
<form
action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="**********#gmail.com">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="Product1">
<input type="hidden" name="item_number" value="1">
<input type="hidden" name="amount" value="10.00">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="rm" value="2" />
<!--in custom field add user id-->
<input type="hidden" name="custom" value="102">
<!-- Specify URLs -->
<input type='hidden' name='cancel_return' value='http://www.shreyash.tech'>
<input type='hidden' name='return' value='http://www.google.co.in'>
<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">
<img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form>
I have no idea what I am doing wrong here.
It looks the issue with your sandbox account. Would you please create your new sandbox seller and buyer test accounts and try again.
Here is the link for your reference to create PayPal sandbox account.

How to validate PayPal data with IPN when using non-hosted PayPal button

I am rather new to PHP and adding payment gateways
However, I want to learn and am having a go at a small shop with a Paypal buy now button which is linked to a PHP cookies cart
It is working fine and shows a list of the items in the cart, however I am worried it is not secure enough and someone could change the amounts or add their email address so that they receive funds
I would like to integrate the instant payment notification (IPN) : https://www.paypal.com/uk/cgi-bin/webscr?cmd=p/acc/ipn-info-outside
Do I need to do much more than follow the above instructions and make an IPN in the merchant account?
I am a bit confused about what the POST code means and how to integrate it into my button code
Please could someone explain what I need to change in my Paypal button code below so that I can make the payment system secure? I keep breaking it
<form action="https://www.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="item_name_1" value="Something Cool">
<input type="hidden" name="quantity_1" value="5">
<input type="hidden" name="amount_1" value="1"-->
<?php
$i = 0;
foreach (json_decode($_COOKIE['cart_items_cookie']) as $key => $value) {
$i++;
echo '<input type="hidden" name="item_name_'.$i.'" value="'.$value->name.'">';
echo '<input type="hidden" name="amount_'.$i.'" value="'.$value->price.'">';
}
?>
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="me#mysite.com">
<input type="hidden" name="item_name" value="Order#21874">
<input type="hidden" name="currency_code" value="GBP">
<!--<input type="hidden" name="amount" value="<?php //echo $_GET['total'];? > "> -->
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
<input type="image" src="https://www.paypalobjects.com/en_US/GB/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.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
Any help or point in the right direction much appreciated!
The best thing to do would be to use the Express Checkout API instead of Payments Standard (HTML forms). This requires more programming and working with API calls, however, I have a PayPal PHP class library you can use to make all of the calls very quick and easy for you.
Express Checkout completely hides everything about the payment and it has a lot more features available to it than Standard does.
If you want to stick with Standard, you can build a hosted button by creating the button from within your PayPal account, and make sure to select the option to "Save the button at PayPal." That is what makes it hosted.
Then you'll still get HTML to paste into your site where you want the payment button to show up, but it will only have a few lines, and one of those lines will show a "hosted_button_id".
This secures the button from tampering like you mentioned, but it limits customization you can do with your checkout in general.

PHP:How to add credit card method option in paypal?

I have been working on paypal integration gateway in php. I have taken some tutorials from google. Now I want to add some credit card option via paypal like (visa, mastercard etc). Kindly guide me that how to add this functionality in php
Here is simple html form
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="businesstest541#shop.com">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="Hot Sauce-12oz Bottle">
<input type="hidden" name="amount" value="5.95">
<input type="hidden" name="currency_code" value="USD">
<!-- Display the payment button. -->
<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">
<img alt="" border="0" width="1" height="1"
src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form>
To process cards on your own site, you'd need to use one of the Pro or Braintree options listed here.

paypal buy now button with redirection after success

I am creating a website where there will be a lot of digital products with variety of product prices. I went to paypal and created a button.
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="W6HILXXVHKYZBY">
<input type="image" src="https://www.paypalobjects.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.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
They price is predefined when creating the button. And also I want the users to be redirected to a success in my website after the payment is complete. The above code works in live environment but in sandbox it gives error. PLUS it is not what I require.
I want something like this
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="accounts#mydomain.com">
<strong>How much do you want to pay?</strong><br />
$ <input type="text" name="amount" value="30" readonly="readonly">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="AU">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="hidden" name="return" value="http://net.mydomain.com/payment-complete/">
<br /><br />
<input type="submit" value="Pay with PayPal!">
</form>
Everything in this code works, but it wont redirect to my success page automatically.
There are some conditions for it to work correctly. you can read them here on the PayPal Developers website.
Here is the Note from PayPal about Auto Return:
If you have turned on Auto Return and have chosen to turn on PayPal Account Optional for new users, a new user will not be automatically directed back to your website, but will be given the option to return.
The Return URL will be applied to all of your Auto Return payments unless otherwise specified within the button or link for that Website Payment. You may specify a different Return URL by changing it in your profile settings; otherwise, you may add or edit the HTML (variable: return) associated with a button or link. In this case, the Return URL that is associated with the button or link will override what was specified in the profile settings.
Firstly, your live account credentials are different from sandbox credentials. Check that you are using the right account email.
Secondly, as Prakash-GPz said, you should enable auto return in your sandbox account also in order to be redirected to success page.

Adding item total to PayPal's order summary, for full aggregate cart payment

I've got my own shopping cart and everything set up, I just need a "Pay Now" button for my website users, and I just intend to send the entire cart's total amount up to payPal, that's it, no other integration necessary. So the customers on my website have already reviewed their order, checked quantities and shipping charges etc for individual items, and now PayPal just needs to be given the total amount which they will confirm and pay.
My code for the "Pay Now" button is below ($overall_total has already been calculated somewhere above in my php code):
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="JRECLRTYAJDKY">
<input type="hidden" name="amount" value="<?php echo $overall_total;?>">
<input type="hidden" name="item_total" value="<?php echo $overall_total;?>">
<input type="hidden" name="item_name" value="Your Shopping order">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynow_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
The user submits this form when they hit "Pay Now", and they come to next page. But Even though I included the amount and item_total variables, the next page gives me an item_total of 0.00. Also, I don't want any Quantity or Item price to show since I am simply implementing an aggregate cart payment for customers, and they have already reviewed per item charges before coming to the payment. This is what I get:
How can I get rid of Quantity and Item price, and have the $overall_total value that I calculated inside the total price on the PayPal summary?
there is no item_total or any total, since every single button handles ONE item at once
$overall_total must be in the english format with "." as decimals separator
problem may be the cmd parameter.. use instead:
<input type="hidden" name="cmd" value="_xclick">
also you need to specify:
<input type="hidden" name="business" value="yourBusiness#yourBusiness.tld">
look at this for a more complete example:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="yourBusiness#yourBusiness.tld">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="amount" value="10.10">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="item_name" value="Item bought desc">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_paynow_SM.gif:NonHostedGuest">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynow_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
also have a look at:
the documentation of cart parameters: HTML Form Basics for PayPal Payments Standard
the cart button builder: Create a PayPal payment button
about the "quantity" issue, sadly you can't hide it... if this is an important issue for you, you could try instead the ExpressCheckout (using php) which is very customizable and not that difficult to implement
hoping to be helpful
The most straightforward way to get around the Qty:1 issue of simple 'Pay Now' buttons is to implement 'Cart Upload' instead, which is how 99% of shopping carts implement Standard. See: PayPal's Cart Upload Documentation
If you are a programmer who can handle API calls, I instead recommend using Express Checkout (perhaps with SOLUTIONTYPE=Sole) rather than a Standard form post like Cart Upload. EC is a more robust interface to program against and essentially a free upgrade to Standard that's available to all PayPal seller accounts.

Categories