Class: OffsitePayments::Integrations::QuickpayV10::Notification
- Inherits:
-
Notification
- Object
- Notification
- OffsitePayments::Integrations::QuickpayV10::Notification
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
#amount, #empty!, #initialize, #iso_currency, #test?, #valid_sender?
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 ==
end
|
155
156
157
|
# File 'lib/offsite_payments/integrations/quickpay_v10.rb', line 155
def
@options[:checksum_header]
end
|
#complete? ⇒ Boolean
102
103
104
|
# File 'lib/offsite_payments/integrations/quickpay_v10.rb', line 102
def complete?
status == '20000'
end
|
#generate_checksum ⇒ Object
151
152
153
|
# File 'lib/offsite_payments/integrations/quickpay_v10.rb', line 151
def generate_checksum
OpenSSL::HMAC.hexdigest('sha256', @options[:credential3], @raw)
end
|
#gross ⇒ Object
118
119
120
|
# File 'lib/offsite_payments/integrations/quickpay_v10.rb', line 118
def gross
"%.2f" % (gross_cents / 100.0)
end
|
#gross_cents ⇒ Object
122
123
124
|
# File 'lib/offsite_payments/integrations/quickpay_v10.rb', line 122
def gross_cents
last_operation['amount']
end
|
#item_id ⇒ Object
106
107
108
|
# File 'lib/offsite_payments/integrations/quickpay_v10.rb', line 106
def item_id
params['order_id']
end
|
#last_operation ⇒ Object
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_at ⇒ Object
114
115
116
|
# File 'lib/offsite_payments/integrations/quickpay_v10.rb', line 114
def received_at
Time.iso8601(params['created_at'])
end
|
#status ⇒ Object
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_id ⇒ Object
110
111
112
|
# File 'lib/offsite_payments/integrations/quickpay_v10.rb', line 110
def transaction_id
params['id']
end
|