Class: Moneybookers::PaymentGateway::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/moneybookers/payment_gateway/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Response

Returns a new instance of Response.

Raises:

  • (ArgumentError)


5
6
7
8
# File 'lib/moneybookers/payment_gateway/response.rb', line 5

def initialize(params)
  raise ArgumentError.new("Params must be passed as a hash") unless params.kind_of?(Hash)
  @params = params
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'lib/moneybookers/payment_gateway/response.rb', line 3

def params
  @params
end

Instance Method Details

#amountObject



36
37
38
# File 'lib/moneybookers/payment_gateway/response.rb', line 36

def amount
  params["mb_amount"]
end

#currencyObject



40
41
42
# File 'lib/moneybookers/payment_gateway/response.rb', line 40

def currency
  params["mb_currency"]
end

#mb_transaction_idObject



44
45
46
# File 'lib/moneybookers/payment_gateway/response.rb', line 44

def mb_transaction_id
  params["mb_transaction_id"]
end

#pay_on_demand_authorized?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/moneybookers/payment_gateway/response.rb', line 28

def pay_on_demand_authorized?
  processed? and (params["rec_payment_type"] == "on-demand")
end

#pay_on_demand_idObject



32
33
34
# File 'lib/moneybookers/payment_gateway/response.rb', line 32

def pay_on_demand_id
  params["rec_payment_id"] if pay_on_demand_authorized?
end

#processed?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/moneybookers/payment_gateway/response.rb', line 24

def processed?
  status == "processed"
end

#signature_verified?(args = {}) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/moneybookers/payment_gateway/response.rb', line 48

def signature_verified?(args={})
  Moneybookers::Signature::Status.new(signature_params.merge(args)).match?(params["md5sig"])
end

#statusObject



14
15
16
17
18
19
20
21
22
# File 'lib/moneybookers/payment_gateway/response.rb', line 14

def status
  case status_code
    when "2"  then "processed"
    when "0"  then "pending"
    when "-1" then "cancelled"
    when "-2" then "failed"
    when "-3" then "chargeback"
  end
end

#status_codeObject



10
11
12
# File 'lib/moneybookers/payment_gateway/response.rb', line 10

def status_code
  params["status"]
end