Class: ActiveMerchant::Billing::Integrations::TwoCheckout::Notification
- Inherits:
-
Notification
- Object
- Notification
- ActiveMerchant::Billing::Integrations::TwoCheckout::Notification
- Defined in:
- lib/active_merchant/billing/integrations/two_checkout/notification.rb
Instance Attribute Summary
Attributes inherited from Notification
Instance Method Summary collapse
-
#acknowledge(authcode = nil) ⇒ Object
Checks against MD5 Hash.
- #complete? ⇒ Boolean
-
#currency ⇒ Object
Seller currency sale was placed in.
-
#gross ⇒ Object
The money amount we received in X.2 decimal.
-
#invoice_id ⇒ Object
2Checkout Invoice ID.
-
#item_id ⇒ Object
The value passed with ‘merchant_order_id’ is passed back as ‘vendor_order_id’.
-
#payer_email ⇒ Object
Customer Email.
- #received_at ⇒ Object
-
#secret ⇒ Object
Secret Word defined in 2Checkout account.
-
#security_key ⇒ Object
The MD5 Hash.
-
#status ⇒ Object
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.
-
#transaction_id ⇒ Object
2Checkout Sale ID.
-
#type ⇒ Object
INS message type.
Methods inherited from Notification
#amount, #empty!, #gross_cents, #initialize, #test?, #valid_sender?
Constructor Details
This class inherits a constructor from ActiveMerchant::Billing::Integrations::Notification
Instance Method Details
#acknowledge(authcode = nil) ⇒ Object
Checks against MD5 Hash
137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 137 def acknowledge(authcode = nil) return false if security_key.blank? if 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? ⇒ Boolean
78 79 80 |
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 78 def complete? status == 'Completed' end |
#currency ⇒ Object
Seller currency sale was placed in
74 75 76 |
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 74 def currency params['list_currency'] end |
#gross ⇒ Object
The money amount we received in X.2 decimal. passback || INS gross amount for new orders || default INS gross
113 114 115 |
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 113 def gross params['invoice_list_amount'] || params['total'] || params['item_list_amount_1'] end |
#invoice_id ⇒ Object
2Checkout Invoice ID
93 94 95 |
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 93 def invoice_id params['invoice_id'] end |
#item_id ⇒ Object
The value passed with ‘merchant_order_id’ is passed back as ‘vendor_order_id’
83 84 85 |
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 83 def item_id params['vendor_order_id'] || params['merchant_order_id'] end |
#payer_email ⇒ Object
Customer Email
102 103 104 |
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 102 def payer_email params['customer_email'] end |
#received_at ⇒ Object
97 98 99 |
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 97 def received_at params['timestamp'] end |
#secret ⇒ Object
Secret Word defined in 2Checkout account
132 133 134 |
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 132 def secret @options[:credential2] end |
#security_key ⇒ Object
The MD5 Hash
107 108 109 |
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 107 def security_key params['md5_hash'] || params['key'] end |
#status ⇒ Object
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.
121 122 123 124 125 126 127 128 129 |
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 121 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 ⇒ Object
2Checkout Sale ID
88 89 90 |
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 88 def transaction_id params['sale_id'] || params['order_number'] end |
#type ⇒ Object
INS message type
69 70 71 |
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 69 def type params['message_type'] end |