I just started working with PayPal online payment system, I started making smart buttons in PayPal but I could not implement what I wanted.
I need that when the user enters a value in the Field Text after paying PayPal send request to a php file on my server with the information
For example, I want the user to enter their Username and send this request to an address after payment: www.site.com/paypal/success.php?username=enteredeusername&product=ID_ID
Use a server-based PayPal Checkout integration.
Make two routes on your server, one for 'Create Order' and one for 'Capture Order', documented here. These routes should accept JSON requests and return JSON to the requester. The action they should perform is to call the respective PayPal APIs before returning their result. The capture one in particular should do validation before sending the capture to PayPal, and write any necessary information to your database before returning its result to the caller JS.
Pair your above two routes with the following approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server
To your question about how to send a Username as part of their request, you can simply put it in your fetch's URL. Alternatively you can add a JSON request body to your fetch, and have your server parse the JSON request, that's just more sophisticated/advanced than the URL method; either will get the job done.