3

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 the data-callback as specified on the JavascriptButton github

    data-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.

Community
  • 1
  • 1
Martin
  • 22,212
  • 11
  • 70
  • 132

1 Answers1

3

Troubleshoot the issue further on Paypal

  • investigate IPN logs on Sandbox Paypal to see what and where the data is sent to, linked are the production URL and sandbox URL.
  • check the status code, if you are getting 5xx type error - debug your script
  • this should tell you WHERE the IPN is sent to, if it isn't what it should be check:
    • ipn URL in the button
    • ipn URL in profile is overriding
Martin
  • 22,212
  • 11
  • 70
  • 132
David Nguyen
  • 8,368
  • 2
  • 33
  • 49
  • My transactions page [here](https://developer.paypal.com/developer/dashboard/sandbox/) shows no transactions, however logging into the sandbox site shows me the transactions but doesn't show me any more than the data given in the JS form, no 5xx returns, etc. The listener script should not be at fault as the IPN Simulator uses the same script reference ( as set in the genuine account Control Panel). I can find no options in the sandbox admin site for editing any transaction destinations etc. – Martin May 13 '16 at 15:44
  • Oh for f*** sake, I used your link you provided and substituted the sandbox address in to it, and i tells me it's "queued" because in my Sandbox profile I had not created a IPN destination file (but I had in the real life profile). Jeeeez. – Martin May 13 '16 at 15:49
  • Thanks for the nudge in the right direction. Although I'm gritted that the sandbox transaction listing cant seem to be reached from the sandbox profile..... so very Paypal. – Martin May 13 '16 at 15:50
  • @Martin that should get you going and yes paypal development is rage inducing :) – David Nguyen May 13 '16 at 15:50
  • I'll have to wait for them to resend the transactions to see if they do arrive but if that works then I can give you the tick. Thanks for pointing me in the right direction, David. It's appreciated. – Martin May 13 '16 at 15:51
  • I have resent a test payment but the transaction is still appearing as *Queued* and not being dlivered. No 5xx code is found on the info. from the sandbox login page. – Martin May 13 '16 at 16:11
  • @Martin that is weird...but I'm also not surprised :P – David Nguyen May 16 '16 at 14:16
  • I found somewhat frustratingly that the page listing the IPN history does not allow me to resend the details, unless I go to the menu and reload the same page, from the menu, the resend tickboxes suddenly appear on the IPN History page. Anyhow, cheers for your help. – Martin May 16 '16 at 14:41