Module: Veritrans
- Defined in:
- lib/veritrans/events.rb,
lib/veritrans.rb,
lib/veritrans/api.rb,
lib/veritrans/cli.rb,
lib/veritrans/client.rb,
lib/veritrans/config.rb,
lib/veritrans/result.rb,
lib/veritrans/version.rb,
lib/generators/veritrans/install_generator.rb,
lib/generators/veritrans/payment_form_generator.rb
Overview
For sinatra you can use Rack::URLMap
run Rack::URLMap.new("/" => MyApp.new, "/payment_events" => Veritrans::Events.new)
Defined Under Namespace
Modules: Api, CLI, Client, Config Classes: Events, InstallGenerator, PaymentFormGenerator, Result
Constant Summary collapse
- VERSION =
"2.0.0"
Class Method Summary collapse
- .config(&block) ⇒ Object (also: setup)
-
.decode_notification_json(input) ⇒ Object
Note: Veritrans sending notification data as json, encoded twice so we should call JSON.parse twice.
- .events ⇒ Object
-
.file_logger ⇒ Object
Logger to file, only important information For rails apps it will write log to RAILS_ROOT/log/veritrans.log.
- .file_logger=(value) ⇒ Object
-
.logger ⇒ Object
General logger for rails apps it’s === Rails.logger for non-rails apps it’s logging to stdout.
- .logger=(value) ⇒ Object
Methods included from Client
_json_decode, _json_encode, request_with_logging
Methods included from Api
approve, cancel, capture, charge, create_vtlink, delete_vtlink, status
Class Method Details
.config(&block) ⇒ Object Also known as: setup
16 17 18 19 20 21 22 |
# File 'lib/veritrans.rb', line 16 def config(&block) if block instance_eval(&block) else Veritrans::Config end end |
.decode_notification_json(input) ⇒ Object
Note: Veritrans sending notification data as json, encoded twice so we should call JSON.parse twice
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/veritrans.rb', line 71 def decode_notification_json(input) if input.start_with?('"{') && input.end_with?('}"') # ruby's JSON library can't excpect only hash or array. To decode string I wrap it in array. request_data = Veritrans::Client._json_decode('[' + input + ']').first return Veritrans::Client._json_decode(request_data) else # in case we will make it in expected way later return Veritrans::Client._json_decode(input) end end |
.events ⇒ Object
65 66 67 |
# File 'lib/veritrans.rb', line 65 def events Veritrans::Events if defined?(Veritrans::Events) end |
.file_logger ⇒ Object
Logger to file, only important information For rails apps it will write log to RAILS_ROOT/log/veritrans.log
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/veritrans.rb', line 49 def file_logger if !@file_logger if defined?(Rails) && Rails.root @file_logger = Logger.new(Rails.root.join("log/veritrans.log").to_s) else @file_logger = Logger.new("/dev/null") end end @file_logger end |
.file_logger=(value) ⇒ Object
61 62 63 |
# File 'lib/veritrans.rb', line 61 def file_logger=(value) @file_logger = value end |
.logger ⇒ Object
General logger for rails apps it’s === Rails.logger for non-rails apps it’s logging to stdout
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/veritrans.rb', line 29 def logger return @logger if @logger if defined?(Rails) Rails.logger else unless @log require 'logger' @log = Logger.new(STDOUT) @log.level = Logger::INFO end @log end end |
.logger=(value) ⇒ Object
43 44 45 |
# File 'lib/veritrans.rb', line 43 def logger=(value) @logger = value end |