Error Checking and Processing


#1

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
    hits submit.

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.

Cheers,
Dan


#2

Dan H. wrote:

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)

I figured out the blank values problem (sorta), but the others are still
a mystery.

Any ideas?


#3

Dan H. wrote:

Dan H. wrote:

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)

I don’t know anything about SOAP, but the latter problem sounds like
it’s simply the
result of redirects being a new request… save the form data in the
flash and pull it
back out after the redirect.

b