Sha256: 6d8c63b3b20c74724938d444357381b8b4a46c7539cf8b105c67be869351345e
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 KB
Contents
module CatarsePagarme class CreditCardBaseController < 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), 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.0.1 | app/controllers/catarse_pagarme/credit_card_base_controller.rb |