ipn-code-samples icon indicating copy to clipboard operation
ipn-code-samples copied to clipboard

PHP Example - Sandbox IPN response is always INVALID?

Open vdonchev opened this issue 6 years ago • 62 comments

I have copied the exact files from PHP examples and then using my PayPal developer sandbox tested the IPN listener (the one in "example_usage.php")

The IPN ALWAYS return INVALID, no matter what I try.

Is there anything required except the example code, so the PayPal may return VERIFIED when testing?

vdonchev avatar May 23 '18 11:05 vdonchev

I'm having the same issue with the C# code!

spivack1212-zz avatar May 31 '18 15:05 spivack1212-zz

I have verified that this is an issue with the IPN Simulator. The same code that was always getting INVALID in the IPN Simulator is working fine in production.

spivack1212-zz avatar May 31 '18 20:05 spivack1212-zz

@pp-randy Are you able to have a look at this? Seens a few people are having this issue.

overint avatar May 31 '18 22:05 overint

Yes, experiencing exactly the same with the ipn simulator.

I’ve checked the parameters passed from the sim and compared them to what I push back for verification and they match exactly.

Have added user agent but still get invalid on every try.

carlcarter avatar Jun 14 '18 16:06 carlcarter

@pp-randy

overint avatar Jun 14 '18 21:06 overint

We're experiencing the same.

jghankins avatar Jun 18 '18 15:06 jghankins

30 days and still no fix for this?

vdonchev avatar Jun 23 '18 05:06 vdonchev

Having same problem here. Pulled my hair out for days over this. One user mentioned it works fine when live. Anyone else able to confirm this? Thanks!

kwdel avatar Jun 24 '18 23:06 kwdel

@kwdel I can confirm that it works with production IPN.

vdonchev avatar Jun 25 '18 04:06 vdonchev

Unfortunately i've not got a response from the paypal team, i've sent them a follow up email.

overint avatar Jun 25 '18 11:06 overint

Well, you guys are doing better than me. I am using the PaypalIPN.php file with the example_usage.php listener, exactly as shown, and the Sandbox IPN Simulator is giving me the "IPN was not sent, and the handshake was not verified. Review your information" response.

jamminjames avatar Jun 26 '18 10:06 jamminjames

Okay, changed a couple variables in the PaypalIPN.php file, and now I'm getting a good handshake, but still Invalid, as with everyone else.

I had to change these to true and false, respectively, even though the public variables were correct:

    /** @var bool Indicates if the sandbox endpoint is used. */
    private $use_sandbox = true;
    /** @var bool Indicates if the local certificates are used. */
    private $use_local_certs = false;

jamminjames avatar Jun 26 '18 11:06 jamminjames

