Reputation: 4056
When a user fills a form to create a record, before that record is saved, I would like to direct to a payment form for the stripe payment.
Do I make a multi-page form or two distinct forms with one redirecting to the other and then save the record? Should the stripe form include the fields of my main form and validate everything after the payment?
Basically I'm trying to understand the correct way connecting my main form and my payment form together and not creating the record until the payment is OK.
Upvotes: 0
Views: 132
Reputation: 3291
I recently went through a similar process for a site I was working on. I ended up doing it as multiple steps due to the complexity of my workflow, but for what you are describing I don't see any reason why it couldn't all be on one form.
This Railscast is a great resource. Basically, it won't submit the form to the server until you're able to generate a Stripe token, and then it won't actually create the charge with Stripe until after your model is validated. If the charge is created successfully it'll save your model, otherwise it will raise an error and not save your model.
Upvotes: 1