Class: OffsitePayments::Integrations::Quickpay::Notification
- Inherits:
-
Notification
- Object
- Notification
- OffsitePayments::Integrations::Quickpay::Notification
show all
- Defined in:
- lib/offsite_payments/integrations/quickpay.rb
Constant Summary
collapse
- MD5_CHECK_FIELDS =
[
:msgtype,
:ordernumber,
:amount,
:currency,
:time,
:state,
:qpstat,
:qpstatmsg,
:chstat,
:chstatmsg,
:merchant,
:merchantemail,
:transaction,
:cardtype,
:cardnumber,
:cardhash,
:cardexpire,
:acquirer,
:splitpayment,
:fraudprobability,
:fraudremarks,
:fraudreport,
:fee
]
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
199
200
201
|
# File 'lib/offsite_payments/integrations/quickpay.rb', line 199
def acknowledge(authcode = nil)
generate_md5check == params['md5check']
end
|
#complete? ⇒ Boolean
104
105
106
|
# File 'lib/offsite_payments/integrations/quickpay.rb', line 104
def complete?
status == '000'
end
|
#currency ⇒ Object
135
136
137
|
# File 'lib/offsite_payments/integrations/quickpay.rb', line 135
def currency
params['currency']
end
|
#generate_md5check ⇒ Object
195
196
197
|
# File 'lib/offsite_payments/integrations/quickpay.rb', line 195
def generate_md5check
Digest::MD5.hexdigest(generate_md5string)
end
|
#generate_md5string ⇒ Object
191
192
193
|
# File 'lib/offsite_payments/integrations/quickpay.rb', line 191
def generate_md5string
MD5_CHECK_FIELDS.map { |key| params[key.to_s] } * "" + @options[:credential2].to_s
end
|
#gross ⇒ Object
123
124
125
|
# File 'lib/offsite_payments/integrations/quickpay.rb', line 123
def gross
"%.2f" % (gross_cents / 100.0)
end
|
#gross_cents ⇒ Object
127
128
129
|
# File 'lib/offsite_payments/integrations/quickpay.rb', line 127
def gross_cents
params['amount'].to_i
end
|
#item_id ⇒ Object
108
109
110
|
# File 'lib/offsite_payments/integrations/quickpay.rb', line 108
def item_id
params['ordernumber']
end
|
#parse(post) ⇒ Object
Take the posted data and move the relevant data into a hash
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
# File 'lib/offsite_payments/integrations/quickpay.rb', line 204
def parse(post)
if post =~ /-{20,40}\w{6,24}/
@raw = post.to_s
post.split(/-{20,40}\w{6,24}[\n\r]*/m).each do |part|
part.scan(/([^\n\r]+)[\n\r]+([^\n\r]*)/m) do |, value|
if .match(/name=["'](.*)["']/)
params[$1] = value.strip
end
end
end
else
super
end
end
|
#received_at ⇒ Object
116
117
118
119
120
121
|
# File 'lib/offsite_payments/integrations/quickpay.rb', line 116
def received_at
time = params['time']
time = "20#{params['time']}" if /[0-9]{12}/.match(params['time'])
Time.parse(time)
end
|
#status ⇒ Object
131
132
133
|
# File 'lib/offsite_payments/integrations/quickpay.rb', line 131
def status
params['qpstat']
end
|
#transaction_id ⇒ Object
112
113
114
|
# File 'lib/offsite_payments/integrations/quickpay.rb', line 112
def transaction_id
params['transaction']
end
|