Hi there Dileep!
My name is John and I'm a Guru here at Shopify!
I've spent some time today researching your query alongside some of our specialist teams here and it looks like there is no way currently to restrict the application of a discount code by payment method.
What I can do for you now though is I will file a feature request on your behalf to raise this requirement to our developer team.
This way we can take into account your feedback and see about changing how this works in the admin in future if possible. :)
Thanks for letting us know about this and do let us know in future how else we can help out.
I am wondering if if possible for the costumers that are buying my product online NOT to apply a discount code if the are buying with afterpay.
I want the costumers to be able to do one or the other not both.