lib/active_merchant/billing/gateways/clearhaus.rb in activemerchant-1.60.0 vs lib/active_merchant/billing/gateways/clearhaus.rb in activemerchant-1.61.0

- old
+ new

@@ -8,10 +8,11 @@ self.supported_countries = ['DK', 'NO', 'SE', 'FI', 'DE', 'CH', 'NL', 'AD', 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'FO', 'GL', 'EE', 'FR', 'GR', 'HU', 'IS', 'IE', 'IT', 'LV', 'LI', 'LT', 'LU', 'MT', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'GB'] self.default_currency = 'EUR' + self.currencies_without_fractions = %w(BIF BYR DJF GNF JPY KMF KRW PYG RWF VND VUV XAF XOF XPF) self.supported_cardtypes = [:visa, :master] self.homepage_url = 'https://www.clearhaus.com' self.display_name = 'Clearhaus' self.money_format = :cents @@ -119,11 +120,11 @@ post[:reference] = options[:order_id] if options[:order_id] post[:text_on_statement] = options[:text_on_statement] if options[:text_on_statement] end def add_amount(post, amount, options) - post[:amount] = amount(amount) + post[:amount] = localized_amount(amount, options[:currency] || default_currency) post[:currency] = (options[:currency] || default_currency) end def add_payment(post, payment) card = {} @@ -171,11 +172,11 @@ Response.new( success_from(response), message_from(response), response, - authorization: authorization_from(response), + authorization: authorization_from(action, response), test: test?, error_code: error_code_from(response) ) end @@ -191,11 +192,18 @@ else (response['status']['message'] || default_message) end end - def authorization_from(response) - response['id'] + def authorization_from(action, response) + id_of_auth_for_capture(action) || response['id'] + end + + def id_of_auth_for_capture(action) + match = action.match(/authorizations\/(.+)\/captures/) + return nil unless match + + match.captures.first end def generate_signature(body) key = OpenSSL::PKey::RSA.new(@options[:private_key]) hex = key.sign(OpenSSL::Digest.new('sha256'), body).unpack('H*').first