Class: CatarsePagarme::SlipTransaction

Inherits:
TransactionBase show all
Defined in:
app/models/catarse_pagarme/slip_transaction.rb

Instance Attribute Summary

Attributes inherited from TransactionBase

#attributes, #payment, #transaction, #user

Instance Method Summary collapse

Methods inherited from TransactionBase

#attributes_to_payment, #change_payment_state, #default_installments, #delegator, #initialize

Constructor Details

This class inherits a constructor from CatarsePagarme::TransactionBase

Instance Method Details

#charge!Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/models/catarse_pagarme/slip_transaction.rb', line 3

def charge!
  unless payment.update(
    gateway: 'Pagarme',
    payment_method: payment_method
  )

    raise ::PagarMe::PagarMeError.new(
      payment.errors.messages.values.flatten.to_sentence)
  end

  self.transaction = PagarMe::Transaction.new(
    self.attributes.merge(payment_method: 'boleto', async: false)
  )
  self.transaction.charge

  change_payment_state
  self.transaction
end

#payment_methodObject



22
23
24
# File 'app/models/catarse_pagarme/slip_transaction.rb', line 22

def payment_method
  PaymentType::SLIP
end