class ActiveMerchant::Billing::PaymillGateway::ResponseParser

Attributes

message[R]
options[R]
parsed[R]
raw_response[R]
succeeded[R]

Public Class Methods

new(raw_response='', options={}) click to toggle source
# File lib/active_merchant/billing/gateways/paymill.rb, line 331
def initialize(raw_response='', options={})
  @raw_response = raw_response
  @options = options
end

Public Instance Methods

generate_response() click to toggle source
# File lib/active_merchant/billing/gateways/paymill.rb, line 336
def generate_response
  parse_response
  if parsed['error']
    handle_response_parse_error
  else
    handle_response_correct_parsing
  end

  Response.new(succeeded, message, parsed, options)
end

Private Instance Methods

handle_response_correct_parsing() click to toggle source
# File lib/active_merchant/billing/gateways/paymill.rb, line 358
def handle_response_correct_parsing
  @message = parsed['transaction']['processing']['return']['message']
  if @succeeded = is_ack?
    @options[:authorization] = parsed['transaction']['identification']['uniqueId']
  end
end
handle_response_parse_error() click to toggle source
# File lib/active_merchant/billing/gateways/paymill.rb, line 353
def handle_response_parse_error
  @succeeded = false
  @message = parsed['error']['message']
end
is_ack?() click to toggle source
# File lib/active_merchant/billing/gateways/paymill.rb, line 365
def is_ack?
  parsed['transaction']['processing']['result'] == 'ACK'
end
parse_response() click to toggle source
# File lib/active_merchant/billing/gateways/paymill.rb, line 349
def parse_response
  @parsed = JSON.parse(raw_response.sub(/jsonPFunction\(/, '').sub(/\)\z/, ''))
end