I've been trying to base my IPN off txn_type, then payment_status but I've been getting exceptions since not every IPN has those. What variable can I base my IPN off of?
txn_type was not sent in refund IPNs.
As you noted, txn_type isn't sent with every IPN type. There isn't really any one field you can look at and always count on. What you need to do is setup logic to check for different fields and their availability as well as their value.
So I would check for txn_type, and if it exists, go ahead process according to that type. If it doesn't exist, though, then you can fall to other parameters to figure out what's going on and how to process it within your logic.
For example, if you take a look at this sample refund IPN data, you'll see it includes a payment_status of "Refunded" as well as a reason_code of "refund". So your logic can look for those values accordingly, and it would then know it's a refund.
Related
I have developed the IPN listener side of a PayPal-enabled website which records user subscriptions. Currently when I am interested for a successful transaction I look for the payment_status variable, ensuring that payment_status == "Completed", but as can be clearly noted in the PayPal IPN variables reference, there's lots of them and I can't say whether I'm overlooking some.
So, in the end, my questions are:
Is a payment transaction considered successful if and only if payment_status == "Completed", or is there any other variable that can determine it?
Are there any other important or common states associated with a payment transaction that is worth considering?
Have a look at all the sample code they provide. You will see that they go to a lot of trouble to make sure that the product being bought actually exists, and that the price is correct for the way they bought it (buy it now, subscription, trial period, ...).
Basically you cannot assume that the original transaction that gave rise to the IPN was not forged somehow. It's easy.
I'm using a basic HTML form to call PayPal (webscr) and I am successfully getting IPN callbacks.
There is plenty of documentation about the contents of each individual variable that can be returned in an IPN. There is something important missing, or else I have missed it:
What paypal transaction types and payment statuses reflect actual changes in my account balance? For example, a "Completed" status certainly does, and a "Pending" status certainly does not.
However, there appear to be five or six relevant transaction types and eleven different payment statuses possible. Other than trying all 55 or 66 combinations in the IPN simulator, is there any document that clearly shows for which ones I should accumulate the mc_gross amount?
Or to put it another way, some IPN messages are just "in case I need to know", and some mean "money has changed hands; adjust your accounts accordingly". It's not clear to me which combinations of transaction type and payment status indicate the latter.
Thanks and Best Regards,
I'm using paypal adaptive payments to make transaction via paypal. Although few of transactions are taking more than 6 hours too receive IPN.
I've gone through forum posts and their documentation, I came through - https://developer.paypal.com/webapps/developer/docs/classic/products/instant-payment-notification/
"Because IPN is not a real-time service, your checkout flow should not wait for the IPN message before it is allowed to complete. If the checkout flow is dependent on receiving an IPN message, processing can be delayed by system load or other reasons. You should configure your checkout flow to handle a possible delay."
The callback is taking more than 6 hours is way too much. any suggestions ?
I've built several custom carts. On average, I see the PayPal IPN come back within 2 minutes at the longest, and usually recurring payments take longer than single payments because they send two IPN messages, not just one, on the initial setup. I usually take the 'custom' property and put a unique identifier that I have permanently cookied. So, even though I may see an initial IPN come in on a recurring payment, I wait for the one that says that txn_type is subscr_payment and also that payment_status is Completed. You can't really trust a subscription payment as being paid unless you see that second message. And if it's a single payment, then I look for txn_type to be web_accept and payment_status to Completed.
The way I handle things is to redirect the customer to PayPal to purchase using the form button technique. The customer pays and then gets redirected (thanks to the form hidden vars I created initially) back to my own custom cart URL that I specify. I call that URL the payment-confirmation script. I display a message with a progress bar to please wait while their payment is being confirmed with PayPal. I hold them there 10 seconds and then redirect to the receipt. It is on the receipt where I check the database to see if my IPN script has already processed this order. If not, then I redirect them back to the payment-confirmation script again for another 10 second progress bar delay. My receipt uses a session cookie to ensure I never send them into a loop more than one time to the payment-confirmation script. So, the customer waits another 10 seconds and then comes back to the receipt page, where I test again, reading my permanent cookie on the 'custom' property that I saved, versus the 'custom' property that comes in from the IPN that I use as the order key in the database. Usually within the first or second 10 second delay, the IPN has come in and I can proceed. However, if the IPN has still not come in, then I redirect to a friendly error message saying that their payment cannot be confirmed and to call our call center to remedy the issue. Our call center techs then see the delay problem in PayPal, back the other transaction out, and sell to the customer over the phone manually, instead.
First of all sorry about my english,
I have a small problem with the IPN PayPal notification system. After a payment is done on my website, Paypal send to me a IPN message in order to confirm the transaction. In my website I need to do some stuff, including setting a variable which indicates the order can be send. But in the case two payments with the same amount are done at the same moment, how can I distinguish them? The user's mail is not enough because the mail I have can be diferent of the paypal user's mail...
Any Idea?
Ok, I think using the custom filed I can achieve that.
The transaction is identified by the txn_id field. In the case of a Reversal or Cancel_reversal, the original transaction it refers to is given by the parent_txn_id field.
I don't see what 'with the same amount' has to do with it.
I'm trying to create a simple paypal purchase system. Going through a few tutorials, it seems like I need to use the IPN (Instant Payment Notification) system to keep track of whether the order is paid.
Is it sufficient to use the return url variable instead, and pass in the order id? For example, something like return="http://mysite.com/paid?id=5&pass=xyS2y"
The variables - PayPal HTML Variables
No - the user might not return to your site after payment.
If you do get a PayPal return you still need to validate it just as you would for IPN in order to confirm payment went through, for the correct amount, for the correct items, for the correct payee account (you), for the correct customer, for the correct order reference, in the correct currency, with the correct shipping amount etc. etc. Your needs on this validation may vary depending on how complicated the payment you are taking is (if it's just a donation for instance that's less processing compared to say a multiple product order).
You will also need to make sure you don't double-process the order when you get the IPN through later.