class GoCardless::Bill
Attributes
amount[RW]
amount_minus_fees[RW]
can_be_cancelled[RW]
can_be_cancelled?[RW]
can_be_retried[RW]
can_be_retried?[RW]
currency[RW]
description[RW]
gocardless_fees[RW]
is_setup_fee[RW]
is_setup_fee?[RW]
name[RW]
partner_fees[RW]
source_id[RW]
@attribute source_id
@return [String] the ID of the bill’s source (eg subscription, pre_authorization)
source_type[RW]
status[RW]
Public Instance Methods
cancel!()
click to toggle source
# File lib/gocardless/bill.rb, line 52 def cancel! path = self.class.endpoint.gsub(':id', id.to_s) + '/cancel' client.api_put(path) end
failed?()
click to toggle source
# File lib/gocardless/bill.rb, line 89 def failed? status == 'failed' end
paid?()
click to toggle source
# File lib/gocardless/bill.rb, line 85 def paid? status == 'paid' end
pending?()
click to toggle source
# File lib/gocardless/bill.rb, line 81 def pending? status == 'pending' end
refund!()
click to toggle source
The ability to refund a payment is disabled by default.
Please contact help@gocardless.com if you require access to the refunds API endpoint.
# File lib/gocardless/bill.rb, line 61 def refund! path = self.class.endpoint.gsub(':id', id.to_s) + '/refund' client.api_post(path) end
refunded?()
click to toggle source
# File lib/gocardless/bill.rb, line 97 def refunded? status == 'refunded' end
retry!()
click to toggle source
# File lib/gocardless/bill.rb, line 47 def retry! path = self.class.endpoint.gsub(':id', id.to_s) + '/retry' client.api_post(path) end
save()
click to toggle source
# File lib/gocardless/bill.rb, line 66 def save bill_params = { :pre_authorization_id => self.source_id, :amount => self.amount, :name => self.name, :description => self.description, :charge_customer_at => self.charge_customer_at, } bill_params.delete_if { |_,v| v.nil? } save_data({ :bill => bill_params }) self end
source()
click to toggle source
# File lib/gocardless/bill.rb, line 32 def source klass = GoCardless.const_get(Utils.camelize(source_type.to_s)) klass.find_with_client(client, @source_id) end
source=(obj)
click to toggle source
# File lib/gocardless/bill.rb, line 37 def source=(obj) klass = obj.class.to_s.split(':').last if !%w{Subscription PreAuthorization}.include?(klass) raise ArgumentError, ("Object must be an instance of Subscription or " "PreAuthorization") end @source_id = obj.id @source_type = Utils.underscore(klass) end
withdrawn?()
click to toggle source
# File lib/gocardless/bill.rb, line 93 def withdrawn? status == 'withdrawn' end