Class: PayPal::Recurring::Notification
- Inherits:
-
Object
- Object
- PayPal::Recurring::Notification
- Extended by:
- Utils
- Defined in:
- lib/paypal/recurring/notification.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
- #completed? ⇒ Boolean
- #created_at ⇒ Object
- #express_checkout? ⇒ Boolean
-
#initialize(params = {}) ⇒ Notification
constructor
A new instance of Notification.
- #next_payment_date ⇒ Object
- #paid_at ⇒ Object
- #recurring_payment? ⇒ Boolean
- #recurring_payment_profile? ⇒ Boolean
- #request ⇒ Object
- #response ⇒ Object
- #valid? ⇒ Boolean
- #verified? ⇒ Boolean
Methods included from Utils
Constructor Details
#initialize(params = {}) ⇒ Notification
Returns a new instance of Notification.
27 28 29 |
# File 'lib/paypal/recurring/notification.rb', line 27 def initialize(params = {}) self.params = params end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
6 7 8 |
# File 'lib/paypal/recurring/notification.rb', line 6 def params @params end |
Instance Method Details
#completed? ⇒ Boolean
63 64 65 |
# File 'lib/paypal/recurring/notification.rb', line 63 def completed? status == "Completed" end |
#created_at ⇒ Object
75 76 77 |
# File 'lib/paypal/recurring/notification.rb', line 75 def created_at self.class.convert_to_time(time_created) if time_created end |
#express_checkout? ⇒ Boolean
37 38 39 |
# File 'lib/paypal/recurring/notification.rb', line 37 def express_checkout? type == "express_checkout" end |
#next_payment_date ⇒ Object
67 68 69 |
# File 'lib/paypal/recurring/notification.rb', line 67 def next_payment_date self.class.convert_to_time(params[:next_payment_date]) if params[:next_payment_date] end |
#paid_at ⇒ Object
71 72 73 |
# File 'lib/paypal/recurring/notification.rb', line 71 def paid_at self.class.convert_to_time(payment_date) if payment_date end |
#recurring_payment? ⇒ Boolean
41 42 43 |
# File 'lib/paypal/recurring/notification.rb', line 41 def recurring_payment? type == "recurring_payment" end |
#recurring_payment_profile? ⇒ Boolean
45 46 47 |
# File 'lib/paypal/recurring/notification.rb', line 45 def recurring_payment_profile? type == "recurring_payment_profile_created" end |
#request ⇒ Object
49 50 51 52 53 |
# File 'lib/paypal/recurring/notification.rb', line 49 def request @request ||= PayPal::Recurring::Request.new.tap do |request| request.uri = URI.parse("#{PayPal::Recurring.site_endpoint}?cmd=_notify-validate") end end |
#response ⇒ Object
55 56 57 |
# File 'lib/paypal/recurring/notification.rb', line 55 def response @response ||= request.post(params.merge(:cmd => "_notify-validate")) end |
#valid? ⇒ Boolean
59 60 61 |
# File 'lib/paypal/recurring/notification.rb', line 59 def valid? completed? && verified? && email == PayPal::Recurring.email && seller_id == PayPal::Recurring.seller_id end |
#verified? ⇒ Boolean
79 80 81 |
# File 'lib/paypal/recurring/notification.rb', line 79 def verified? response.body == "VERIFIED" end |