How do I setup a free trial that requires a credit card up front?

we want to setup a 7 day free trial followed by the paid plan. We want to require the user to enter their credit card info up front. How do we do this or can we?