class OffsitePayments::Integrations::TwoCheckout::Notification
Public Instance Methods
acknowledge(authcode = nil)
click to toggle source
Checks against MD5 Hash
# File lib/offsite_payments/integrations/two_checkout.rb, line 246 def acknowledge(authcode = nil) return false if security_key.blank? if ins_message? Digest::MD5.hexdigest("#{ transaction_id }#{ params['vendor_id'] }#{ invoice_id }#{ secret }").upcase == security_key.upcase elsif passback? order_number = params['demo'] == 'Y' ? 1 : params['order_number'] Digest::MD5.hexdigest("#{ secret }#{ params['sid'] }#{ order_number }#{ gross }").upcase == params['key'].upcase else false end end
complete?()
click to toggle source
# File lib/offsite_payments/integrations/two_checkout.rb, line 187 def complete? status == 'Completed' end
currency()
click to toggle source
Seller currency sale was placed in
# File lib/offsite_payments/integrations/two_checkout.rb, line 183 def currency params['list_currency'] end
gross()
click to toggle source
The money amount we received in X.2 decimal. passback || INS gross amount for new orders || default INS gross
# File lib/offsite_payments/integrations/two_checkout.rb, line 222 def gross params['invoice_list_amount'] || params['total'] || params['item_list_amount_1'] end
invoice_id()
click to toggle source
2Checkout Invoice ID
# File lib/offsite_payments/integrations/two_checkout.rb, line 202 def invoice_id params['invoice_id'] end
item_id()
click to toggle source
The value passed with ‘merchant_order_id’ is passed back as ‘vendor_order_id’
# File lib/offsite_payments/integrations/two_checkout.rb, line 192 def item_id params['vendor_order_id'] || params['merchant_order_id'] end
payer_email()
click to toggle source
Customer Email
# File lib/offsite_payments/integrations/two_checkout.rb, line 211 def payer_email params['customer_email'] end
received_at()
click to toggle source
# File lib/offsite_payments/integrations/two_checkout.rb, line 206 def received_at params['timestamp'] end
secret()
click to toggle source
Secret Word defined in 2Checkout account
# File lib/offsite_payments/integrations/two_checkout.rb, line 241 def secret @options[:credential2] end
security_key()
click to toggle source
The MD5 Hash
# File lib/offsite_payments/integrations/two_checkout.rb, line 216 def security_key params['md5_hash'] || params['key'] end
status()
click to toggle source
Determine status based on parameter set, if the params include a fraud status we know we’re being notified of the finalization of an order (an INS message) If the params include ‘credit_card_processed’ we know we’re being notified of a new order being inbound, which we handle in the deferred demo sale scenario.
# File lib/offsite_payments/integrations/two_checkout.rb, line 230 def status if params['fraud_status'] == 'pass' || params['credit_card_processed'] == 'Y' 'Completed' elsif params['fraud_status'] == 'wait' 'Pending' else 'Failed' end end
transaction_id()
click to toggle source
2Checkout Sale ID
# File lib/offsite_payments/integrations/two_checkout.rb, line 197 def transaction_id params['sale_id'] || params['order_number'] end
type()
click to toggle source
INS message type
# File lib/offsite_payments/integrations/two_checkout.rb, line 178 def type params['message_type'] end
Private Instance Methods
ins_message?()
click to toggle source
# File lib/offsite_payments/integrations/two_checkout.rb, line 269 def ins_message? params.include? 'message_type' end
parse(post)
click to toggle source
Parses Header Redirect Query String
# File lib/offsite_payments/integrations/two_checkout.rb, line 261 def parse(post) @raw = post.to_s for line in @raw.split('&') key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten params[key] = CGI.unescape(value || '') end end
passback?()
click to toggle source
# File lib/offsite_payments/integrations/two_checkout.rb, line 273 def passback? params.include? 'credit_card_processed' end