I have a multi-step Rails 3 form that I set up using this railscast: http://railscasts.com/episodes/217-multistep-forms, and I used another railscast to implement Stripe payment for my app: http://railscasts.com/episodes/288-billing-with-stripe
In my app, the payment form is hidden via jQuery if the amount charged to the user is 0.
$(document).ready(function() {
var xyz = $("span#total").text();
if (xyz == 0){
$("div#stripefields").hide();
};
});
What I want to be able to do is tell my Rails app that the Stripe payment fields are not required to successfully submit the form if the amount charged to the user is 0. So, I need to modify this statement in my controller to reflect that:
elsif @video.last_step?
@video.save if @video.all_valid? && @video.save_with_payment(@total)
@total is the amount charged to the user, and "save_with_payment" represents the Stripe charge. What would be the best way to go about doing this? Can I add another "if" to this statement somehow?