Class: StarkBank::Invoice::Payment

Inherits:
Utils::SubResource show all
Defined in:
lib/invoice/payment.rb

Overview

# Payment object

When an Invoice is paid, its InvoicePayment sub-resource will become available. It carries all the available information about the invoice payment.

## Attributes (return-only):

  • amount [long]: amount in cents that was paid. ex: 1234 (= R$ 12.34)

  • name [string]: payer full name. ex: ‘Anthony Edward Stark’

  • tax_id [string]: payer tax ID (CPF or CNPJ). ex: ‘20.018.183/0001-80’

  • bank_code [string]: code of the payer bank institution in Brazil. ex: ‘20018183’

  • branch_code [string]: payer bank account branch. ex: ‘1357-9’

  • account_number [string]: payer bank account number. ex: ‘876543-2’

  • account_type [string]: payer bank account type. ex: ‘checking’, ‘savings’, ‘salary’ or ‘payment’

  • end_to_end_id [string]: central bank’s unique transaction ID. ex: ‘E79457883202101262140HHX553UPqeq’

  • method [string]: payment method that was used. ex: ‘pix’

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Utils::SubResource

#inspect, #to_s

Constructor Details

#initialize(name:, tax_id:, bank_code:, branch_code:, account_number:, account_type:, amount:, end_to_end_id:, method:) ⇒ Payment

Returns a new instance of Payment.



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/invoice/payment.rb', line 25

def initialize(name:, tax_id:, bank_code:, branch_code:, account_number:, account_type:, amount:, end_to_end_id:, method:)
    @name = name
    @tax_id = tax_id
    @bank_code = bank_code
    @branch_code = branch_code
    @account_number = 
    @account_type = 
    @amount = amount
    @end_to_end_id = end_to_end_id
    @method = method
end

Instance Attribute Details

#account_numberObject (readonly)

Returns the value of attribute account_number.



24
25
26
# File 'lib/invoice/payment.rb', line 24

def 
  @account_number
end

#account_typeObject (readonly)

Returns the value of attribute account_type.



24
25
26
# File 'lib/invoice/payment.rb', line 24

def 
  @account_type
end

#amountObject (readonly)

Returns the value of attribute amount.



24
25
26
# File 'lib/invoice/payment.rb', line 24

def amount
  @amount
end

#bank_codeObject (readonly)

Returns the value of attribute bank_code.



24
25
26
# File 'lib/invoice/payment.rb', line 24

def bank_code
  @bank_code
end

#branch_codeObject (readonly)

Returns the value of attribute branch_code.



24
25
26
# File 'lib/invoice/payment.rb', line 24

def branch_code
  @branch_code
end

#end_to_end_idObject (readonly)

Returns the value of attribute end_to_end_id.



24
25
26
# File 'lib/invoice/payment.rb', line 24

def end_to_end_id
  @end_to_end_id
end

#methodObject (readonly)

Returns the value of attribute method.



24
25
26
# File 'lib/invoice/payment.rb', line 24

def method
  @method
end

#nameObject (readonly)

Returns the value of attribute name.



24
25
26
# File 'lib/invoice/payment.rb', line 24

def name
  @name
end

#tax_idObject (readonly)

Returns the value of attribute tax_id.



24
25
26
# File 'lib/invoice/payment.rb', line 24

def tax_id
  @tax_id
end

Class Method Details

.resourceObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/invoice/payment.rb', line 37

def self.resource
    {
        sub_resource_name: 'Payment',
        sub_resource_maker: proc { |json|
            Payment.new(
                name: json['name'],
                tax_id: json['tax_id'],
                bank_code: json['bank_code'],
                branch_code: json['branch_code'],
                account_number: json['account_number'],
                account_type: json['account_type'],
                amount: json['amount'],
                end_to_end_id: json['end_to_end_id'],
                method: json['method']
            )
        }
    }
end