I still having the same Issue with my Python Code!... More than 1 month and no one can solve this issue? :(

alfonsofoster avatar Jun 28 '18 23:06 alfonsofoster

Hi guys, I'm new to Dot Net Core and Angular. I have implemented the Paypal payment in my system. It takes the payment properly from user, also return them back to ThankYou page. But the problem is, it does not send the IPN response back. I have copied the code, mentioned in code section of ASPNETCORE_MVC. But it does not get called from the PayPal. I have specfied the url like this:

http://www.mywebsite.com/ControllerName

Here in my case the ControllerName is IPN and snapshot code is as below.

http://www.mywebsite.com/IPN

But it does not call the function Receive(), which i think it should call when the paypal sends the response back.

using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using System.IO; using System.Net; using System.Text; using System.Web; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Hosting;

namespace WebApplication4.Controllers { public class IPNController : Controller { private static IHostingEnvironment _hostingEnvironment; public IPNController(IHostingEnvironment environment) { _hostingEnvironment = environment; }

    private class IPNContext
    {
        public HttpRequest IPNRequest { get; set; }

        public string RequestBody { get; set; }

        public string Verification { get; set; } = String.Empty;
    }

    [HttpPost]
    public IActionResult Receive()
    {
        string l_strBody1 = "Paypal Response IPN:  - Hard coded";
        AlertsAndEmails.SendEmail("Muhammad", "[email protected]", l_strBody1, "https://google.com", _hostingEnvironment, "Paypal Response");

        IPNContext ipnContext = new IPNContext()
        {
            IPNRequest = Request
        };

        using (StreamReader reader = new StreamReader(ipnContext.IPNRequest.Body, Encoding.ASCII))
        {
            ipnContext.RequestBody = reader.ReadToEnd();
        }

        //Store the IPN received from PayPal
        LogRequest(ipnContext);

        //Fire and forget verification task
        Task.Run(() => VerifyTask(ipnContext));

        //Reply back a 200 code
        return Ok();
    }

//The rest of the code. }

Your effort will be highly appreciated. Thanks.

MuhammadMohsan786 avatar Jun 29 '18 10:06 MuhammadMohsan786

Muhammad, make sure you have app.UseMvc() in your Startup.cs file.

Also, make sure your IPN listener is deployed to a website that supports TLS 1.2. I.e. your URL should begin with "https://", not "http://"

spivack1212-zz avatar Jun 29 '18 10:06 spivack1212-zz

Still no fix for this? I'm having the same INVALID response problem...

dagger59 avatar Jul 04 '18 16:07 dagger59

@onmas59

Unfortunately I do not work at paypal, however i've escalated it to their IPN team so hopefully they are working on a fix. @pp-randy

overint avatar Jul 04 '18 22:07 overint

same here with php

daslicht avatar Jul 10 '18 16:07 daslicht

@daslicht Indeed. I saw someone say it operates successfully on the live servers rather than the sandbox ones, if anyone can validate this? I don't want to push something if it is not operating as desired.

Swedz avatar Jul 11 '18 21:07 Swedz

@Swedz I confirm that the example code works well with the production endpoint.

vdonchev avatar Jul 12 '18 04:07 vdonchev

Anyways, what the the purpose of a sandbox when it is not working ? How to test the IPN without a real transaction ...

daslicht avatar Jul 12 '18 09:07 daslicht

Just tried it again, today it worked with teh sandbox !

daslicht avatar Jul 12 '18 09:07 daslicht

IPN simulator is broken, always returning INVALID when the same code in production returns VERIFIED. And my IPN script correctly sends back the processed the message to https://ipnpb.sandbox.paypal.com/cgi-bin/webscr when using IPN simulator and not 'https://ipnpb.paypal.com/cgi-bin/webscr.

Such a shame...

damianobarbati avatar Jul 13 '18 11:07 damianobarbati

Here thats what I get when I do a ExpressCheckout IPN simulation:

daslicht avatar Jul 13 '18 14:07 daslicht

@daslicht yeah, me too. Then verification of IPN message to https://ipnpb.sandbox.paypal.com/cgi-bin/webscr miserably fails. Same code of production, just calling sandbox url. We resorted testing with real transactions.

damianobarbati avatar Jul 13 '18 14:07 damianobarbati

Just tried it and: $verified = $ipn->verifyIPN(); returns true

in Sandbox mode here. one day ago it always was false

daslicht avatar Jul 13 '18 14:07 daslicht

@damianobarbati Just tried it again this time when i call the listener with the IPN Tester form dev tools I also get false. But when i do a sandbox checkout it is true

daslicht avatar Jul 13 '18 17:07 daslicht

Same problem here using the sample code.

saidmrn avatar Jul 18 '18 00:07 saidmrn

Same issue. Hoping paypal can look at this soon so my development isn't blocked.

ataker avatar Jul 19 '18 11:07 ataker

do you guys also get that error when performing a checkout using a sandbox account ? The only thing which discourage me from using PayPal is their bad support.

I wait for an aswer for some days now, whereas Braintree answers within a few hours.

daslicht avatar Jul 19 '18 12:07 daslicht