Sha256: dcd8cf1c421c7b4ddb81c55cd88816ac89ff895e6e2b049e5ad16bc5f5e170ce
Contents?: true
Size: 1.41 KB
Versions: 4
Compression:
Stored size: 1.41 KB
Contents
module Balanced class Error class OrderCancelFailure < Balanced::StandardError; end end class Order include Balanced::Resource include Balanced::HypermediaRegistry define_hypermedia_types [:orders] def cancel reload # shouldn't fail unless there's a network outage # let's just hope there's not (for the sake of time) self.debits.map { |d| begin d.refund rescue d.refunds.to_a end }.flatten end alias refund cancel def debit_from(options={}) Balanced::Utils.assert_required_keys(options, :required => [:source, :amount]) options[:order] = self.href source = options[:source] debit = source.debit(options) debit end def credit_to(options={}) Balanced::Utils.assert_required_keys(options, :required => [:destination, :amount]) options[:order] = self.href destination = options[:destination] # should have a way here to disburse more funds to another account, but not required credit = destination.credit(options) credit end private def has_initiated_credits? self.credits.total != 0 end def has_initiated_refunds? self.refunds.total != 0 end def has_initiated_reversals? self.reversals.total != 0 end def has_initiated_debits? self.debits.total != 0 end end end
Version data entries
4 entries across 4 versions & 1 rubygems