Class: PayPal::Recurring::Notification

Inherits:
Object
  • Object
show all
Extended by:
Utils
Defined in:
lib/paypal/recurring/notification.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

convert_to_time, mapping

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

#paramsObject

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

Returns:

  • (Boolean)


63
64
65
# File 'lib/paypal/recurring/notification.rb', line 63

def completed?
  status == "Completed"
end

#created_atObject



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

Returns:

  • (Boolean)


37
38
39
# File 'lib/paypal/recurring/notification.rb', line 37

def express_checkout?
  type == "express_checkout"
end

#next_payment_dateObject



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


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

Returns:

  • (Boolean)


41
42
43
# File 'lib/paypal/recurring/notification.rb', line 41

def recurring_payment?
  type == "recurring_payment"
end

#recurring_payment_profile?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/paypal/recurring/notification.rb', line 45

def recurring_payment_profile?
  type == "recurring_payment_profile_created"
end

#requestObject



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

#responseObject



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

def response
  @response ||= request.post(params.merge(:cmd => "_notify-validate"))
end

#valid?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


79
80
81
# File 'lib/paypal/recurring/notification.rb', line 79

def verified?
  response.body == "VERIFIED"
end