paypal ipn max time for incomplete transaction - paypal

Hey guys was hoping you could help me out.
I am integrating paypal (for the first time) in a website using PHP. From what I have read, there are two methods for confirming a successful transaction, PDT and IPN.
Now the thing is, the item's being sold can have a limited stock. So if suppose a person reserves an item and is taken to the PAYPAL site for final payment, I have to stop all other people from making a purchase since the last piece of the item will be "reserved".
But suppose the person (who has reserved the final piece of the item) goes to the paypal page, and then simply closes it. Will this result in a "fail" ipn coming to me (so I should un-reserve the item so others can buy)?
If so, how long will it take for the failed IPN to come?
If not, how exactly should I handle this.
And is there any scenario where an IPN does not come?

You could use the Express Checkout API.
With EC, the payment is a two step process. In the first step, you make an API call (SetExpressCheckout) where you set up the transaction, and redirect the buyer to PayPal. Once there, the buyer authorizes the payment, and returns to your site.
At this point no money has changed hands. You need to make a second API call in order to capture the funds (DoExpressCheckout).
You can hold the item for a specific period, and if the buyer abandons the transaction, or is very slow to approve the payment, you can release the item back to the public. If he eventually approves it, and does come back to your site, you would simply skip the second step, and inform the user that his transaction timed out. No money changes hands, no items are double sold.

Related

PayPal IPN and AutoReturn

