Taylor Cooney


2,050 Experience
2 Lessons Completed
1 Question Solved


Hey Chris...how do you differentiate your form, so that when a user edits a post they've already paid for, the Stripe pay button is replaced with a typical 'Submit' button. Thanks in advance
Great video Chris
Nice one, Chrisđź‘ŚMoving the payment logic to be inline with the Job makes a lot more sense. Can't wait to sign up for the video series, thanks!
It's been surprisingly difficult to find more information on creating one-off, or single charges for a user.

Currently I am making a job board where anyone can browse listings, and a user (Devise) has CRUD abilities for a job posting. I want to embed a Checkout in the Job#new form and charge a user $x.xx before the job is created. This Checkout would work with Stripe to capture credit card details, and not store the user as a repeating customer; a user should not have their credit card details stored on file and should have to input the credit card information each time they want to create a job.

Rough outline of how I'd approach this. Let me know if this seems logical:
1. adding the Stripe gem to the application’s Gemfile
2. create the actual charges in the existing Jobs Controller

 |   before_action :authenticate_user!, only: [:new]
 |   def new
 |     @job = current_user.jobs.build
 |   end

 |   def create
 |     @job = current_user.jobs.build(jobs_params)

 |     if @job.save
 |       # Pass Stripe::Charge.create
 |       redirect_to @job
 |     else
 |       # Handle rescue Stripe::CardError
 |       render 'new'
 |     end
 |   end

I'm not sure if this will have an impact on routes how this will change how I add the credit card form in Job#new in terms of getting the [:stripeToken].

= simple_form_for(@job) do |f|
 |   = f.input :title
 |   = f.input :company
 |   = f.input :location
 |   = f.input :url
 |   = f.button :submit

Hoping to get a clearer idea of how to implement one-off charges before diving into the implementation,

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2021 GoRails, LLC. All rights reserved.