Class: OffsitePayments::Notification
- Inherits:
-
Object
- Object
- OffsitePayments::Notification
- Defined in:
- lib/offsite_payments/notification.rb
Direct Known Subclasses
Integrations::A1agregator::Notification, Integrations::AuthorizeNetSim::Notification, Integrations::BitPay::Notification, Integrations::Bogus::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::Megakassa::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::PayuIn::Notification, Integrations::Platron::Notification, Integrations::Pxpay::Notification, Integrations::Quickpay::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, Integrations::YandexMoney::Notification
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
-
#raw ⇒ Object
Returns the value of attribute raw.
Instance Method Summary collapse
-
#amount ⇒ Object
This combines the gross and currency and returns a proper Money object.
-
#empty! ⇒ Object
reset the notification.
-
#gross ⇒ Object
the money amount we received in X.2 decimal.
- #gross_cents ⇒ Object
-
#initialize(post, options = {}) ⇒ Notification
constructor
-
Args : -
doc
-> raw post string -options
-> custom options which individual implementations can utilize.
-
- #iso_currency ⇒ Object
- #status ⇒ Object
- #test? ⇒ Boolean
-
#valid_sender?(ip) ⇒ Boolean
Check if the request comes from an official IP.
Constructor Details
#initialize(post, options = {}) ⇒ Notification
-
Args :
-
doc
-> raw post string -
options
-> custom options which individual implementations canutilize
-
14 15 16 17 18 |
# File 'lib/offsite_payments/notification.rb', line 14 def initialize(post, = {}) @options = empty! parse(post) end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
3 4 5 |
# File 'lib/offsite_payments/notification.rb', line 3 def params @params end |
#raw ⇒ Object
Returns the value of attribute raw.
4 5 6 |
# File 'lib/offsite_payments/notification.rb', line 4 def raw @raw end |
Instance Method Details
#amount ⇒ Object
This combines the gross and currency and returns a proper Money object. this requires the money library located at rubymoney.github.io/money/
35 36 37 38 |
# File 'lib/offsite_payments/notification.rb', line 35 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 |
#empty! ⇒ Object
reset the notification.
41 42 43 44 |
# File 'lib/offsite_payments/notification.rb', line 41 def empty! @params = Hash.new @raw = "" end |
#gross ⇒ Object
the money amount we received in X.2 decimal.
25 26 27 |
# File 'lib/offsite_payments/notification.rb', line 25 def gross raise NotImplementedError, "Must implement this method in the subclass" end |
#gross_cents ⇒ Object
29 30 31 |
# File 'lib/offsite_payments/notification.rb', line 29 def gross_cents (gross.to_f * 100.0).round end |
#iso_currency ⇒ Object
56 57 58 |
# File 'lib/offsite_payments/notification.rb', line 56 def iso_currency ActiveUtils::CurrencyCode.standardize(currency) end |
#status ⇒ Object
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
52 53 54 |
# File 'lib/offsite_payments/notification.rb', line 52 def test? false end |
#valid_sender?(ip) ⇒ Boolean
Check if the request comes from an official IP
47 48 49 50 |
# File 'lib/offsite_payments/notification.rb', line 47 def valid_sender?(ip) return true if OffsitePayments.mode == :test || production_ips.blank? production_ips.include?(ip) end |