Class: ActiveMerchant::Billing::Integrations::TwoCheckout::Notification

Inherits:
Notification
  • Object
show all
Defined in:
lib/active_merchant/billing/integrations/two_checkout/notification.rb

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods inherited from Notification

#amount, #empty!, #gross_cents, #initialize, #valid_sender?

Constructor Details

This class inherits a constructor from ActiveMerchant::Billing::Integrations::Notification

Instance Method Details

#acknowledgeObject

Checks against MD5 Hash



118
119
120
121
122
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 118

def acknowledge
  return false if security_key.blank?

  Digest::MD5.hexdigest("#{secret}#{params['sid']}#{transaction_id}#{gross}").upcase == security_key.upcase
end

#complete?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 54

def complete?
  status == 'Completed'
end

#currencyObject

Allow seller to define default currency (should match 2Checkout account pricing currency)



50
51
52
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 50

def currency
    'USD'
end

#grossObject

The money amount we received in X.2 decimal.



92
93
94
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 92

def gross
  params['total']
end

#item_idObject

Third Party Cart parameters will return ‘card_order_id’ Pass Through Product parameters will only return ‘merchant_order_id’



60
61
62
63
64
65
66
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 60

def item_id
  if (params['cart_order_id'].nil?)
    params['merchant_order_id']
  else
    params['cart_order_id']
  end
end

#payer_emailObject

Customer Email



78
79
80
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 78

def payer_email
  params['email']
end

#received_atObject



73
74
75
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 73

def received_at
  params['']
end

#receiver_emailObject



82
83
84
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 82

def receiver_email
  params['']
end

#secretObject

Secret Word defined in 2Checkout account



113
114
115
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 113

def secret
  @options[:credential2]
end

#security_keyObject

The MD5 Hash



87
88
89
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 87

def security_key
  params['key']
end

#statusObject

2Checkout only returns ‘Y’ for this parameter. If the sale is not authorized, no passback occurs.



103
104
105
106
107
108
109
110
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 103

def status
  case params['credit_card_processed']
    when 'Y'
      'Completed'
    else
      'Failed'
  end
end

#test?Boolean

Was this a test transaction? # Use the hash Please note 2Checkout forces the order number computed in the hash to ‘1’ on demo sales.

Returns:

  • (Boolean)


98
99
100
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 98

def test?
  params['demo'] == 'Y'
end

#transaction_idObject

2Checkout Sale ID



69
70
71
# File 'lib/active_merchant/billing/integrations/two_checkout/notification.rb', line 69

def transaction_id
  params['order_number']
end