Sha256: 0ff0d6a0566870baf83ca29930700a7dd268f51fd071518ba078fd98cef3a007
Contents?: true
Size: 1.73 KB
Versions: 2
Compression:
Stored size: 1.73 KB
Contents
module PayPal module Recurring class Notification attr_reader :params def initialize(params = {}) self.params = params end def params=(params) @params = params.inject({}) do |buffer, (name,value)| buffer.merge(name.to_sym => value) end end def type params[:txn_type] end def express_checkout? type == "express_checkout" end def recurring_payment? type == "recurring_payment" end def request @request ||= PayPal::Recurring::Request.new.tap do |request| request.uri = URI.parse("#{PayPal::Recurring.site_endpoint}?cmd=_notify-validate") end end def response @response ||= request.post(params.merge(:cmd => "_notify-validate")) end def valid? completed? && verified? && params[:receiver_email] == PayPal::Recurring.email && params[:receiver_id] == PayPal::Recurring.seller_id end def completed? status == "Completed" end def transaction_id params[:txn_id] end def fee params[:mc_currency] end def reference params[:rp_invoice_id] end def payment_id params[:recurring_payment_id] end def next_payment_date Time.parse(params[:next_payment_date]) if params[:next_payment_date] end def paid_at Time.parse params[:time_created] if params[:time_created] end def amount params[:amount] end def currency params[:mc_currency] end def status params[:payment_status] end def verified? response.body == "VERIFIED" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
paypal-recurring-0.1.4 | lib/paypal/recurring/notification.rb |
paypal-recurring-0.1.3 | lib/paypal/recurring/notification.rb |