lib/active_merchant/billing/gateways/paymill.rb in activemerchant-1.31.1 vs lib/active_merchant/billing/gateways/paymill.rb in activemerchant-1.32.0

- old
+ new

@@ -1,10 +1,11 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class PaymillGateway < Gateway - self.supported_countries = %w(AT BE CH CZ DE DK EE ES FI FR GB HU IE - IS IT LI LU LV NL NO PL PT SE SI TR) + self.supported_countries = %w(AD AT BE CY CZ DE DK EE ES FI FO FR GB GR + HU IE IL IS IT LI LT LU LV MT NL NO PL PT + SE SI SK TR VA) self.supported_cardtypes = [:visa, :master] self.homepage_url = 'https://paymill.com' self.display_name = 'Paymill' self.money_format = :cents @@ -121,23 +122,26 @@ response_for_save_from(raw_response) end def response_for_save_from(raw_response) - parsed = JSON.parse(raw_response.sub(/jsonPFunction\(/, '').sub(/\)\z/, '')) - succeeded = parsed['transaction']['processing']['result'] == 'ACK' - options = { :test => test? } - if succeeded - options[:authorization] = parsed['transaction']['identification']['uniqueId'] + + parsed = JSON.parse(raw_response.sub(/jsonPFunction\(/, '').sub(/\)\z/, '')) + if parsed['error'] + succeeded = false + message = parsed['error']['message'] + else + succeeded = parsed['transaction']['processing']['result'] == 'ACK' + message = parsed['transaction']['processing']['return']['message'] + options[:authorization] = parsed['transaction']['identification']['uniqueId'] if succeeded end - message = parsed['transaction']['processing']['return']['message'] Response.new(succeeded, message, parsed, options) end def save_card_url - (test? ? 'https://test-token.paymill.de' : 'https://token-v2.paymill.de') + (test? ? 'https://test-token.paymill.com' : 'https://token-v2.paymill.com') end def post_data(params) no_blanks = params.reject { |key, value| value.blank? } no_blanks.map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")