Class: OffsitePayments::Integrations::QuickpayV10::Notification

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

Overview

credential3: private key checksum_header: QuickPay-Checksum-Sha256 request header value

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods inherited from Notification

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

Constructor Details

This class inherits a constructor from OffsitePayments::Notification

Instance Method Details

#acknowledge(authcode = nil) ⇒ Object

Quickpay doesn’t do acknowledgements of callback notifications Instead it provides a SHA256 checksum header



161
162
163
# File 'lib/offsite_payments/integrations/quickpay_v10.rb', line 161

def acknowledge(authcode = nil)
  generate_checksum == checksum_header
end

#checksum_headerObject



155
156
157
# File 'lib/offsite_payments/integrations/quickpay_v10.rb', line 155

def checksum_header
  @options[:checksum_header]
end

#complete?Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/offsite_payments/integrations/quickpay_v10.rb', line 102

def complete?
  status == '20000'
end

#generate_checksumObject



151
152
153
# File 'lib/offsite_payments/integrations/quickpay_v10.rb', line 151

def generate_checksum
  OpenSSL::HMAC.hexdigest('sha256', @options[:credential3], @raw)
end

#grossObject



118
119
120
# File 'lib/offsite_payments/integrations/quickpay_v10.rb', line 118

def gross
  "%.2f" % (gross_cents / 100.0)
end

#gross_centsObject



122
123
124
# File 'lib/offsite_payments/integrations/quickpay_v10.rb', line 122

def gross_cents
  last_operation['amount']
end

#item_idObject



106
107
108
# File 'lib/offsite_payments/integrations/quickpay_v10.rb', line 106

def item_id
  params['order_id']
end

#last_operationObject



126
127
128
# File 'lib/offsite_payments/integrations/quickpay_v10.rb', line 126

def last_operation
  params['operations'].last
end

#parse(post) ⇒ Object

Take the posted data and move the relevant data into a hash



166
167
168
169
# File 'lib/offsite_payments/integrations/quickpay_v10.rb', line 166

def parse(post)
  @raw = post.to_s
  @params = JSON.parse(post)
end

#received_atObject



114
115
116
# File 'lib/offsite_payments/integrations/quickpay_v10.rb', line 114

def received_at
  Time.iso8601(params['created_at'])
end

#statusObject



130
131
132
# File 'lib/offsite_payments/integrations/quickpay_v10.rb', line 130

def status
  last_operation['qp_status_code'] if last_operation
end

#transaction_idObject



110
111
112
# File 'lib/offsite_payments/integrations/quickpay_v10.rb', line 110

def transaction_id
  params['id']
end