tags:

views:

46

answers:

1

Hi,

My notification script is launched twice first is VERIFIED and second INVALID.

I've tried different ipn validation scripts and always get it twice.

I'm using sandbox maybe seller account settings are not right? I've set IPN on with notify url and auto return. Also in form there is return and notify_url set

+2  A: 

I remember in the documentation it states that duplicates are possible -- that's just the nature of the internet. That's why it gives you a unique transaction ID. You're supposed to use that to prevent bad things from happening if you get notified twice.

A better question might be: why does it say Verified and then Invalid? Or is that ok?

EDIT

The docs say "PayPal sends a single word back, which is either VERIFIED if the message originated with PayPal or INVALID if there is any discrepancy with what was originally sent". I'm going to guess that YOUR code accidentally sends the "echo" back to PayPak twice and one of them is malformed. Maybe they're both identical but PayPal responds with INVALID if it gets it twice. But no matter, for a particular transaction Id, once you get VERIFIED, you're good. Simply ignore all subsequent responses.

EDIT 2

The return url is simply used by PayPal to redirect the user back to your site. Use this page to thank them for their purchase and inform them they will be notified once processing is complete. You can even set this to an empty string if you don't want this feature. When Payment is actually complete (or some problem was identified), PayPal will invoke the script referenced by the notify url. This is where you make sure everything looks right, handle duplicate notifications, update your database, send an email to the user saying their payment was processed, etc.

colithium
The problem is always get it twice, it's ok when using IPN simulator and it's not ok
miojamo
See the edit I just made
colithium
I had return URL set to verify so it was called twice. So my next question is. Notify url is send back so how to validate payment in return url?
miojamo
The common pattern is to resend every message you get back to PayPal and wait for PayPal to respond with "VERIFIED". You should also perform some validation related to your business rules (ie, make sure they aren't buying something that doesn't exist). But for more specific answers, check the guide: https://cms.paypal.com/cms_content/US/en_US/files/developer/IPNGuide.pdf
colithium
yes but return url is different than notify_url and call different function or site and status variable are not passed from notify_url to return url.
miojamo
If I'm not mistaken... The return url is intended to be a page that just says "thanks for buying {x}, your order is being processed". Then when it actually is processed, PayPal calls notify_url. Since the script at notify_url doesn't have a browser to talk to, it needs to update the database and/or send the user an email to let them know it went through.
colithium
OK thanks for explanation, I though that could pass information straight away after payment is done, even try to save a session with status but that didn't work
miojamo
Well by all means save which product button they clicked/selected in SESSION so you can display that information when they come back to the return url. But payment processing is done asynchronously.
colithium