Sha256: 830717a9612734b64968cdedb31a81b88b0bb5d79ee6b85eada45b2ee374854a

Contents?: true

Size: 933 Bytes

Versions: 18

Compression:

Stored size: 933 Bytes

Contents

module PagSeguro
  class DeveloperController < ::ActionController::Base
    skip_before_filter :verify_authenticity_token
    PAGSEGURO_ORDERS_FILE = File.join(Rails.root, "tmp", "pagseguro-#{Rails.env}.yml")

    def create
      # create the orders file if doesn't exist
      FileUtils.touch(PAGSEGURO_ORDERS_FILE) unless File.exist?(PAGSEGURO_ORDERS_FILE)

      # YAML caveat: if file is empty false is returned;
      # we need to set default to an empty hash in this case
      orders = YAML.load_file(PAGSEGURO_ORDERS_FILE) || {}

      # add a new order, associating it with the order id
      orders[params[:ref_transacao]] = params.except(:controller, :action, :only_path, :authenticity_token)

      # save the file
      File.open(PAGSEGURO_ORDERS_FILE, "w+") do |file|
        file << orders.to_yaml
      end

      # redirect to the configuration url
      redirect_to PagSeguro.config["return_to"]
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
pagseguro-0.1.13 lib/pagseguro/developer_controller.rb
pagseguro-0.1.12 lib/pagseguro/developer_controller.rb
pagseguro-0.1.11 lib/pagseguro/developer_controller.rb
pagseguro-0.1.11.beta2 lib/pagseguro/developer_controller.rb
pagseguro-0.1.11.beta1 lib/pagseguro/developer_controller.rb
pagseguro-0.1.10 lib/pagseguro/developer_controller.rb
pagseguro-0.1.10.beta.0 lib/pagseguro/developer_controller.rb
pagseguro-0.1.9 lib/pagseguro/developer_controller.rb
pagseguro-0.1.9.beta.0 lib/pagseguro/developer_controller.rb
pagseguro-0.1.8 lib/pagseguro/developer_controller.rb
pagseguro-0.1.7 lib/pagseguro/developer_controller.rb
pagseguro-0.1.7.beta.1 lib/pagseguro/developer_controller.rb
pagseguro-0.1.7.beta.0 lib/pagseguro/developer_controller.rb
pagseguro-0.1.6 lib/pagseguro/developer_controller.rb
pagseguro-0.1.5 lib/pagseguro/developer_controller.rb
pagseguro-0.1.4 lib/pagseguro/developer_controller.rb
pagseguro-0.1.3 lib/pagseguro/developer_controller.rb
pagseguro-0.1.3.beta.1 lib/pagseguro/developer_controller.rb