Hi,
Relatively inexperienced RoR guy here (but decided to use it for the
challenge!).
I have a website which takes online credit card payments. I have a very
bad problem though with it though. My “place_order” method which
actually performs the payment transaction and saves the order to the
database is not working correctly every time.
Here is some very brief psuedo-code of the method:
def place_order
create Order object
add line items to Order object
if Order.valid?
send XML-RPC call to credit card processing company
if result of XML-RPC call is ok
save Order to database
empty cart
redirect to payment_complete page
end
end
rescue XMLRPC::FaultException
log XML-RPC error
rescue Exception
log error
end
To help me diagnose my problem i have also put a large number of
logger.info() printouts throughout the method.
Now the problem i have is that from studying my logs it seems like every
now and then, the method just decides to randomly stop at a certain
point. Do rails methods have some kind of timeout where they will just
suddenly die after a certain time?
For me this problem is so bad because what is happening is that the
XML-RPC call is being sent to the credit card company, the method is
then dying; this results in the person being charged for the order but
it not being saved to the database - very bad indeed!
The point in the method where it seems to be halting does not seem to
stay the same - sometimes it is right after the XML-RPC call is made,
and other times it is after the result has been recieved back (but
before the order is saved to the database).
The XML-RPC call to the credit card processing company seems to take
between 2-30 seconds, could this play a factor?
As i said, this is only happening sometimes and the place_order method
works perfectly fine 9/10 times.
When the method was ending i was getting absolutely no error output in
my logs (set at :info level). I have just set my logs to :debug so maybe
that will shed some light on it.
I would be hugely grateful if anyone could help out or give me any
advice what i should do to make a more fault proof method; possibly
going to have to take the site offline if i cant solve this quite fast.
Thanks very much indeed.
Martin Brown.