Sha256: fe007247190e5694e45197181be7cb6bf2d7e248b386eaa5ea8a747081d0a1ce

Contents?: true

Size: 909 Bytes

Versions: 1

Compression:

Stored size: 909 Bytes

Contents

module Zoop
  class Transaction < Zoop::Model
    alias :charge :create

    def initialize(response = {})
      super(response)

      self.currency         ||= 'BRL'
      self.payment_type     ||= 'credit'
      self.capture          ||= true
    end

    def capture!
      params = { amount: amount.convert_to_cents, on_behalf_of: on_behalf_of }
      update_model Zoop::Request.post(url('capture'), params: params).run
      self
    end

    def refund
      params = { amount: amount.convert_to_cents, on_behalf_of: on_behalf_of }
      update_model Zoop::Request.post(url('void'), params: params).run
      self
    end

    def receivables
      Zoop::Request.get( url 'receivables' ).call
    end

    def split_rules
      Zoop::Request.get( url 'split_rules' ).call
    end

    def destroy
      raise NotImplementedError
    end

    class << self
      alias :charge :create
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zoop-0.3.0 lib/zoop/resources/transaction.rb