Class: OffsitePayments::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/offsite_payments/notification.rb

Direct Known Subclasses

Integrations::A1agregator::Notification, Integrations::AuthorizeNetSim::Notification, Integrations::BitPay::Notification, Integrations::Bogus::Notification, Integrations::CheckoutFinland::Notification, Integrations::Chronopay::Notification, Integrations::Citrus::Notification, Integrations::Coinbase::Notification, Integrations::DirecPay::Notification, Integrations::Directebanking::Notification, Integrations::Doku::Notification, Integrations::Dotpay::Notification, Integrations::Dwolla::Notification, Integrations::EPaymentPlans::Notification, Integrations::EasyPay::Notification, Integrations::Epay::Notification, Integrations::Gestpay::Notification, Integrations::HiTrust::Notification, Integrations::Ipay88::Notification, Integrations::Klarna::Notification, Integrations::Liqpay::Notification, Integrations::Maksuturva::Notification, Integrations::MollieIdeal::Notification, Integrations::MollieMistercash::Notification, Integrations::Molpay::Notification, Integrations::Moneybookers::Notification, Integrations::Nochex::Notification, Integrations::PagSeguro::Notification, Integrations::Paxum::Notification, Integrations::PayFast::Notification, Integrations::Paydollar::Notification, Integrations::PayflowLink::Notification, Integrations::Paypal::Notification, Integrations::Paysbuy::Notification, Integrations::Paytm::Notification, Integrations::PayuIn::Notification, Integrations::Platron::Notification, Integrations::Pxpay::Notification, Integrations::Quickpay::Notification, Integrations::QuickpayV10::Notification, Integrations::Rbkmoney::Notification, Integrations::RealexOffsite::Notification, Integrations::Robokassa::Notification, Integrations::SagePayForm::Notification, Integrations::TwoCheckout::Notification, Integrations::Universal::Notification, Integrations::Valitor::Notification, Integrations::Verkkomaksut::Notification, Integrations::WebPay::Notification, Integrations::Webmoney::Notification, Integrations::WirecardCheckoutPage::Notification, Integrations::WorldPay::Notification

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(post, options = {}) ⇒ Notification

  • Args :

    • doc -> raw post string

    • options -> custom options which individual implementations can

      utilize
      


14
15
16
17
18
# File 'lib/offsite_payments/notification.rb', line 14

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

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



3
4
5
# File 'lib/offsite_payments/notification.rb', line 3

def params
  @params
end

#rawObject

Returns the value of attribute raw.



4
5
6
# File 'lib/offsite_payments/notification.rb', line 4

def raw
  @raw
end

Instance Method Details

#amountObject



33
34
35
36
37
# File 'lib/offsite_payments/notification.rb', line 33

def amount
  amount = gross ? gross.to_d : 0
  return Money.from_amount(amount, currency) rescue ArgumentError
  return Money.from_amount(amount) # maybe you have an own money object which doesn't take a currency?
end

#empty!Object

reset the notification.



40
41
42
43
# File 'lib/offsite_payments/notification.rb', line 40

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

#grossObject

the money amount we received in X.2 decimal.

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/offsite_payments/notification.rb', line 25

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

#gross_centsObject



29
30
31
# File 'lib/offsite_payments/notification.rb', line 29

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

#iso_currencyObject



55
56
57
# File 'lib/offsite_payments/notification.rb', line 55

def iso_currency
  ActiveUtils::CurrencyCode.standardize(currency)
end

#statusObject

Raises:

  • (NotImplementedError)


20
21
22
# File 'lib/offsite_payments/notification.rb', line 20

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

#test?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/offsite_payments/notification.rb', line 51

def test?
  false
end

#valid_sender?(ip) ⇒ Boolean

Check if the request comes from an official IP

Returns:

  • (Boolean)


46
47
48
49
# File 'lib/offsite_payments/notification.rb', line 46

def valid_sender?(ip)
  return true if OffsitePayments.mode == :test || production_ips.blank?
  production_ips.include?(ip)
end