I use the method of payment sandbox, and when a user makes the payment, if he does not click on "Return to the site," but he closes the page, the payment is made, but my page that manages the treatment if payment is not called ... How can I return to this page automatically? Thanks
What you're looking for would be configuring Auto-Return in your PayPal. It's part of the Payment Data Transfer (PDT) system.
That said, I would NOT recommend you handle post-payment processing tasks from the return URL. Even with Auto-Return enabled there is no guarantee the user will make it to that page (they could close their browser window, for example), and in those cases your code would never run so your system wouldn't get updated correctly.
Instead, you should use Instant Payment Notification (IPN), which is very similar to PDT except that it will POST data to a "listener" script that you have sitting on your server regardless of whether or not the user makes it back to your return URL. This will ensure your code always runs as expected.
IPN also allows you to properly handle things like e-checks, which take a few days to clear so you would need to update your system upon pending payment as well as the actual completed payment. You can also automate tasks for things like refunds, customer disputes, subscription payments, etc. using IPN.