lib/active_merchant/common/posts_data.rb in activemerchant-1.9.1 vs lib/active_merchant/common/posts_data.rb in activemerchant-1.9.2
- old
+ new
@@ -23,13 +23,16 @@
end
def ssl_post(endpoint, data, headers = {})
ssl_request(:post, endpoint, data, headers)
end
-
- private
- def ssl_request(method, endpoint, data, headers = {})
+
+ def ssl_request(method, endpoint, data, headers)
+ handle_response(raw_ssl_request(method, endpoint, data, headers))
+ end
+
+ def raw_ssl_request(method, endpoint, data, headers = {})
connection = Connection.new(endpoint)
connection.open_timeout = open_timeout
connection.read_timeout = read_timeout
connection.retry_safe = retry_safe
connection.verify_peer = ssl_strict
@@ -40,8 +43,19 @@
connection.pem = @options[:pem] if @options
connection.pem_password = @options[:pem_password] if @options
connection.request(method, data, headers)
end
+
+ private
+
+ def handle_response(response)
+ case response.code.to_i
+ when 200...300
+ response.body
+ else
+ raise ResponseError.new(response)
+ end
+ end
end
-end
\ No newline at end of file
+end