class Datatrans::Web::Transaction::AuthorizeResponse

Attributes

datatrans[RW]
params[RW]

Public Class Methods

new(datatrans, params) click to toggle source
# File lib/datatrans/web/transaction/authorize.rb, line 5
def initialize(datatrans, params)
  @datatrans = datatrans
  @params = params
end

Public Instance Methods

authorization_code() click to toggle source
# File lib/datatrans/web/transaction/authorize.rb, line 37
def authorization_code
  params[:authorizationCode] rescue nil
end
creditcard_alias() click to toggle source
# File lib/datatrans/web/transaction/authorize.rb, line 57
def creditcard_alias
  params[:aliasCC] rescue nil
end
error_code() click to toggle source
# File lib/datatrans/web/transaction/authorize.rb, line 61
def error_code
  params[:errorCode] rescue nil
end
error_detail() click to toggle source
# File lib/datatrans/web/transaction/authorize.rb, line 69
def error_detail
  params[:errorDetail] rescue nil
end
error_message() click to toggle source
# File lib/datatrans/web/transaction/authorize.rb, line 65
def error_message
  params[:errorMessage] rescue nil
end
exp_month() click to toggle source
# File lib/datatrans/web/transaction/authorize.rb, line 53
def exp_month
  params[:expm] rescue nil
end
exp_year() click to toggle source
# File lib/datatrans/web/transaction/authorize.rb, line 49
def exp_year
  params[:expy] rescue nil
end
masked_cc() click to toggle source
# File lib/datatrans/web/transaction/authorize.rb, line 45
def masked_cc
  params[:maskedCC] rescue nil
end
payment_method() click to toggle source
# File lib/datatrans/web/transaction/authorize.rb, line 41
def payment_method
  params[:pmethod] rescue nil
end
reference_number() click to toggle source
# File lib/datatrans/web/transaction/authorize.rb, line 33
def reference_number
  params[:refno] rescue nil
end
response_code() click to toggle source
# File lib/datatrans/web/transaction/authorize.rb, line 21
def response_code
  params[:responseCode] rescue nil
end
response_message() click to toggle source
# File lib/datatrans/web/transaction/authorize.rb, line 25
def response_message
  params[:responseMessage] rescue nil
end
successful?() click to toggle source
# File lib/datatrans/web/transaction/authorize.rb, line 10
def successful?
  raise Datatrans::InvalidSignatureError unless valid_signature?
  response_code == '01' && response_message == 'Authorized' && !errors_occurred?
end
transaction_id() click to toggle source
# File lib/datatrans/web/transaction/authorize.rb, line 29
def transaction_id
  params[:uppTransactionId] rescue nil
end
valid_signature?() click to toggle source
# File lib/datatrans/web/transaction/authorize.rb, line 15
def valid_signature?
  # TODO: does not make sense... true if errors?
  return true if errors_occurred? # no sign2 sent on error
  sign(self.datatrans.merchant_id, params[:amount], params[:currency], params[:uppTransactionId]) == params[:sign2]
end

Private Instance Methods

errors_occurred?() click to toggle source
# File lib/datatrans/web/transaction/authorize.rb, line 76
def errors_occurred?
  error_code || error_message || error_detail
end