89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/active_merchant/billing/gateways/worldpay.rb', line 89
def refund(money, authorization, options = {})
authorization = order_id_from_authorization(authorization.to_s)
success_criteria = %w(CAPTURED SETTLED SETTLED_BY_MERCHANT SENT_FOR_REFUND)
success_criteria.push('AUTHORIZED') if options[:cancel_or_refund]
response = MultiResponse.run do |r|
r.process { inquire_request(authorization, options, *success_criteria) } unless options[:authorization_validated]
r.process { refund_request(money, authorization, options) }
end
if !response.success? && options[:force_full_refund_if_unsettled] &&
response.params['last_event'] == 'AUTHORISED'
void(authorization, options)
else
response
end
end
|