Class: PayPal::ExpressCheckout::Response::Notification
- Inherits:
-
Base
- Object
- Base
- PayPal::ExpressCheckout::Response::Notification
show all
- Defined in:
- lib/paypal/express_checkout/response/notification.rb
Constant Summary
Constants included
from Fields
Fields::ASSOCIATIONS, Fields::ATTRIBUTES
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Base
#build_association, #build_billings, #build_fmfs, #build_payment_items, #build_payments, #build_shipping_options, #build_values, #errors, #success?
Methods included from Utils
#convert_to_time, #mapping
Methods included from Fields
#field_map, #group_collect, #group_fields, #has_fields?, #has_many?, included, #inverted_field_map
Constructor Details
#initialize(params = {}) ⇒ Notification
Returns a new instance of Notification.
27
28
29
|
# File 'lib/paypal/express_checkout/response/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/express_checkout/response/notification.rb', line 6
def params
@params
end
|
Instance Method Details
#completed? ⇒ Boolean
63
64
65
|
# File 'lib/paypal/express_checkout/response/notification.rb', line 63
def completed?
status == "Completed"
end
|
#created_at ⇒ Object
75
76
77
|
# File 'lib/paypal/express_checkout/response/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/express_checkout/response/notification.rb', line 37
def express_checkout?
type == "express_checkout"
end
|
#next_payment_date ⇒ Object
67
68
69
|
# File 'lib/paypal/express_checkout/response/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/express_checkout/response/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/express_checkout/response/notification.rb', line 41
def recurring_payment?
type == "recurring_payment"
end
|
#recurring_payment_profile? ⇒ Boolean
45
46
47
|
# File 'lib/paypal/express_checkout/response/notification.rb', line 45
def recurring_payment_profile?
type == "recurring_payment_profile_created"
end
|
#request ⇒ Object
49
50
51
52
53
|
# File 'lib/paypal/express_checkout/response/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/express_checkout/response/notification.rb', line 55
def response
@response ||= request.post(params.merge(:cmd => "_notify-validate"))
end
|
#valid? ⇒ Boolean
59
60
61
|
# File 'lib/paypal/express_checkout/response/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/express_checkout/response/notification.rb', line 79
def verified?
response.body == "VERIFIED"
end
|