Class: ActiveMerchant::Billing::Integrations::Moneybookers::Notification

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

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

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

#acknowledge(secret = '') ⇒ Object

Acknowledge the transaction to MoneyBooker. This method has to be called after a new apc arrives. It will verify that all the information we received is correct and will return a ok or a fail.

Example:

def ipn
  notify = Moneybookers::Notification.new(request.raw_post)

  if notify.acknowledge('secretpass')
    ... process order ... if notify.complete?
  else
    ... log possible hacking attempt ...
  end


93
94
95
96
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 93

def acknowledge(secret = '')
  fields = [merchant_id, transaction_id, Digest::MD5.hexdigest(secret).upcase, gross, currency, status].join
  md5sig == Digest::MD5.hexdigest(fields).upcase
end

#complete?Boolean

was the transaction comlete?

Returns:

  • (Boolean)


12
13
14
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 12

def complete?
  status == "2"
end

#currencyObject

currency of mb_amount, will always be the same as the currency of the beneficiary’s account at Moneybookers.com



55
56
57
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 55

def currency
  params['mb_currency']
end

#grossObject

total amount of the payment in Merchants currency (ex 25.46/25.4/25)



60
61
62
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 60

def gross
  params['mb_amount']
end

#item_idObject



20
21
22
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 20

def item_id
  nil
end

#md5sigObject



45
46
47
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 45

def md5sig
  params['md5sig']
end

#merchant_idObject

Unique ID from the merchant’s Moneybookers.com account, needed for calculatinon of md5 sig



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

def merchant_id
  params['merchant_id']
end

#payer_emailObject



37
38
39
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 37

def payer_email
  params['pay_from_email']
end

#posted_amountObject

amount of the payment as posted by the merchant on the entry form (ex. 39.60/39.6/39)



70
71
72
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 70

def posted_amount
  params['amount']
end

#posted_currencyObject

currency of the payment as posted by the merchant on the entry form



65
66
67
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 65

def posted_currency
  params['currency']
end

#received_atObject

When was this payment received by the client.



33
34
35
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 33

def received_at
  nil
end

#receiver_emailObject



41
42
43
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 41

def receiver_email
  params['pay_to_email']
end

#statusObject



16
17
18
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 16

def status
  params['status']
end

#test?Boolean

Was this a test transaction?

Returns:

  • (Boolean)


75
76
77
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 75

def test?
  false
end

#transaction_idObject



24
25
26
27
28
29
30
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 24

def transaction_id
  if params.has_key?("transaction_id")
    params['transaction_id']
  else
    params['mb_transaction_id']
  end
end