I have a rails 4 app that I'm using Stripe checkout. I've followed their tutorial, and my controller looks like:
s = Subscription.new
s.user_id = current_user.id
s.plan_id = params[:plan_id]
s.stripe_token = params[:stripeToken]
# Amount in cents
@amount = 699
customer = Stripe::Customer.create(
:email => current_user.email,
:card => params[:stripeToken]
charge = Stripe::Charge.create(
:customer => customer.id,
:amount => @amount,
:description => 'Sitekite Pro',
:currency => 'usd'
rescue Stripe::CardError => e
flash[:error] = e.message
Stripe::Charge is indeed for single charges. The Customer create is what you need, but when you create the customer you specify a
plan (plans are defined in your
Stripe dashboard). The plan will specify the amount to charge and how often to charge it.
When the charge is actually made, which might be the same day or might be several days later depending on whether your plan provides, say, some free access time... the
Stripe service can send the charge to a webhook... which is to say a route in your project for the dedicated use of the Stripe service.
Stripe will post charges (and failures) to your webhook, and you can handle them appropriately (logging the payments and maybe restricting the user if his card becomes expired or a regular payment fails for some other reason)