Class: Payonline::PaymentResponse

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/payonline/payment_response.rb

Constant Summary collapse

SIGNED_PARAMS =
i(date_time transaction_id order_id amount currency)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ PaymentResponse

Returns a new instance of PaymentResponse.



11
12
13
14
# File 'lib/payonline/payment_response.rb', line 11

def initialize(params = {})
  @params = prepare_params(params)
  @data = OpenStruct.new(@params)
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



5
6
7
# File 'lib/payonline/payment_response.rb', line 5

def data
  @data
end

#paramsObject

Returns the value of attribute params.



5
6
7
# File 'lib/payonline/payment_response.rb', line 5

def params
  @params
end

Instance Method Details

#valid_payment?Boolean

Returns:

  • (Boolean)


16
17
18
19
# File 'lib/payonline/payment_response.rb', line 16

def valid_payment?
  keys = SIGNED_PARAMS.select { |key| @params.key?(key) }
  @params[:security_key] == Payonline::Signature.new(@params, keys, false).digest
end