How to provide coupon code to app user when they purchase an app

Shopify Partner
37 0 3


I am a Shopify developer and I want to provide my app users a coupon code when they purchase an existing plan so that with coupon code they can purchase the same plan with less amount next month.
I want it to provide certain specific app users only. My app is having recurring charges monthly.

Should I have to manage everything by my code and my own logic or is there anything by which I can handle it with Shopify's API or any parameter or anything else?
Also, what is the best possible way to accomplish it?

Thank you to the community for the help and suggestion in advance.