I'm trying to integrate PayPal on my site and I have problems with receiving information from PayPal about transaction.
I'm using sandbox environment for tests.
I generated the form and placed return url into there:
<input type='hidden' name='return' value='my-local-site/success.php'>
After all payments are done (and they are done correct - I'm getting money to my account) I'm returned to my-local-site/success.php without any parameters about this transaction.
I tried to make it like here - http://www.dollarfry.com/paypal-integration-guide-php/ but it does not work for me.
My question is why I don't receive any information about transaction from PayPal as payments were done correctly via sandbox (money were sent from one account to another correctly).
I want to get some info like
http://my.local.site/success.php?tx=6BC88318RN685282M&st=Completed&amt=20.00&cc=USD&cm=&item_number=BEAR05
What should I do to get that info? Is something wrong I do, or with my account?
Thank you!
Try adding an extra parameter.
<input type="hidden" name="rm" value="0" />
Check PayPal's HTML variables documentation for more details. Search for "return method" on that page and you should find it easily.
Related
I have the IPN receiver on my server successfully receiving IPNs and re-posting them back to PayPal's server (https://www.paypal.com/cgi-bin/webscr) for validation. I am testing it using the IPN simulator and it always receives INVALID. So I've done the bulk of the work and got the servers talking. There's just a bit of fine polishing needed and I cannot debug this because I have no feedback. Where can I get this feedback?
PayPal's docs state the following:
"Check your IPN history on paypal.com.
Your IPN history tells you whether PayPal sent a given IPN message and whether your listener responded to it. This page may also provide information about the status of the server on which your listener is running. If necessary, you can request that PayPal re-send a given IPN message via the IPN history page."
-- https://developer.paypal.com/webapps/developer/docs/classic/ipn/integration-guide/IPNTesting/
So I need to find this IPN history, right? But what account are these IPN logs recorded? Do they definitely include IPNs generated using the simulator? If not what's the point and how does any dev debug? I've looked in the live merchant account, the sandbox merchant account, the sandbox payer account. But they all say there is no history of any IPNs being sent.
Just a side point: PayPal's sandbox is a nightmare because if you log out of one sandbox account you find yourself at the login page back on the live site. Similarly, you cannot login to the IPN simulator using a sandbox merchant account, only the live merchant account so you are forever having to login as live merchant to send the request, logout, login as sandbox, check the IPN history, find nothing, log back out, log in as live and repeat until you are insane. Then to further confuse things, the simulator sends IPNs from the address buyer#paypalsandbox.com SO MAKE UP YOUR MIND PAYPAL!!!! Is the IPN Simulator part of the sandbox or not? Once you have submitted one simulated IPN, it resets all the form values to defaults if you do need to enter an address of a valid sandbox payer account (The docs don't state whether or not you do, but I am cluching at straws here) you also have to copy and paste into boxes numerous times per request. Please please please PayPal, write you docs in a way that can be understood by someone who is not one of your colleagues. Explain what environment you need to be in at each stage of testing the IPN.
I am feeling very frustrated because this is not how development should be done. I am blindly trying things based on hunches, very unscientific and very inefficient.
Can anyone clarify (or point me to the part of the docs that clarifies) exactly how to debug INVALID responses please?
OK. After some significant time I have come to the following conclusions:
The IPN Simulator is NOT really part of the sandbox. It is useful for hitting quick lightweight tests to check PayPal's server can talk to yours but that is about it. It is far from a true payment process simulator! The solution to debugging your IPN validation process is to start the payment simulation process from the basket submission stage with a few very important values set to sandbox environment.
1) Firstly, log in to https://developer.paypal.com/ using your LIVE business account username and password. Click on Applications > Sandbox Accounts https://developer.paypal.com/webapps/developer/applications/accounts and create 2 sandbox accounts:
Create one Merchant/Business Sandbox Account, this is going to be our fake shop. For example alansugar#yourdomain.example.com
Then, create one Personal Sandbox Account, this is going to be our fake customer. For example ladygaga#yourdomain.example.com
We are going to use this fake shop and this fake customer to play in the sandbox...
2) Set up the basket page on your server (the one that submits to PayPal) with your Merchant/Business Sandbox account's address in the business field and PayPal's sandbox domain in the action property of the FORM element. Like so...
<form method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr">
<input type="hidden" value="_xclick" name="cmd">
<input type="hidden" value="alansugar#yourdomain.example.com" name="business">
<input type="hidden" value="1" name="no_note">
<input type="hidden" value="GBP" name="currency_code">
<input type="hidden" value="GB" name="lc">
<input type="hidden" value="PP-BuyNowBF" name="bn">
<input type="hidden" value="bo14-9097200" name="invoice">
<input type="hidden" value="monkey" name="custom">
<input type="hidden" value="A nice pair of trousers" name="item_name">
<input type="hidden" value="1" name="Some socks to match">
<input type="hidden" value="25.0" name="amount">
<input type="hidden" value="2" name="no_shipping">
<input class="buyButton" type="image" border="0" alt="PayPal – The safer, easier way to pay online." name="submit" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_buynowCC_LG.gif">
<img width="1" border="0" height="1" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" alt="">
</form>
3) Submit the basket and when you see the PayPal payment page (your browsers address bar will be accessing the www.sandbox.paypal.com domain) use your fake customer account to pay.
4) Log in to https://developer.paypal.com/ using your LIVE account. Click on Applications > Sandbox Accounts and click the Enter Sandbox site link. Now, whilst your browser is still logged into your main live account, you can kind of secondarily log in to a deeper layer using the sandbox accounts username and password (very confusing). Of course just to confuse you, the Username and Password boxes in the top right will be pre-populated with your live account's details. Wipe these and use the sandbox Merchant/Business account's username and password. Now click on History > IPN History and you can see the requests that were posted to your server. You should be able to debug nicely using this information. If IPN is not enabled on your Merchant/Business Sandbox Account yet it will give you instructions to go to a settings page and enable it. Do that. Obviously any payments before that point will not have triggered IPNs.
I hope this description helps anyone who, like me, found that the Official PayPal Docs read like a book with half the pages missing!
To access IPN notification history in PayPal sandbox, login at https://www.sandbox.paypal.com with your test merchant account.
Navigate to "My Account/Profile"
in "Selling preferences" section it has a link "Instant Payment Notification preferences"
On that page there is a link to "IPN History page".
I'm not sure if they recently have added this to the sandbox, but I agree it's pretty cumbersome.
I've got a scenario where I need to collect address details from Paypal when a user donates to a site. From what I can tell in the Paypal Sandbox those details aren't returned via IPN or PDT when the transaction is related to a donation.
Is there something I'm missing like an account setting or paypal variable that can make this possible?
At the moment I'm using a Buy Now option as below which does return address details:
input type="hidden" name="cmd" value="_xclick"
Simply changing the cmd to donation and the address info stops coming in via IPN:
input type="hidden" name="cmd" value="_donations"
I don't believe the address is given on donations. Your best bet is to call it a donation in the title & then send it still as an xclick. Change the displayed button image to a donation button, but use an xclick instead of _donation. I believe that's the only possible way.
I have a hosted PayPal form setup for a Subscribe button.
I send the return URL like so:
<input type="hidden" name="return" value="http://myurl.com/returnurl" />
This works fine, upon payment the user gets redirected to this URL.
I also send the item_number parameter like so
<input type="hidden" name="item_number" value="{{uid}}" />
{{uid}} is a template tag and I have verified when viewing the source code it is being filled correctly. For testing I was using uid 15.
When the user clicks the PayPal Subscribe button it takes them to the PayPal gateway. I have verified by using Developer Tools in Chrome that the correct uid (15 in this case) is being sent in the HTTP headers.
The problem is that all IPN notifications have the item_number 1 (I'm checking in the IPN history of the PayPal website, where it lists the parameters sent for each message.)
Can anyone think of why item_number is being sent as 1, and not the correct value?
Thanks
It appears item_number isn't always a variable you can set. When setting up a product to sell in the PayPal control panel you specify and item description and an item number. I'd setup the item_number of 1 and so even though I was setting it in my HTML <form> it was being overwritten by the item number I'd already setup.
The solution was to use a different custom field.
I'm testing a simple paypal paying script whisch works fine except that it's not calling my notify_url and I don't understand why. The url is reachable and even the sandbox IPN testing gives a positive result. Even stranger, on the same domain I have an other script that is working briliantly. Code is not identical, but it's using the same method.
This is the html of the form used to send paymento to Paypal:
form id="ppcheckout" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" name="pp">
<input type="hidden" value="_xclick" name="cmd">
<input id="business" type="hidden" value="xxx#gmail.com" name="business">
<input id="currency_code" type="hidden" value="EUR" name="currency_code">
<input type="hidden" value="http://www.mydomain.com/dir/ipn.php" name="notify_url">
<input id="return" type="hidden" value="http://www.mydomain.com/dir/" name="return">
<input id="cancel_return" type="hidden" value="http://www.mydomain.com/dir/" name="cancel_return">
<input type="hidden" value="1" name="amount">
<input type="hidden" value="Order from mysite" name="item_name">
<input type="hidden" value="1" name="invoice">
</form>
Can't realy figure out what's wrong or missing. Does someone have an idea?
Thanks
Bye
I hope you are not testing paypal on LOCALHOST. That wont work, you need to test it online, in a web server, you can code using localhost but have to upload it to the SERVER so as to test it completely.
Here is a link that might help in configuring paypal - How to Set Up PayPal Integration with PHP & MySQL
You need to edit the Instant Payment Notification (IPN) settings in your PayPal Sandbox business account.
Log into Sandbox business account.
Go to the Profile page and click on Instant Payment Notification preferences link.
Set Notification URL and enable the IPN message.
Full tutorial can be found from here - PayPal IPN / Notify URL is not working on Sandbox Account
Have you verified your sandbox account's email?
This link sounds similar to your problem, and that fixed it for him.
Checked for Queued IPN messages.
Hover over your profile Icon ->
Account Settings ->
(on Left) Notifications ->
Instant Payment Notifications (Click Update) ->
Search for IPN History
Now check whether the messages are queued or failed etc. It well might be paypal sandbox encounter's spikes and can't deliver the messages.
This is a direct link to IPN History
I had a hard time getting the sandbox to work as well. I would try to test it on paypal and confirm that sandbox is not doing something goofy
I had the same issue my login check was creating problem when paypal hit back to notify_url. I passed user session id in notify_url as query string and every thing works fine for me. Paypal on localhost won't work.
Using below link you can download paypal IPN class
http://www.micahcarrick.com/php-paypal-ipn-integration-class.html
I am building a web site for an organisation. The organisation can create as many programs as they want.
Each program should have a paypal donate button. when creating a program, a paypal donate button can be inserted automatically (something like {donate_button: label } ).
i want to keep track of each program donation fees.
So i need somehow to know what program a donor donate to so then i can make a report about fee for each program.
Am not so sure how to get this done properly. is it possible to add some parameters in the donate paypal button dynamically ? if posible , is there any problem regarding to security ?
Can paypal donate button be created dynamically ?
I am very appreciated for all of you .
Thanks
Am sorry for my bad English.
I'd suggest looking at Instant Payment Notification (IPN) and 'custom' to pass the name of the organisation on to PayPal.
Simply include the following in your existing button code
<input type="hidden" name="notify_url" value="link to IPN script">
<input type="hidden" name="custom" value="name of organisation / other unique identifier">
and read the IPN POST for the 'custom' parameter when it comes through.
There's additional documentation and some sample code at https://www.paypal.com/ipn