First you've got to find out if the person of interest filed for a pension. Ancestry, and I think Fold3, both have those applications. On Ancestry, you do a search and then select "Military" from the list of options on the left of the page and if there's a pension application it should come up pretty close to the top of the list. I always print or download a copy; you'll need some info off the application (see example attached).
Once you've established that a pension was applied for then you have to order a copy of the file from the National Archives. You've got two choices: use their on-line service (for which you'll have to create an account with a password) or mail in a form (which is available on line). In theory the on-line service is faster - but neither is fast - but I've had problems getting pension files using that method for some reason - have been told several times there's no pension file when there is - so I tend to use the old-fashioned snail mail form. That allows me to attach a copy of the pension application form so there's no question there is an application (you can't attach anything with the on-line service). I've never had a problem using the mail option and have always got the files just about as fast as if I'd used the on-line service (always takes six to eight weeks no matter what).
Oh, and regarding the files, you've got two options for pensions: the "complete" file or the abbreviated file. The complete file costs $80 while the abbreviated one costs $30. I've never got a complete file as the abbreviated ones are purported to contain all of the genealogical information (I'd guess the complete files have a lot more supporting documents and such).
Here's the URL for the mailable form:
https://www.archives.gov/files/forms/pdf/natf-85.pdf
Here's the URL for the Archives' on-line service:
https://eservices.archives.gov/orderonline/start.swe?SWECmd=Start&SWEHo=eservices.archives.gov
View attachment 306329