lib/active_merchant/billing/gateways/visanet_peru.rb in activemerchant-1.83.0 vs lib/active_merchant/billing/gateways/visanet_peru.rb in activemerchant-1.84.0

- old
+ new

@@ -138,28 +138,26 @@ def split_authorization(authorization) authorization.split('|') end def commit(action, params, options={}) - begin - raw_response = ssl_request(method(action), url(action, params, options), params.to_json, headers) - response = parse(raw_response) - rescue ResponseError => e - raw_response = e.response.body - response_error(raw_response, options, action) - rescue JSON::ParserError - unparsable_response(raw_response) - else - Response.new( - success_from(response), - message_from(response, options, action), - response, - :test => test?, - :authorization => authorization_from(params, response, options), - :error_code => response['errorCode'] - ) - end + raw_response = ssl_request(method(action), url(action, params, options), params.to_json, headers) + response = parse(raw_response) + rescue ResponseError => e + raw_response = e.response.body + response_error(raw_response, options, action) + rescue JSON::ParserError + unparsable_response(raw_response) + else + Response.new( + success_from(response), + message_from(response, options, action), + response, + :test => test?, + :authorization => authorization_from(params, response, options), + :error_code => response['errorCode'] + ) end def headers { 'Authorization' => 'Basic ' + Base64.strict_encode64("#{@options[:access_key_id]}:#{@options[:secret_access_key]}").strip, @@ -209,23 +207,21 @@ response['errorMessage'] end end def response_error(raw_response, options, action) - begin - response = parse(raw_response) - rescue JSON::ParserError - unparsable_response(raw_response) - else - return Response.new( - false, - message_from(response, options, action), - response, - :test => test?, - :authorization => response['transactionUUID'], - :error_code => response['errorCode'] - ) - end + response = parse(raw_response) + rescue JSON::ParserError + unparsable_response(raw_response) + else + return Response.new( + false, + message_from(response, options, action), + response, + :test => test?, + :authorization => response['transactionUUID'], + :error_code => response['errorCode'] + ) end def unparsable_response(raw_response) message = 'Invalid JSON response received from VisanetPeruGateway. Please contact VisanetPeruGateway if you continue to receive this message.' message += " (The raw response returned by the API was #{raw_response.inspect})"