I have spent 9 hours today working with Paypal, and I have an issue that I can't find the solution for.
I am using the Paypal Javascript Buttons github script for creating dynamic page generated buttons for simple Buy Now transactions.
The button example output is generated by PHP (so is dynamic) and looks like this (featuring sandbox details):
<script src='https://site-addr/includes/js/paypal-button.min.js?merchant=siteemail-facilitator@gmail.com'
data-callback='https://site-addr/account/listener.php'
data-tax='0'
data-env='sandbox'
data-shipping='0'
data-currency='GBP'
data-amount='1.00'
data-quantity='1'
data-custom='$2y$10$BdA/7xN2S/fzRq8X9p4pFOmzYBpia/u7sWsAcWN/4w9NZVXduaUzu'
data-number='20165'
data-size='Large'
data-locale='UK'
data-host='www.sandbox.paypal.com'
data-type='button'
data-cancel_return='https://site-addr/account/basket.php'
data-return='https://site-addr/account/complete.php'
data-name='Site Name Tickets'
data-button='buynow'
async='async'></script>
This generates a perfectly good simple click form for purchasing via the Paypal interface.
Meanwhile, I have downloaded the IPN listener from the Paypal Github and updated the details as required, also downloading the cacert.pem
file
from here.
I have run the Paypal IPN simulator which gives me correct results via my listener.php
file, giving a correct feed out of full data and VERIFIED
each time I run the test.
The Issue
But, when I run the sandbox purchase using the above details, the purchase runs correctly but I get no feedback to my IPN listener, I also get no transaction details on my sandbox Transaction notifications. But I DO get details on the sandbox Paypal account that the purchase was successful and the purchase has completed ok.
Things I've tried
I have read a lot of Paypals documentation and found their approach to providing a clear and concise guide to setting anything by Paypal up, very fraught. I have read about 40 pages of their documentation including finding out various ueful posts from Stack Overflow (whom Paypal directly reference for helpful solutions rather than providing their own).
Solutions that have tried and failed:
This similar question did not provide any clear solution.
This question gives some help and confirms that the transactions should be the acceptable
web_accept
type.This question (answer) gives clear advise to use
data-notify_url
rather than thedata-callback
as specified on the JavascriptButton githubdata-notify_url='https://site-addr/account/listener.php'
But the above replacing data-callback
does not work. The transaction still appears to succeed but not transaction or IPN data is recorded.
removing / replacing various
data-
entities, with no success.I have full PHP error reporting throughout my site and no errors of any form are generated.
Further considerations
I'm sure some of you will be saying, well I should use the SDK downloads for doing this sort of thing, but the scope of the SDK is huge and my need is relatively simple, and the Paypal documentation leaves an awful lot to be designed. Also their (on a range of Paypal github deposits) are using MySQL_
requests on example code as well as addslashes
and other things that are years out of date.
Also it's worth noting that while the Paypal documentation for the Javascript Button generator accepts the account email or the account Code, giving the account code causes a critical error and prevents payments (real or sandbox) being processed.
Coupled with this the finding of only piecemeal guidance information as well as "loops" in the documentation such that I'm on one topic, and it says "oh if you want to find out how to do this, follow this link", and then following the link it's more verbose text written for non-developers (on the developer portal) and then a link to another text block before a link back to the text to start with.
Sorry this is turning into a Paypal moan, but as far as possible I would like to avoid using the huge SDK system for what should amount to a straight forward send and recieve data operation.
Any helpful examples with solving this issue?
Final note: Last month I made a payment system on Stripe that does exactly the same thing, it took four hours and works perfectly.
(I can't use Stripe here as client has an existing Paypal account and won't change).
Solution:
With the help from David Nguyens answer below, I found the issue in my case was that I had set up the IPN and enabled the IPN and given the correct address for it, but this was on the Live account rather than the sandbox account, despite only setting up the sandbox account after all the details on the live one had been applied.
Paypals Live and Sandbox profiles are entirely mutually exclusive and sandbox creation will not import any data from the live account it is associated with.