Paypal Button Not Working - We are sorry error - php

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.

Related

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.

How to transform PayPal Classic Payment form into PayPal REST API PHP Application?

The following is the simplest PayPal interface form:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" />
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="JohnDoe2#example.com" />
<input type="hidden" name="item_name" value="Purchase at the Virtual Store" />
<input type="hidden" name="item_number" value="Organic-001" />
<input type="hidden" name="amount" value="17.4" />
<input type="hidden" name="currency_code" value="EUR" />
<input type="hidden" name="notify_url" value="http://www.example.com/paypalnotify.php" />
<input type="submit" name="submit" value="Pay now By PayPal" />
</form>
This form is specific to a PayPal premier business account and a given amount to pay, with following key parameters:
business=JohnDoe2#example.com.
amount=17.4EUR.
currency_code=EUR or USD.
notify_url as the callback for PayPal.com as it ends.
By clicking on the [submit] button, it perfoms this:
It redirects the customer to the paypal.com site.
The user will login into her/his PayPal account, and validate the payment.
The PayPal site will call the paypalnotify.php like a callback, passes information indicating if the payment has suceeded, cancelled, or not valid...
Now in the new interface using PalPal REST API, using PHP development kit, how one has to proceed to accomplish the payment ?
There are a few options. Start by looking at the code in these files:
https://github.com/paypal/rest-api-sdk-php/blob/master/sample/payments/CreatePayment.php
https://github.com/paypal/rest-api-sdk-php/blob/master/sample/payments/CreatePaymentUsingPayPal.php
Obviously they don't have any interactive forms, but they show the general process. Dig in and work through creating your code. Then when you hit problems, open a new question with the specific issues. StackOverflow is not for "how do I" type questions. https://stackoverflow.com/help/on-topic

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.

PayPal shopping cart button markup error?

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

Categories