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

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

Direct Known Subclasses

A1agregator::Notification, AuthorizeNetSim::Notification, BitPay::Notification, Bogus::Notification, Chronopay::Notification, Citrus::Notification, DirecPay::Notification, Directebanking::Notification, Doku::Notification, Dotpay::Notification, Dwolla::Notification, EPaymentPlans::Notification, EasyPay::Notification, Epay::Notification, Gestpay::Notification, HiTrust::Notification, Ipay88::Notification, Liqpay::Notification, Maksuturva::Notification, Moneybookers::Notification, ActiveMerchant::Billing::Integrations::Nochex::Notification, Paxum::Notification, PayFast::Notification, PayflowLink::Notification, Paypal::Notification, Paysbuy::Notification, PayuIn::Notification, Platron::Notification, Pxpay::Notification, Quickpay::Notification, Rbkmoney::Notification, Robokassa::Notification, SagePayForm::Notification, TwoCheckout::Notification, Valitor::Notification, Verkkomaksut::Notification, WebPay::Notification, Webmoney::Notification, WirecardCheckoutPage::Notification, WorldPay::Notification

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Notification) initialize(post, options = {})

  • Args :

    • doc -> raw post string

    • options -> custom options which individual implementations can

      utilize


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

def initialize(post, options = {})
  @options = options
  empty!
  parse(post)
end

Instance Attribute Details

- (Object) params

Returns the value of attribute params



5
6
7
# File 'lib/active_merchant/billing/integrations/notification.rb', line 5

def params
  @params
end

- (Object) raw

Returns the value of attribute raw



6
7
8
# File 'lib/active_merchant/billing/integrations/notification.rb', line 6

def raw
  @raw
end

Instance Method Details

- (Object) amount

This combines the gross and currency and returns a proper Money object. this requires the money library located at dist.leetsoft.com/api/money



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

def amount
  return Money.new(gross_cents, currency) rescue ArgumentError
  return Money.new(gross_cents) # maybe you have an own money object which doesn't take a currency?
end

- (Object) empty!

reset the notification.



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

def empty!
  @params  = Hash.new
  @raw     = ""
end

- (Object) gross

the money amount we received in X.2 decimal.

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/active_merchant/billing/integrations/notification.rb', line 27

def gross
  raise NotImplementedError, "Must implement this method in the subclass"
end

- (Object) gross_cents



31
32
33
# File 'lib/active_merchant/billing/integrations/notification.rb', line 31

def gross_cents
  (gross.to_f * 100.0).round
end

- (Object) status

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/active_merchant/billing/integrations/notification.rb', line 22

def status
  raise NotImplementedError, "Must implement this method in the subclass"
end

- (Boolean) test?

Returns:

  • (Boolean)


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

def test?
  false
end

- (Boolean) valid_sender?(ip)

Check if the request comes from an official IP

Returns:

  • (Boolean)


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

def valid_sender?(ip)
  return true if ActiveMerchant::Billing::Base.integration_mode == :test || production_ips.blank?
  production_ips.include?(ip)
end