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

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

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods inherited from Notification

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

Constructor Details

#initialize(data, options) ⇒ Notification

Returns a new instance of Notification.



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

def initialize(data, options)
  if options[:credential2].nil?
    raise ArgumentError, "You need to provide the md5 secret as the option :credential2 to verify that the notification originated from Moneybookers"
  end
  super
end

Instance Method Details

#acknowledgeObject

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. The secret (second credential) has to be provided in the parameter :credential2 when instantiating the Notification object.

Example:

def ipn
  notify = Moneybookers.notification(request.raw_post, :credential2 => 'secret')

  if notify.acknowledge
    ... process order ... if notify.complete?
  else
    ... log possible hacking attempt ...
  end


121
122
123
124
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 121

def acknowledge
  fields = [merchant_id, item_id, Digest::MD5.hexdigest(secret).upcase, merchant_amount, merchant_currency, status_code].join
  md5sig == Digest::MD5.hexdigest(fields).upcase
end

#complete?Boolean

Returns:

  • (Boolean)


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

def complete?
  status == 'Completed'
end

#currencyObject

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



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

def currency
  params['currency']
end

#grossObject

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



83
84
85
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 83

def gross
  params['amount']
end

#item_idObject



47
48
49
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 47

def item_id
  params['transaction_id']
end

#md5sigObject



68
69
70
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 68

def md5sig
  params['md5sig']
end

#merchant_amountObject

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



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

def merchant_amount
  params['mb_amount']
end

#merchant_currencyObject

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



88
89
90
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 88

def merchant_currency
  params['mb_currency']
end

#merchant_idObject

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



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

def merchant_id
  params['merchant_id']
end

#payer_emailObject



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

def payer_email
  params['pay_from_email']
end

#received_atObject

When was this payment received by the client.



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

def received_at
  nil
end

#receiver_emailObject



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

def receiver_email
  params['pay_to_email']
end

#secretObject



102
103
104
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 102

def secret
  @options[:credential2]
end

#statusObject

‘2’ Processed – This status is sent when the transaction is processed and the funds have been received on your Moneybookers account. ‘0’ Pending – This status is sent when the customers pays via the pending bank transfer option. Such transactions will auto-process IF the bank transfer is received by Moneybookers. We strongly recommend that you do NOT process the order/transaction in your system upon receipt of a pending status from Moneybookers. ‘-1’ Cancelled – Pending transactions can either be cancelled manually by the sender in their online account history or they will auto-cancel after 14 days if still pending. ‘-2’ Failed – This status is sent when the customer tries to pay via Credit Card or Direct Debit but our provider declines the transaction. If you do not accept Credit Card or Direct Debit payments via Moneybookers (see page 17) then you will never receive the failed status. ‘-3’ Chargeback – This status could be received only if your account is configured to receive chargebacks. If this is the case, whenever a chargeback is received by Moneybookers, a -3 status will be posted on the status_url for the reversed transaction.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 26

def status
  case status_code
  when '2'
    'Completed'
  when '0'
    'Pending'
  when '-1'
    'Cancelled'
  when '-2'
    'Failed'
  when '-3'
    'Reversed'
  else
    'Error'
  end
end

#status_codeObject



43
44
45
# File 'lib/active_merchant/billing/integrations/moneybookers/notification.rb', line 43

def status_code
  params['status']
end

#test?Boolean

Was this a test transaction?

Returns:

  • (Boolean)


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

def test?
  false
end

#transaction_idObject



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

def transaction_id
  params['mb_transaction_id']
end