Take a look at Instant Payment Notification (IPN). It will POST
transaction data to a listener script you have on your web server in
real-time so you can automate tasks based on pending payments, completed
payments, refunds, disputes, etc.
For PHP there are lots of IPN templates/classes available for you to
use. Here's one that I built years ago that is still very
useful. There are good options
on Packagist so you can easily load them up in Composer, too, if you'd
rather go that route.