# Error Checking and Processing

**URL:** <https://www.ruby-forum.com/t/error-checking-and-processing/55907>\
**Category:** Rails\
**Created:** [March 25, 2006, 12:41am UTC](https://www.ruby-forum.com/t/error-checking-and-processing/55907 "2006-03-25T00:41:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![danhobbs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a5b964/32.png) [@danhobbs](https://www.ruby-forum.com/u/danhobbs)\
**Post date:** [March 25, 2006, 12:41am UTC](https://www.ruby-forum.com/t/error-checking-and-processing/55907/1 "2006-03-25T00:41:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![danhobbs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a5b964/32.png) [@danhobbs](https://www.ruby-forum.com/u/danhobbs)\
**Post date:** [March 25, 2006, 5:44am UTC](https://www.ruby-forum.com/t/error-checking-and-processing/55907/2 "2006-03-25T05:44:25Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![danhobbs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a5b964/32.png) [@danhobbs](https://www.ruby-forum.com/u/danhobbs)\
**Post date:** [March 25, 2006, 8:56am UTC](https://www.ruby-forum.com/t/error-checking-and-processing/55907/3 "2006-03-25T08:56:14Z")

</div>

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
