Sha256: 38c4b3cdff237cec9d21d59905d73ac5c39c30f86de0cfdbb85343c38625b304

Contents?: true

Size: 937 Bytes

Versions: 5

Compression:

Stored size: 937 Bytes

Contents

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

    attr_accessor :capture

    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

5 entries across 5 versions & 1 rubygems

Version Path
zoop-0.3.5 lib/zoop/resources/transaction.rb
zoop-0.3.4 lib/zoop/resources/transaction.rb
zoop-0.3.3 lib/zoop/resources/transaction.rb
zoop-0.3.2 lib/zoop/resources/transaction.rb
zoop-0.3.1 lib/zoop/resources/transaction.rb