How to handle timeouts when using ActiveMerchant?

Sometimes when developing locally my connection drops, and while this, I hope, should not happen during production, there is a problem due to which I probably should process timeouts from ActiveMerchant when it goes to the payment gateway, in my case SagePay.

I can’t figure out how to do this in the documentation, I was wondering if there is a way to handle this?

+4
source share
1 answer

I believe the question is related to the ruby ​​implementation of AM (correct me, if I'm wrong, please).

ActiveMerchant ActiveMerchant::ConnectionError, ( ). . :.

begin
  # Your ActiveMerchant staff here
rescue ActiveMerchant::ConnectionError => e
  # timeout handler
end

, open_timeout read_timeout ( ), SagePay:

ActiveMerchant::SagePay.open_timeout = 5 # timeout for opening the connection is set to 5 seconds
ActiveMerchant::SagePay.read_timeout = 10 # timeout for reading from opened connection is set to 10
0

All Articles