Is there any way to automatically download a dynamically generated file after payment completion

I am learning about Javascript API<sub>s</sub>, and as a practice I had created a web application using GOQR API, which asks for some details from the user and when user clicks generate button it generates a qr code based on that information and user can download it on his system as png file. Now I had linked that button (which generates qr code) with my instamojo payment link, and now I want is that the file with user’s qr code gets downloaded automatically after completion of payment.

I had searched for solutions on instamojo FAQs and with other payment gateways also, but none of them worked for me, they’re for downloading a static file which was uploaded on the server. But I wanted to download a dynamically generated file.