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::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
-
#params ⇒ Object
Returns the value of attribute params.
-
#raw ⇒ Object
Returns the value of attribute raw.
Instance Method Summary collapse
- #amount ⇒ 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
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 |
#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
55 56 57 |
# File 'lib/offsite_payments/notification.rb', line 55 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
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
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 |