lib/active_merchant/billing/gateways/mercado_pago.rb in activemerchant-1.85.0 vs lib/active_merchant/billing/gateways/mercado_pago.rb in activemerchant-1.86.0

- old
+ new

@@ -184,10 +184,16 @@ post[:payment_method_id] = options[:card_brand] end def parse(body) JSON.parse(body) + rescue JSON::ParserError + { + 'status' => 'error', + 'status_detail' => 'json_parse_error', + 'message' => "A non-JSON response was received from Mercado Pago where one was expected. The raw response was:\n\n#{body}" + } end def commit(action, path, parameters) if ['capture', 'void'].include?(action) response = parse(ssl_request(:put, url(path), post_data(parameters), headers)) @@ -205,10 +211,10 @@ ) end def success_from(action, response) if action == 'refund' - response['error'].nil? + response['status'] != 404 && response['error'].nil? else ['active', 'approved', 'authorized', 'cancelled', 'in_process'].include?(response['status']) end end