Module: PagSeguro

Extended by:
PagSeguro
Included in:
PagSeguro
Defined in:
lib/pagseguro/base.rb,
lib/pagseguro/rake.rb,
lib/pagseguro/faker.rb,
lib/pagseguro/order.rb,
lib/pagseguro/utils.rb,
lib/pagseguro/railtie.rb,
lib/pagseguro/version.rb,
lib/pagseguro/generator.rb,
lib/pagseguro/notification.rb,
lib/pagseguro/action_controller.rb,
lib/pagseguro/developer_controller.rb

Defined Under Namespace

Modules: ActionController, Faker, Helper, Rake, Utils, Version Classes: DeveloperController, InstallGenerator, MissingConfigurationError, MissingEnvironmentError, Notification, Order, Railtie

Constant Summary collapse

GATEWAY_URL =

PagSeguro receives all invoices in this URL. If developer mode is enabled, then the URL will be /pagseguro_developer/invoice

"https://pagseguro.uol.com.br/security/webpagamentos/webpagto.aspx"
@@config =

Hold the config/pagseguro.yml contents

nil

Instance Method Summary collapse

Instance Method Details

#configObject

Load configuration file.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/pagseguro/base.rb', line 22

def config
  raise MissingConfigurationError, "file not found on #{config_file.inspect}" unless config?

  # load file if is not loaded yet
  @@config ||= YAML.load_file(config_file)

  # raise an exception if the environment hasn't been set
  # or if file is empty
  if @@config == false || !@@config[Rails.env]
    raise MissingEnvironmentError, ":#{Rails.env} environment not set on #{config_file.inspect}"
  end

  # retrieve the environment settings
  @@config[Rails.env]
end

#config?Boolean

Check if configuration file exists.

Returns:

  • (Boolean)


17
18
19
# File 'lib/pagseguro/base.rb', line 17

def config?
  File.exist?(config_file)
end

#config_fileObject

The path to the configuration file



12
13
14
# File 'lib/pagseguro/base.rb', line 12

def config_file
  Rails.root.join("config/pagseguro.yml")
end

#developer?Boolean

Reader for the ‘developer` configuration

Returns:

  • (Boolean)


49
50
51
# File 'lib/pagseguro/base.rb', line 49

def developer?
  config? && config["developer"] == true
end

#gateway_urlObject

The gateway URL will point to a local URL is app is running in developer mode



40
41
42
43
44
45
46
# File 'lib/pagseguro/base.rb', line 40

def gateway_url
  if developer?
    "/pagseguro_developer"
  else
    GATEWAY_URL
  end
end