Paypal automatic refund from IPN - paypal

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.

Related

PayPal Payment TimeOut

We a developing a booking system using PayPal for payments.
If a payment is not made within a set time how can we prevent the payment from being completed if the set time has been exceeded?
When selling tickets to an event, we reserve the tickets until payment is made, but if payment is not made we need a way to cancel the transaction and allow the tickets to be sold to a different customer.
Hope someone can help!
Cheers. - Dave.

PayPal Subscriptions - Tracking Refund

I'm not a developer, but a project manager. So please excuse my lack of proper language.
We are trying to figure out how to handle subscription refunds and then limit account access on the site.
Here's a scenario. Member signs up for an annual subscription to gain certain capabilities in the account. 3 months into it member decides to cancel and requests a refund. Normally, if no refund is issued, subscription is good until the end of the billing period, at which point account is deactivated.
In our case, if a refund is issued, account should be deactivated immediately. Question: is it possible to set this up as part of PayPal Subscriptions? Some type of call from PayPal to our system that will trigger account deactivation.
Thank you.
We recommend using IPN (Instant Payment Notifications) to be asynchronously notified of any events, in this case of those related to existing subscription/recurring payments.
https://developer.paypal.com/webapps/developer/docs/classic/ipn/gs_IPN/
If you enable IPN notifications you will receive a POST of PayPal in the following events (among others):
When a recurring profile is cancelled.
When a refund has been made to a previous completed transaction.
This way, you can set up your IPN script to keep the subscription “open” in your side for the remainder of the month even if the profile has been cancelled, or to deactivate it if the last month has been refunded.
For more information about IPN variables:
https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNandPDTVariables/

When to stop querying paypal api's for payment status?

Using the parallel payments paypal api. If user 1 makes a payment to user 2, I make a check using the api to make sure paypal returns the payment details as COMPLETED.
How long does paypal keep that COMPLETED payment record? Do they keep it indefinitely, or do they delete it after a while? I ask because I am at the stage of development where I need to decide if I should rely on paypal keeping that record indefinitely, or if I should create a record on my server that the payment has been completed, or if I should always check if the payment has been marked as COMPLETED by querying paypal?
The only reason why I "want" to check via paypal, is if the payment is ever returned to user1 as REFUNDED or PARITALLY_REFUNDED when paypal is queried using their apis. I would want to act accordingly in such situations.
It's not too much of an issue if the status is REFUNDED or PARTIALLY_REFUNDED as apparently people can't get refunds if they don't open a case with paypal before 45 days are up. I am more concerned about the REVERSED status, which can apparently happen any time, even after 45 days which is beyond paypal's control, as it is done by the credit card companies, if the user pays by credit card...
Using the PaymentDetails request I was able to pull my oldest Adaptive Payment transaction, which was over 60 days old and had no problems pulling it up using the transactionId field. It should be able to pull up payments as long as they are listed in the PayPal account (currently forever.)
This will work using the payKey field also if you are storing that instead of transactionId, however the transactionId is displayed in your PayPal account and is sent with IPN responses.

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.

paypal ipn max time for incomplete transaction

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.