Does anyone have any ideas on the best way to perform error checking and
processing for a particular problem:
- A customer fills in an order form with their credit card details and
The controller has to do the following work:
- Try to find an existing customer matched by email
- if the customer exists, update their details in the database
- if the customer is new save a new record
- validation errors could occur here
- Copy the data from the cart session variable to an Order object
- Save the order to the orders table
- Send the credit card details to PayPal for processing
- parse success/fail and save any errors to forward to the user
- If anything failed, redirect back to the form filling in the form
details and showing all error messages.
Now some things I’m not too clear on in Rails land:
- How to I parse the response from PayPal for error messages (using
SOAP and the PayPayl Rails plugin)?
- How do I redirect back to the form and send the data to fill in? (I
can redirect to the form, but there are no values filled in)
- What is the best way to structure these steps in code (order, etc)
and the best way to handle the success/fail, rollback, errors, etc?
It may be obvious, but my brain is a bit mushed from staring at this
problem too long, any help appreciated.