Class: OffsitePayments::Integrations::Megakassa::Notification

Inherits:
Notification
  • Object
show all
Defined in:
lib/offsite_payments/integrations/megakassa.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, #test?, #valid_sender?

Constructor Details

This class inherits a constructor from OffsitePayments::Notification

Instance Method Details

#acknowledge(authcode = nil) ⇒ Object



164
165
166
# File 'lib/offsite_payments/integrations/megakassa.rb', line 164

def acknowledge(authcode = nil)
  security_key == generate_signature
end

#amount_clientObject



128
129
130
# File 'lib/offsite_payments/integrations/megakassa.rb', line 128

def amount_client
  Money.new(gross_client_cents, currency)
end

#amount_shopObject



116
117
118
# File 'lib/offsite_payments/integrations/megakassa.rb', line 116

def amount_shop
  Money.new(gross_shop_cents, currency)
end

#client_emailObject



148
149
150
# File 'lib/offsite_payments/integrations/megakassa.rb', line 148

def client_email
  params['client_email']
end

#complete?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/offsite_payments/integrations/megakassa.rb', line 96

def complete?
  true
end

#currencyObject



132
133
134
# File 'lib/offsite_payments/integrations/megakassa.rb', line 132

def currency
  params['currency']
end

#generate_signatureObject



92
93
94
# File 'lib/offsite_payments/integrations/megakassa.rb', line 92

def generate_signature
  Digest::MD5.hexdigest(generate_signature_string)
end

#generate_signature_stringObject



88
89
90
# File 'lib/offsite_payments/integrations/megakassa.rb', line 88

def generate_signature_string
  "#{uid}:#{gross}:#{gross_shop}:#{gross_client}:#{currency}:#{order_id}:#{payment_method_id}:#{payment_method_title}:#{client_email}:#{secret}"
end

#grossObject



104
105
106
# File 'lib/offsite_payments/integrations/megakassa.rb', line 104

def gross
  params['amount']
end

#gross_clientObject



120
121
122
# File 'lib/offsite_payments/integrations/megakassa.rb', line 120

def gross_client
  params['amount_client']
end

#gross_client_centsObject



124
125
126
# File 'lib/offsite_payments/integrations/megakassa.rb', line 124

def gross_client_cents
  (gross_client.to_f * 100.0).round
end

#gross_shopObject



108
109
110
# File 'lib/offsite_payments/integrations/megakassa.rb', line 108

def gross_shop
  params['amount_shop']
end

#gross_shop_centsObject



112
113
114
# File 'lib/offsite_payments/integrations/megakassa.rb', line 112

def gross_shop_cents
  (gross_shop.to_f * 100.0).round
end

#order_idObject



136
137
138
# File 'lib/offsite_payments/integrations/megakassa.rb', line 136

def order_id
  params['order_id']
end

#payment_method_idObject



140
141
142
# File 'lib/offsite_payments/integrations/megakassa.rb', line 140

def payment_method_id
  params['payment_method_id']
end

#payment_method_titleObject



144
145
146
# File 'lib/offsite_payments/integrations/megakassa.rb', line 144

def payment_method_title
  params['payment_method_title']
end

#secretObject



160
161
162
# File 'lib/offsite_payments/integrations/megakassa.rb', line 160

def secret
  @options[:secret]
end

#security_keyObject



152
153
154
# File 'lib/offsite_payments/integrations/megakassa.rb', line 152

def security_key
  params[OffsitePayments::Integrations::Megakassa.signature_parameter_name].to_s
end

#statusObject



156
157
158
# File 'lib/offsite_payments/integrations/megakassa.rb', line 156

def status
  'success'
end

#success_response(*args) ⇒ Object



168
169
170
# File 'lib/offsite_payments/integrations/megakassa.rb', line 168

def success_response(*args)
  'ok'
end

#uidObject



100
101
102
# File 'lib/offsite_payments/integrations/megakassa.rb', line 100

def uid
  params['uid']
end