Topic: checkout sequence - payment

When is the checkout sequence is the optimal time for saving the order?

I have a:
a. cart and cart item model
b. a customers model and table

contained within these objects is all the necessary information to authorize the sale.

Is there any reason for not authorizing a sale ....just before all of these objects are saved into a customer:order:lineItem form in the respective tables.

I am asking this question because it seems cleaner and more straight forward to send information to a payment gateway before it is saved due to AVS errors.

I'm thinking that the response from the gateway would determines the conditional next step.

if the transaction passes
  save the customer, order and flush the cart
  proceed to 'thanks' and fulfillment
else
redirect to the customer/cart info for address AVS errors and
let the customer re-submit.


Is there any vulnerability that I don't 'get'.

Re: checkout sequence - payment

No - no vulnerabilities.

You may want to save the order regardless though, depending on the requirements of what you're wanting to achieve.

It can be valuable to know how many carts/orders are abandoned.  Processing the order again later on for "physical" products may be an option as well.

Ruby Rockstars - Ruby Jobs for all!