class Twocheckout::Invoice
Public Class Methods
find(options)
click to toggle source
# File lib/twocheckout/invoice.rb, line 4 def self.find(options) response = Twocheckout::API.request(:get, 'sales/detail_sale', options) Sale.new(response['sale']).invoice[options[:invoice_id]] end
Public Instance Methods
active_lineitems()
click to toggle source
Get active recurring lineitems
# File lib/twocheckout/invoice.rb, line 43 def active_lineitems @active_lineitems ||= lineitems.select(&:active?).freeze end
lineitem()
click to toggle source
A hash to index line-items by id
# File lib/twocheckout/invoice.rb, line 23 def lineitem if @lineitem.nil? @lineitem = {} lineitems.each { |li| @lineitem[li.lineitem_id] = li } @lineitem.freeze end return @lineitem end
lineitems()
click to toggle source
An array of all line-items in this invoice
# File lib/twocheckout/invoice.rb, line 12 def lineitems if @lineitems.nil? @lineitems = @hash['lineitems'].map { |li| Twocheckout::LineItem.new(li) } @lineitems.freeze end @lineitems end
refund!(opts)
click to toggle source
Refund invoice
# File lib/twocheckout/invoice.rb, line 35 def refund!(opts) opts = opts.merge(:invoice_id => self.invoice_id) Twocheckout::API.request(:post, 'sales/refund_invoice', opts) end
stop_recurring!()
click to toggle source
# File lib/twocheckout/invoice.rb, line 47 def stop_recurring! active_lineitems.each { |li| li.stop_recurring! } end
Protected Instance Methods
_key()
click to toggle source
# File lib/twocheckout/invoice.rb, line 53 def _key self.invoice_id end