Hi smile,
You need to create another table where you have to save the payment details.
Like UserId, FileName and PaymentStatus.
When paid by user insert the details in the table.
Now, when download button will be clicked by the user, then check the payment status for the file.
If not paid then redirect for payment and continue download.
If already paid then continue with the download.