I have an ipn listener that update my transactions (from pending to completed) and my contracts payments from finished to paid. This is perfect! I has also a return page... From PayPal to my site... This page show "thanks" and "button to allow download their last paid online contract" (paid with PayPal). My problem is that.... Ipn listener sometimes comes 3 seconds after my return page is shown to the the user....
In my return page in this case. Has the transaction and contract unpaid... And when ipn listener catch the results... Then this transaction and contract change to paid status. But ipn listener is executed at back-end. In my server. And my return page was shown 3 o 2 seconds before to my user. What can I do?
Should I add a timer (a delay) in my return page waiting until ipn updates my transaction and contract status? And then, show to the user a button "you can download your last paid contract!". Or better I should forget this step. And in my return page always without wait show to user "thanks for your payment". "you can download your last paid contract!"
You should not regard or show the transaction as complete, or allow any further business action to occur, until you have actually received the money, and only the IPN tells you that.
You need to adjust what you show on your return page accordingly.
All you should really do here is thank the customer for his business and tell him that the download or the delivery or whatever it is will become available immediately PayPal has notified you of the actual transfer.
And note that it can take a lot longer than three seconds. If they chose to fund the payment from their bank account, it can take 3-5 days: and there is always the possibility of that process failing altogether due to insufficient funds.
So don't be too optimistic in designing your return page. The deal isn't done until the money is in the bank.
This page show "thanks"
Good.
and "button to allow download their last paid online contract"
Bad. That should be somewhere in 'My Account'.
I also have my return page wait for the IPN notification to come into my server, and you can definitely make that work if you do it right.
Initially, the return page polls on a field in my back-end database that the IPN handler updates. Then, when the return page sees that field update, the customer gets his 'here are the items you paid for' button.
I also have a one minute timeout on this process. When that expires (although I can't remember the last time that actually happened), I display a catch-all error message ('There was a problem processing your transaction') and invite the customer to contact me for help.
I also tell them that their license key (which is what they are buying, in my case) might be on its way by email, since, usually, it is. IPN notifications can sometimes take a little while to arrive for some reason but my IPN handler sends out a confirmation email as a backup so they will get that in due course. That usually sorts things out, I rarely need to get directly involved.
If PayPal puts the transaction on hold, it doesn't seem to ever forward the customer to the return page (I have certainly never seen that happen). Instead, I assume it lets the customer know that he must wait for the funds to clear and leaves it at that.
An IPN notification does get sent however when the transaction eventually clears, and then you can have your handler send that email.
Lest this sounds like a lot of work, you should be sending an email from your IPN handler anyway since customers like to have a record of their purchases. Once you put that mechanism in place, the rest is easy.
Note: Watch out for IPN transactions flagged as 'echeque'. The funds haven't cleared yet, you will get another notification when they do. Then you can send them their contract by email. If memory serves,this does forward them to your return page so you have to handle that by letting them know that they must wait. In practise, this doesn't seem to happen very often.
Suggestion: have your scripts send you an email when something unexpected happens. This has saved my bacon more than once when PayPal have changed the names of the fields passed to the IPN handler for no obvious reason.
Summary: This is a practical, experience-based write-up of the way my website works, and it works well. I hope readers of this post find it helpful, despite the mysterious downvotes.

Paypal automatic refund from IPN

having an issue.
I want a way to do a paypal transaction automatically when the paypal IPN sends a notifications.
To give some context.
I am developing a online seat booking system (school plays etc.) and have implemented a paypal button to buy the seats once you click your seats but i want to have a way for the paypal transaction to timeout so that the booked seats can be made available again if the payment doesn't go through.
so what i have currently is a time stamp on the booked seats that gives 10 mins before they are available again. But the paykey (i think i have that right) is still valid. so the first person could (in theory) go back and pay for the seats, therefor the seats are booked out twice.
so on my IPN i have a check to see if the booking is timed out.
And this is where i am, what code can i use to issue a refund in that case?
thanks
You can call paypal refund API:
https://developer.paypal.com/docs/integration/direct/payments/refund-payment/
I would also suggest that you have check on your website when someone clicks on Pay to see if the session is expired so that payment is never done. If you implement the solution where you will call refund based on ipn you will end up paying transaction fees anyways and customer experience will also be below par.

Paypal IPN getting delayed by hours

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.

PayPal Payments Standard Expiration

I am using PayPal Payments Standard to upload contents from a custom shopping cart. i.e. The upload happens with a page redirect which posts the hidden vars to PayPal where the customer completes the transaction. When the transaction finishes, PayPal uses the "IPN" process to notify my the payment has been made.
In this case a reservation is made at the same time. The same as selling a limited stock item. As it wouldn't be good to have multiple PayPal transactions out there contending for the same slot, the reservation is made before the customer gets redirected to PayPal.
Once the Customer is at PayPal they might realize they don't have any money and close the window leading to an unpaid reservation that needs timed out and dropped.
Is there a guaranteed expiration time for the PayPal checkout page after which the reservation can be discarded without a risk of receiving a surprise payment for a deleted transaction? I realize IPN has it's own non-deterministic timing stuff, but without knowing there even is an expiration period, someone might sit on the website for a day and then pay.
Possibly too late to help you, but for the record: I asked PayPal tech support this question, as I couldn't find it in the docs either. They wrote:
Each transaction is associated with a token that expires after 3 hours
if the buyer didn't complete the checkout. This isn't usually
modifiable but can be extended by contacting a Business service
representative ( we don't recommend to extend it for security reasons
however. the token can't be less than 3H in any case)
So it's a MINIMUM of three hours.

paypal echecks need some explanation

I have read a lot of stuff and spent hours on studying the PPs API.
There is one thing I don't understand and would like to know how can I do this.
When sender sends money form the bank account (not cc) it's called echeck and it takes up to 5 days.
In some places I can see that people say
you can't cancel echeck once it's approved. you can only ask seller to cancel your request/ payment.
but on some other sites I can read
buyer can cancel transfer any time, so do not ship the items untill you get final confirmation.
So what's the final answer here, can the buyer cancell the echeck/ transfer or not?
What if they approve it, but after one minute get rid of all the money form the account, and there is nothing they can be charged for?
And the second question: I can see that in the account setting you can disable acceptance od echecks. but how can this be done via API? I mean on my website I will have different sellers and I can't check if they have echeck enabled or not, so I would like to block echecks automatically via api. So, how can I block echecks using API
Buyers can't cancel an eCheck once they've initiated it. They would have to request a refund from you after the eCheck completes. (P.S. -- it's always a good idea to wait for the eCheck to complete before giving the buyer their goods. Just because an eCheck was initiated doesn't automatically mean that it will clear -- the withdraw from their bank account could still fail.)
If you're using Express Checkout, you can set PAYMENTREQUEST_0_ALLOWEDPAYMENTMETHOD=InstantPaymentOnly to disable eChecks.