Class: KondutoPayment

Inherits:
Object
  • Object
show all
Defined in:
lib/konduto-ruby/konduto_payment.rb

Constant Summary collapse

TYPE_PAYMENT =
[:credit, :boleto, :debit, :transfer, :voucher]
TYPE_STATUS =
[:approved, :declined, :pending]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ KondutoPayment

Returns a new instance of KondutoPayment.



7
8
9
10
11
12
13
# File 'lib/konduto-ruby/konduto_payment.rb', line 7

def initialize(*args)
  unless args[0].nil?
    args[0].each do |k,v|
      instance_variable_set("@#{k}", v) unless v.nil?
    end
  end
end

Instance Attribute Details

#binObject

Returns the value of attribute bin.



2
3
4
# File 'lib/konduto-ruby/konduto_payment.rb', line 2

def bin
  @bin
end

#expiration_dateObject

Returns the value of attribute expiration_date.



2
3
4
# File 'lib/konduto-ruby/konduto_payment.rb', line 2

def expiration_date
  @expiration_date
end

#last4Object

Returns the value of attribute last4.



2
3
4
# File 'lib/konduto-ruby/konduto_payment.rb', line 2

def last4
  @last4
end

#statusObject

Returns the value of attribute status.



2
3
4
# File 'lib/konduto-ruby/konduto_payment.rb', line 2

def status
  @status
end

#typeObject

Returns the value of attribute type.



2
3
4
# File 'lib/konduto-ruby/konduto_payment.rb', line 2

def type
  @type
end

Instance Method Details

#to_hashObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/konduto-ruby/konduto_payment.rb', line 15

def to_hash
  hash = {
      type: self.type,
      status: self.status,
      bin: self.bin,
      last4: self.last4,
      expiration_date: self.expiration_date
  }
  KondutoUtils.remove_nil_keys_from_hash(hash)
end

#to_jsonObject



26
27
28
# File 'lib/konduto-ruby/konduto_payment.rb', line 26

def to_json
  self.to_hash.to_json
end