How to change/discount total amount before payment I want to change the total amount programatically before the payments are processed. 

If the total amount is $1000 I want to give a discount based on a point system in the users profile. You can add the desired amount based on his total points. If he adds 20 he gets a $20 discount and only have to pay $800. 

What is the best way to implement this? I have tried with commerce_transactions.onCreateTransaction but no luck.
Have you looked into building an adjuster for this purpose? You can find the documentation here