Sha256: 454752c57aaad0d6f9c55cf9c1a766573b5893d59193c5171411755941e973fd
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
module CatarsePagarme class CreditCardBaseController < CatarsePagarme::ApplicationController protected def charge_with_class(kclass) transaction = kclass.new(credit_card_attributes, contribution).charge! render json: { payment_status: transaction.status } rescue Exception => e render json: { payment_status: 'failed', message: e.message } end def splited_month_and_year params[:payment_card_date].split('/') rescue [0, 0] end def get_installment if contribution.value < CatarsePagarme.configuration.minimum_value_for_installment 1 elsif params[:payment_card_installments].to_i > 0 params[:payment_card_installments].to_i else 1 end end def credit_card_attributes { payment_method: 'credit_card', card_number: params[:payment_card_number], card_holder_name: params[:payment_card_name], card_expiration_month: splited_month_and_year[0], card_expiration_year: splited_month_and_year[1], card_cvv: params[:payment_card_source], amount: delegator.value_with_installment_tax(get_installment), postback_url: ipn_pagarme_url(contribution, host: CatarsePagarme.configuration.host), installments: get_installment, customer: { email: contribution.user.email, name: contribution.user.name } } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
catarse_pagarme-0.1.4 | app/controllers/catarse_pagarme/credit_card_base_controller.rb |