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.



26
27
28
# File 'lib/paypal/recurring/notification.rb', line 26

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)


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

def completed?
  status == "Completed"
end

#express_checkout?Boolean

Returns:

  • (Boolean)


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

def express_checkout?
  type == "express_checkout"
end

#next_payment_dateObject



66
67
68
# File 'lib/paypal/recurring/notification.rb', line 66

def next_payment_date
  self.class.convert_to_time(params[:next_payment_date]) if params[:next_payment_date]
end


70
71
72
# File 'lib/paypal/recurring/notification.rb', line 70

def paid_at
  self.class.convert_to_time(payment_date) if payment_date
end

#recurring_payment?Boolean

Returns:

  • (Boolean)


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

def recurring_payment?
  type == "recurring_payment"
end

#recurring_payment_profile?Boolean

Returns:

  • (Boolean)


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

def recurring_payment_profile?
  type == "recurring_payment_profile_created"
end

#requestObject



48
49
50
51
52
# File 'lib/paypal/recurring/notification.rb', line 48

def request
  @request ||= PayPal::Recurring::Request.new.tap do |request|
    request.uri = URI.parse("#{PayPal::Recurring.site_endpoint}?cmd=_notify-validate")
  end
end

#responseObject



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

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

#valid?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/paypal/recurring/notification.rb', line 58

def valid?
  completed? && verified? && email == PayPal::Recurring.email && seller_id == PayPal::Recurring.seller_id
end

#verified?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/paypal/recurring/notification.rb', line 74

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