Sha256: cbe760857e6012b2d8b6f3d5657666d88f4e93475c1e0b3d3b3dd7762437e561

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

module Balanced
  # A Debit represents a transfer of funds from a buyer's Account to your
  # Marketplace's escrow account.
  #
  # A Debit may be created directly, or it will be created as a side-effect
  # of capturing a Hold. If you create a Debit directly it will implicitly
  # create the associated Hold if the funding source supports this.
  #
  # If no Hold is specified the Debit will by default be created using the
  # most recently added funding source associated with the Account. You
  # cannot change the funding source between creating a Hold and capturing
  # it.
  #
  class Debit
    include Balanced::Resource
    include Balanced::HypermediaRegistry

    define_hypermedia_types [:debits]

    # Refunds this Debit. If no amount is specified it will refund the entire
    # amount of the Debit, you may create many Refunds up to the sum total
    # of the original Debit's amount.
    #
    # @return [Refund]
    def refund(options={})

      amount = options[:amount]
      description = options[:description]

      refund = Refund.new(
          :href => self.refunds.href,
          :amount => amount,
          :description => description
      )
      refund.save
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
balanced-1.0.1 lib/balanced/resources/debit.rb
balanced-1.0 lib/balanced/resources/debit.rb
balanced-1.0.beta1 lib/balanced/resources/debit.rb