class PaymentRecipes::PayPal::REST::Refund
Attributes
capture[R]
capture_id[R]
create_time[R]
currency[R]
id[R]
payment[R]
payment_id[R]
raw_refund[R]
sale[R]
sale_id[R]
state[R]
total[R]
update_time[R]
Public Class Methods
find(id)
click to toggle source
# File lib/payment_recipes/paypal/rest/refund.rb, line 123 def find(id) paypal_refund = find_raw(id) if paypal_refund new(paypal_refund, payment: nil) else nil end end
find_raw(id)
click to toggle source
# File lib/payment_recipes/paypal/rest/refund.rb, line 133 def find_raw(id) begin ::PayPal::SDK::REST::Refund.find(id) rescue ::PayPal::SDK::Core::Exceptions::ResourceNotFound nil end end
new(paypal_refund, payment: nil)
click to toggle source
# File lib/payment_recipes/paypal/rest/refund.rb, line 26 def initialize(paypal_refund, payment: nil) unless paypal_refund.is_a?(::PayPal::SDK::REST::DataTypes::Refund) raise Exception, "#{ self.class.name } must be initialized with a PayPal Refund" end if payment unless payment.is_a?(::PaymentRecipes::PayPal::REST::Payment) raise Exception, "Parameter payment must be a PaymentRecipes::PayPal::Payment" end @payment = payment @payment_id = payment.id end extract_and_store(paypal_refund) end
Public Instance Methods
completed?()
click to toggle source
# File lib/payment_recipes/paypal/rest/refund.rb, line 102 def completed? @state == :completed end
extract_and_store(paypal_refund)
click to toggle source
# File lib/payment_recipes/paypal/rest/refund.rb, line 143 def extract_and_store(paypal_refund) @id = convert_to_string(paypal_refund.id) @currency = convert_to_string(paypal_refund.amount.currency) @total = convert_to_money(amount: paypal_refund.amount.total, currency: paypal_refund.amount.currency) @payment_id = convert_to_string(paypal_refund.parent_payment) @state = convert_to_symbol(paypal_refund.state) @create_time = convert_to_time(paypal_refund.create_time) @update_time = convert_to_time(paypal_refund.update_time) @sale_id = convert_to_string(paypal_refund.sale_id) @capture_id = convert_to_string(paypal_refund.capture_id) @raw_refund = paypal_refund end
failed?()
click to toggle source
# File lib/payment_recipes/paypal/rest/refund.rb, line 106 def failed? @state == :failed end
inspect()
click to toggle source
# File lib/payment_recipes/paypal/rest/refund.rb, line 110 def inspect to_str end
pending?()
click to toggle source
# File lib/payment_recipes/paypal/rest/refund.rb, line 98 def pending? @state == :pending end
reload!()
click to toggle source
# File lib/payment_recipes/paypal/rest/refund.rb, line 43 def reload! paypal_refund = self.class.find_raw(@id) extract_and_store(paypal_refund) self end
reload_capture!()
click to toggle source
# File lib/payment_recipes/paypal/rest/refund.rb, line 64 def reload_capture! return unless @capture_id @capture = ::PaymentRecipes::PayPal::REST::Capture.find(@capture_id) @capture end
reload_payment!()
click to toggle source
# File lib/payment_recipes/paypal/rest/refund.rb, line 50 def reload_payment! @payment = ::PaymentRecipes::PayPal::REST::Payment.find(@payment_id) @payment end
reload_sale!()
click to toggle source
# File lib/payment_recipes/paypal/rest/refund.rb, line 56 def reload_sale! return unless @sale_id @sale = ::PaymentRecipes::PayPal::REST::Sale.find(@sale_id) @sale end
to_s()
click to toggle source
# File lib/payment_recipes/paypal/rest/refund.rb, line 114 def to_s to_str end
to_str()
click to toggle source
# File lib/payment_recipes/paypal/rest/refund.rb, line 118 def to_str "<#{ self.class.name } total=#{ @total.format } state=#{ @state } id=#{ @id }>" end