Class: CatarsePagarme::CreditCardsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/catarse_pagarme/credit_cards_controller.rb

Constant Summary collapse

MAX_SOFT_DESCRIPTOR_LENGTH =
13

Instance Method Summary collapse

Instance Method Details

#createObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/catarse_pagarme/credit_cards_controller.rb', line 6

def create
  transaction = CreditCardTransaction.new(credit_card_attributes, payment).process!

  render json: { payment_status: transaction.status }
rescue PagarMe::PagarMeError, PagarMe::ValidationError => e
  # should ignore refused payments
  if payment.state != 'refused'
    raven_capture(e)
  end
  payment.destroy if payment.persisted? && !payment.gateway_id.present?

  render json: { payment_status: 'failed', message: e.message }
rescue => e
  raven_capture(e)

  render json: { payment_status: 'failed', message: e.message }
end

#get_encryption_key_jsonObject



28
29
30
# File 'app/controllers/catarse_pagarme/credit_cards_controller.rb', line 28

def get_encryption_key_json
  render json: { key: CatarsePagarme.configuration.ecr_key }
end

#get_installment_jsonObject



24
25
26
# File 'app/controllers/catarse_pagarme/credit_cards_controller.rb', line 24

def get_installment_json
  render json: installments_for_json.to_json
end