Class: OffsitePayments::Integrations::Rbkmoney::Notification

Inherits:
Notification
  • Object
show all
Defined in:
lib/offsite_payments/integrations/rbkmoney.rb

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods inherited from Notification

#amount, #empty!, #gross_cents, #initialize, #iso_currency, #valid_sender?

Constructor Details

This class inherits a constructor from OffsitePayments::Notification

Instance Method Details

#acknowledge(authcode = nil) ⇒ Object


81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/offsite_payments/integrations/rbkmoney.rb', line 81

def acknowledge(authcode = nil)
  string = [
    eshop_id,
    order_id,
    service_name,
    ,
    recipient_amount,
    recipient_currency,
    payment_status,
    user_name,
    user_email,
    payment_data,
    @options[:secret]
  ].join '::'

  signature = case hash.to_s.length
  when 32
    Digest::MD5.hexdigest(string)
  when 128
    Digest::SHA512.hexdigest(string)
  else
    return false
  end

  signature == hash
end

#complete?Boolean


46
47
48
# File 'lib/offsite_payments/integrations/rbkmoney.rb', line 46

def complete?
  (payment_status == '5')
end

#statusObject


54
55
56
57
58
59
60
61
62
# File 'lib/offsite_payments/integrations/rbkmoney.rb', line 54

def status
  case payment_status
  when '3'
    'pending'
  when '5'
    'completed'
  else 'unknown'
  end
end

#test?Boolean


50
51
52
# File 'lib/offsite_payments/integrations/rbkmoney.rb', line 50

def test?
  false
end

#user_fieldsObject


64
65
66
67
68
69
70
71
# File 'lib/offsite_payments/integrations/rbkmoney.rb', line 64

def user_fields
  params.inject({}) do |fields, (k,v)|
    if /\AuserField_[\d+]\z/.match(k)
      fields[k] = v
    end
    fields
  end
end