Module: IPay
- Defined in:
- lib/ipay.rb,
lib/ipay/cc.rb,
lib/ipay/log.rb,
lib/ipay/util.rb,
lib/ipay/config.rb,
lib/ipay/wallet.rb,
lib/ipay/network.rb,
lib/ipay/version.rb,
lib/ipay/currency.rb,
lib/ipay/response.rb,
lib/ipay/constants.rb,
lib/ipay/api_request.rb,
lib/ipay/xml_request.rb,
lib/ipay/certification.rb
Defined Under Namespace
Modules: CC, Certification, Countries, Currency, Network, Util, Wallet
Classes: ApiRequest, Log, Response, XmlRequest
Constant Summary
collapse
- ENV =
ENV['RAILS_ENV'] || ENV['IPAY_ENV'] || 'development'
- ROOT =
ENV['RAILS_ROOT'] || ENV['IPAY_ROOT'] || '.'
- CONFIG_NAME =
'ipay.yml'
- LOG_NAME =
'ipay.log'
- ApiError =
Class.new(RuntimeError)
- RequestError =
Class.new(ApiError)
- RequestTimeout =
Class.new(RequestError)
- ResponseError =
Class.new(ApiError)
- DEFAULTS =
{
:currency_code => IPay::Countries[:us][:currency_code],
:currency_indicator => CUR_INDICATOR_DOMESTIC,
:transaction_indicator => TXN_INDICATOR_HTTPS
}
- VERSION =
'0.2.2'
- EM_SWIPED =
1
- EM_MANUAL_PRESENT =
2
- EM_MANUAL_NOT_PRESENT =
3
- GOODS_DIGITAL =
'D'
- GOODS_PHYSICAL =
'P'
- CUR_INDICATOR_DOMESTIC =
0
- CUR_INDICATOR_MCP =
1
- CUR_INDICATOR_PYC =
2
- TXN_INDICATOR_MAIL =
'M'
- TXN_INDICATOR_POS =
'P'
- TXN_INDICATOR_PHONE =
'T'
- TXN_INDICATOR_RECUR =
2
- TXN_INDICATOR_AUTH =
5
- TXN_INDICATOR_AUTH_FAILED =
6
- TXN_INDICATOR_HTTPS =
7
- BILLING_TXN_AUTH =
0
- BILLING_TXN_SALE =
1
- BILLING_TXN_AVS =
2
- BILLING_TXN_ACH_VALIDATION =
3
- ACCOUNT_CC =
'CC'
- ACCOUNT_ACH =
'ACH'
- QUERY_TYPE_TXN =
0
- QUERY_TYPE_GROUP =
1
Class Method Summary
collapse
Class Method Details
.config {|@config| ... } ⇒ Object
36
37
38
39
40
|
# File 'lib/ipay/config.rb', line 36
def self.config
@config ||= load_config_file
yield @config if block_given?
@config
end
|
.config_file ⇒ Object
12
13
14
|
# File 'lib/ipay/config.rb', line 12
def self.config_file
File.expand_path(File.join(ROOT, 'config', CONFIG_NAME))
end
|
.init_log(log = nil) ⇒ Object
15
16
17
18
19
|
# File 'lib/ipay/log.rb', line 15
def self.init_log(log = nil)
@log = Log.new(log||log_file)
@log.level = Logger::WARN if ENV == 'production'
@log
end
|
.load_config_file ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/ipay/config.rb', line 16
def self.load_config_file
path = File.expand_path(config_file)
if File.readable?(path)
IPay::log.debug "Using configuration file '#{path}'"
config = OpenStruct.new(YAML.load_file(path)) unless config
else
config = OpenStruct.new
end
set_defaults(config)
end
|
.log ⇒ Object
21
22
23
|
# File 'lib/ipay/log.rb', line 21
def self.log
@log ||= init_log
end
|
.log=(log) ⇒ Object
25
26
27
|
# File 'lib/ipay/log.rb', line 25
def self.log=(log)
init_log log
end
|
.log_file ⇒ Object
9
10
11
12
13
|
# File 'lib/ipay/log.rb', line 9
def self.log_file
path = File.join(ROOT, 'log')
path = '.' unless File.directory?(path)
File.expand_path(File.join(path, LOG_NAME))
end
|
.set_defaults(config) ⇒ Object
29
30
31
32
33
34
|
# File 'lib/ipay/config.rb', line 29
def self.set_defaults(config)
config.dry_run ||= false
config.certification ||= false
config.defaults = DEFAULTS.merge(config.defaults || {}) config
end
|