Shipping rates

How can I apply different shipping charges based on the payment method chosen at checkout? For instance, I want to charge $1 for customers selecting cash on delivery (COD) and $2 for those opting for online payment.