lib/active_merchant/billing/gateways/mundipagg.rb in activemerchant-1.124.0 vs lib/active_merchant/billing/gateways/mundipagg.rb in activemerchant-1.125.0
- old
+ new
@@ -274,18 +274,18 @@
else
parse(ssl_post(url, post_data(parameters), headers(authorization_secret_key)))
end
Response.new(
- success_from(response),
+ success_from(response, action),
message_from(response),
response,
authorization: authorization_from(response, action),
avs_result: AVSResult.new(code: response['some_avs_response_key']),
cvv_result: CVVResult.new(response['some_cvv_response_key']),
test: test?,
- error_code: error_code_from(response)
+ error_code: error_code_from(response, action)
)
rescue ResponseError => e
message = get_error_messages(e)
return Response.new(
@@ -295,12 +295,14 @@
test: test?,
error_code: STANDARD_ERROR_CODE_MAPPING[e.response.code]
)
end
- def success_from(response)
- %w[pending paid processing canceled active].include? response['status']
+ def success_from(response, action)
+ success = response.try(:[], 'last_transaction').try(:[], 'success') unless action == 'store'
+ success = !response.try(:[], 'id').nil? if action == 'store'
+ success
end
def message_from(response)
return gateway_response_errors(response) if gateway_response_errors?(response)
return response['message'] if response['message']
@@ -348,11 +350,11 @@
def post_data(parameters = {})
parameters.to_json
end
- def error_code_from(response)
- return if success_from(response)
+ def error_code_from(response, action)
+ return if success_from(response, action)
return response['last_transaction']['acquirer_return_code'] if response['last_transaction']
STANDARD_ERROR_CODE[:processing_error]
end
end