Class: Zoop::Transaction

Inherits:
Model show all
Defined in:
lib/zoop/resources/transaction.rb

Constant Summary

Constants inherited from ZoopObject

ZoopObject::RESOURCES

Instance Attribute Summary collapse

Attributes inherited from ZoopObject

#attributes

Instance Method Summary collapse

Methods inherited from Model

class_name, #create, create, find_by_id, #save, underscored_class_name, #update, url, #url

Methods inherited from ZoopObject

#==, #[]=, convert, #empty?, #respond_to?, #to_hash, #to_s, #unsaved_attributes

Constructor Details

#initialize(response = {}) ⇒ Transaction

Returns a new instance of Transaction.



7
8
9
10
11
12
13
# File 'lib/zoop/resources/transaction.rb', line 7

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

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Zoop::ZoopObject

Instance Attribute Details

#captureObject

Returns the value of attribute capture.



5
6
7
# File 'lib/zoop/resources/transaction.rb', line 5

def capture
  @capture
end

Instance Method Details

#capture!Object



15
16
17
18
19
# File 'lib/zoop/resources/transaction.rb', line 15

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

#destroyObject

Raises:

  • (NotImplementedError)


35
36
37
# File 'lib/zoop/resources/transaction.rb', line 35

def destroy
  raise NotImplementedError
end

#receivablesObject



27
28
29
# File 'lib/zoop/resources/transaction.rb', line 27

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

#refundObject



21
22
23
24
25
# File 'lib/zoop/resources/transaction.rb', line 21

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

#split_rulesObject



31
32
33
# File 'lib/zoop/resources/transaction.rb', line 31

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