lib/active_merchant/billing/gateways/paymill.rb in activemerchant-1.38.1 vs lib/active_merchant/billing/gateways/paymill.rb in activemerchant-1.39.0

- old
+ new

@@ -55,10 +55,14 @@ post[:amount] = amount(money) post[:description] = options[:description] commit(:post, "refunds/#{transaction_id(authorization)}", post) end + def void(authorization, options={}) + commit(:delete, "preauthorizations/#{preauth(authorization)}") + end + def store(credit_card, options={}) save_card(credit_card) end private @@ -95,22 +99,26 @@ Response.new(true, 'Transaction approved', parsed, options) end def authorization_from(parsed_response) + parsed_data = parsed_response['data'] + return '' unless parsed_data.kind_of?(Hash) + [ - parsed_response['data']['id'], - parsed_response['data']['preauthorization'].try(:[], 'id') + parsed_data['id'], + parsed_data['preauthorization'].try(:[], 'id') ].join(";") end def purchase_with_token(money, card_token, options) post = {} add_amount(post, money, options) post[:token] = card_token post[:description] = options[:description] + post[:client] = options[:customer] commit(:post, 'transactions', post) end def authorize_with_token(money, card_token, options) post = {} @@ -156,9 +164,11 @@ def save_card_url (test? ? 'https://test-token.paymill.com' : 'https://token-v2.paymill.de') end def post_data(params) + return nil unless params + no_blanks = params.reject { |key, value| value.blank? } no_blanks.map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") end def add_amount(post, money, options)