Class: OffsitePayments::Integrations::EasyPay::Notification

Inherits:
Notification
  • Object
show all
Includes:
Common
Defined in:
lib/offsite_payments/integrations/easy_pay.rb

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Common

#generate_signature, #notify_signature_string, #request_signature_string

Methods inherited from Notification

#empty!, #gross_cents, #iso_currency, #test?, #valid_sender?

Constructor Details

#initialize(data, options) ⇒ Notification


87
88
89
90
91
92
93
# File 'lib/offsite_payments/integrations/easy_pay.rb', line 87

def initialize(data, options)
  if options[:credential2].nil?
    raise ArgumentError, "You need to provide the md5 secret as the option :credential2 to verify that the notification originated from EasyPay"
  end

  super
end

Class Method Details

.recognizes?(params) ⇒ Boolean


95
96
97
# File 'lib/offsite_payments/integrations/easy_pay.rb', line 95

def self.recognizes?(params)
  params.has_key?('order_mer_code') && params.has_key?('sum')
end

Instance Method Details

#acknowledge(authcode = nil) ⇒ Object


127
128
129
# File 'lib/offsite_payments/integrations/easy_pay.rb', line 127

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

#amountObject


103
104
105
# File 'lib/offsite_payments/integrations/easy_pay.rb', line 103

def amount
  BigDecimal.new(gross)
end

#complete?Boolean


99
100
101
# File 'lib/offsite_payments/integrations/easy_pay.rb', line 99

def complete?
  true
end

#grossObject


115
116
117
# File 'lib/offsite_payments/integrations/easy_pay.rb', line 115

def gross
  params['sum']
end

#item_idObject


107
108
109
# File 'lib/offsite_payments/integrations/easy_pay.rb', line 107

def item_id
  params['order_mer_code']
end

#secretObject


123
124
125
# File 'lib/offsite_payments/integrations/easy_pay.rb', line 123

def secret
  @options[:credential2]
end

#security_keyObject


111
112
113
# File 'lib/offsite_payments/integrations/easy_pay.rb', line 111

def security_key
  params[OffsitePayments::Integrations::EasyPay.notify_signature_parameter_name]
end

#statusObject


119
120
121
# File 'lib/offsite_payments/integrations/easy_pay.rb', line 119

def status
  'Completed'
end

#success_response(*args) ⇒ Object


131
132
133
# File 'lib/offsite_payments/integrations/easy_pay.rb', line 131

def success_response(*args)
  { :nothing => true }
end