Sha256: 34f66fc4e91ad5f4119e0cac73bb96b777d613b4e8297f185f22d7162e520f98

Contents?: true

Size: 1.3 KB

Versions: 16

Compression:

Stored size: 1.3 KB

Contents

require 'weekdays'

module CatarsePagarme
  class SlipController < CatarsePagarme::ApplicationController

    def create
      transaction = SlipTransaction.new(slip_attributes, payment).charge!

      render json: { boleto_url: transaction.boleto_url, payment_status: transaction.status }
    rescue PagarMe::PagarMeError => e
      render json: { boleto_url: nil, payment_status: 'failed', message: e.message }
    end

    def update
      transaction = SlipTransaction.new(slip_attributes, payment).charge!
      respond_to do |format|
        format.html { redirect_to transaction.boleto_url }
        format.json do
          { boleto_url: transaction.boleto_url }
        end
      end
    end

    protected

    def slip_attributes
      {
        payment_method: 'boleto',
        boleto_expiration_date: payment.slip_expiration_date,
        amount: delegator.value_for_transaction,
        postback_url: ipn_pagarme_index_url(host: CatarsePagarme.configuration.host,
                                            subdomain: CatarsePagarme.configuration.subdomain,
                                            protocol: CatarsePagarme.configuration.protocol),
        customer: {
          email: payment.user.email,
          name: payment.user.name
        },
        metadata: metadata_attributes
      }
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
catarse_pagarme-2.9.7 app/controllers/catarse_pagarme/slip_controller.rb
catarse_pagarme-2.9.6 app/controllers/catarse_pagarme/slip_controller.rb
catarse_pagarme-2.9.5 app/controllers/catarse_pagarme/slip_controller.rb
catarse_pagarme-2.9.4 app/controllers/catarse_pagarme/slip_controller.rb
catarse_pagarme-2.9.3 app/controllers/catarse_pagarme/slip_controller.rb
catarse_pagarme-2.9.2 app/controllers/catarse_pagarme/slip_controller.rb
catarse_pagarme-2.9.0 app/controllers/catarse_pagarme/slip_controller.rb
catarse_pagarme-2.8.10 app/controllers/catarse_pagarme/slip_controller.rb
catarse_pagarme-2.8.9 app/controllers/catarse_pagarme/slip_controller.rb
catarse_pagarme-2.8.8 app/controllers/catarse_pagarme/slip_controller.rb
catarse_pagarme-2.8.7 app/controllers/catarse_pagarme/slip_controller.rb
catarse_pagarme-2.8.6 app/controllers/catarse_pagarme/slip_controller.rb
catarse_pagarme-2.8.5 app/controllers/catarse_pagarme/slip_controller.rb
catarse_pagarme-2.8.4 app/controllers/catarse_pagarme/slip_controller.rb
catarse_pagarme-2.8.3 app/controllers/catarse_pagarme/slip_controller.rb
catarse_pagarme-2.8.2 app/controllers/catarse_pagarme/slip_controller.rb