veritrans 2.1.3 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +6 -1
- data/.travis.yml +3 -5
- data/CHANGELOG.md +20 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +89 -94
- data/Procfile +1 -1
- data/README.md +62 -13
- data/api_reference.md +10 -10
- data/example/rails/cable/Gemfile +48 -0
- data/example/rails/cable/Gemfile.lock +184 -0
- data/example/rails/cable/README.md +29 -0
- data/example/rails/cable/Rakefile +6 -0
- data/example/rails/cable/app/assets/config/manifest.js +3 -0
- data/example/rails/cable/app/assets/images/.keep +0 -0
- data/example/rails/cable/app/assets/javascripts/application.js +15 -0
- data/example/rails/cable/app/assets/javascripts/cable.js +13 -0
- data/example/rails/cable/app/assets/javascripts/channels/.keep +0 -0
- data/example/rails/cable/app/assets/javascripts/chats.js +39 -0
- data/example/rails/cable/app/assets/javascripts/rooms.js +55 -0
- data/example/rails/cable/app/assets/stylesheets/application.css +16 -0
- data/example/rails/cable/app/assets/stylesheets/chatbox.scss +31 -0
- data/example/rails/cable/app/assets/stylesheets/peoplebox.scss +6 -0
- data/example/rails/cable/app/channels/application_cable/channel.rb +4 -0
- data/example/rails/cable/app/channels/application_cable/connection.rb +4 -0
- data/example/rails/cable/app/channels/rooms_texting_channel.rb +13 -0
- data/example/rails/cable/app/controllers/application_controller.rb +3 -0
- data/example/rails/cable/app/controllers/chats_controller.rb +18 -0
- data/example/rails/cable/app/controllers/concerns/.keep +0 -0
- data/example/rails/cable/app/controllers/pays_controller.rb +28 -0
- data/example/rails/cable/app/controllers/rooms_controller.rb +4 -0
- data/example/rails/cable/app/helpers/application_helper.rb +2 -0
- data/example/rails/cable/app/helpers/chats_helper.rb +2 -0
- data/example/rails/cable/app/helpers/rooms_helper.rb +5 -0
- data/example/rails/cable/app/jobs/application_job.rb +2 -0
- data/example/rails/cable/app/jobs/chat_broadcaster_job.rb +15 -0
- data/example/rails/cable/app/mailers/application_mailer.rb +4 -0
- data/example/rails/cable/app/models/application_record.rb +3 -0
- data/example/rails/cable/app/models/chat.rb +41 -0
- data/example/rails/cable/app/models/concerns/.keep +0 -0
- data/example/rails/cable/app/models/order.rb +2 -0
- data/example/rails/cable/app/models/user.rb +2 -0
- data/example/rails/cable/app/views/chats/_chat.html.erb +18 -0
- data/example/rails/cable/app/views/layouts/application.html.erb +19 -0
- data/example/rails/cable/app/views/layouts/mailer.html.erb +13 -0
- data/example/rails/cable/app/views/layouts/mailer.text.erb +1 -0
- data/example/rails/cable/app/views/rooms/_chatbox.html.erb +13 -0
- data/example/rails/cable/app/views/rooms/_online_people.html.erb +53 -0
- data/example/rails/cable/app/views/rooms/index.html.erb +9 -0
- data/example/rails/cable/bin/bundle +3 -0
- data/example/rails/cable/bin/rails +9 -0
- data/example/rails/cable/bin/rake +9 -0
- data/example/rails/cable/bin/setup +34 -0
- data/example/rails/cable/bin/spring +16 -0
- data/example/rails/cable/bin/update +29 -0
- data/example/rails/cable/config.ru +5 -0
- data/example/rails/cable/config/application.rb +16 -0
- data/example/rails/cable/config/boot.rb +3 -0
- data/example/rails/cable/config/cable.yml +9 -0
- data/example/rails/cable/config/database.yml +20 -0
- data/example/rails/cable/config/environment.rb +5 -0
- data/example/rails/cable/config/environments/development.rb +57 -0
- data/example/rails/cable/config/environments/production.rb +86 -0
- data/example/rails/cable/config/environments/test.rb +42 -0
- data/example/rails/cable/config/initializers/application_controller_renderer.rb +6 -0
- data/example/rails/cable/config/initializers/assets.rb +11 -0
- data/example/rails/cable/config/initializers/backtrace_silencers.rb +7 -0
- data/example/rails/cable/config/initializers/cookies_serializer.rb +5 -0
- data/example/rails/cable/config/initializers/filter_parameter_logging.rb +4 -0
- data/example/rails/cable/config/initializers/inflections.rb +16 -0
- data/example/rails/cable/config/initializers/mime_types.rb +4 -0
- data/example/rails/cable/config/initializers/new_framework_defaults.rb +24 -0
- data/example/rails/cable/config/initializers/session_store.rb +3 -0
- data/example/rails/cable/config/initializers/sidekiq.rb +2 -0
- data/example/rails/cable/config/initializers/veritrans.rb +46 -0
- data/example/rails/cable/config/initializers/wrap_parameters.rb +14 -0
- data/example/rails/cable/config/locales/en.yml +23 -0
- data/example/rails/cable/config/puma.rb +47 -0
- data/example/rails/cable/config/routes.rb +18 -0
- data/example/rails/cable/config/secrets.yml +22 -0
- data/example/rails/cable/config/spring.rb +6 -0
- data/example/rails/cable/config/veritrans.yml +13 -0
- data/example/rails/cable/db/development.sqlite3 +0 -0
- data/example/rails/cable/db/migrate/20161215070044_create_chats.rb +10 -0
- data/example/rails/cable/db/migrate/20161215072021_create_users.rb +10 -0
- data/example/rails/cable/db/migrate/20161219110219_create_orders.rb +11 -0
- data/example/rails/cable/db/schema.rb +37 -0
- data/example/rails/cable/db/seeds.rb +41 -0
- data/example/rails/cable/db/test.sqlite3 +0 -0
- data/example/rails/cable/lib/assets/.keep +0 -0
- data/example/rails/cable/lib/tasks/.keep +0 -0
- data/example/rails/cable/public/404.html +67 -0
- data/example/rails/cable/public/422.html +67 -0
- data/example/rails/cable/public/500.html +66 -0
- data/example/rails/cable/public/apple-touch-icon-precomposed.png +0 -0
- data/example/rails/cable/public/apple-touch-icon.png +0 -0
- data/example/rails/cable/public/favicon.ico +0 -0
- data/example/rails/cable/public/images/avatar1.jpg +0 -0
- data/example/rails/cable/public/images/avatar2.jpg +0 -0
- data/example/rails/cable/public/images/avatar3.jpg +0 -0
- data/example/rails/cable/public/images/avatar4.jpg +0 -0
- data/example/rails/cable/public/images/avatar5.jpg +0 -0
- data/example/rails/cable/public/images/avatar6.jpg +0 -0
- data/example/rails/cable/public/robots.txt +5 -0
- data/example/rails/cable/vendor/assets/javascripts/.keep +0 -0
- data/example/rails/cable/vendor/assets/stylesheets/.keep +0 -0
- data/example/rails/cable/vendor/assets/stylesheets/photon.css +2333 -0
- data/example/rails/simplepay/Gemfile +54 -0
- data/example/rails/simplepay/Gemfile.lock +178 -0
- data/example/rails/simplepay/README.md +30 -0
- data/example/rails/simplepay/Rakefile +6 -0
- data/example/rails/simplepay/app/assets/config/manifest.js +3 -0
- data/example/rails/simplepay/app/assets/images/.keep +0 -0
- data/example/rails/simplepay/app/assets/javascripts/application.js +16 -0
- data/example/rails/simplepay/app/assets/javascripts/cable.js +13 -0
- data/example/rails/simplepay/app/assets/javascripts/channels/.keep +0 -0
- data/example/rails/simplepay/app/assets/javascripts/pay.js +18 -0
- data/example/rails/simplepay/app/assets/stylesheets/application.css +15 -0
- data/example/rails/simplepay/app/assets/stylesheets/style.css +254 -0
- data/example/rails/simplepay/app/channels/application_cable/channel.rb +4 -0
- data/example/rails/simplepay/app/channels/application_cable/connection.rb +4 -0
- data/example/rails/simplepay/app/controllers/application_controller.rb +3 -0
- data/example/rails/simplepay/app/controllers/concerns/.keep +0 -0
- data/example/rails/simplepay/app/controllers/home_controller.rb +16 -0
- data/example/rails/simplepay/app/controllers/pay_controller.rb +10 -0
- data/example/rails/simplepay/app/helpers/application_helper.rb +2 -0
- data/example/rails/simplepay/app/helpers/pay_helper.rb +2 -0
- data/example/rails/simplepay/app/jobs/application_job.rb +2 -0
- data/example/rails/simplepay/app/mailers/application_mailer.rb +4 -0
- data/example/rails/simplepay/app/models/application_record.rb +3 -0
- data/example/rails/simplepay/app/models/concerns/.keep +0 -0
- data/example/rails/simplepay/app/models/order.rb +2 -0
- data/example/rails/simplepay/app/views/home/index.html.erb +19 -0
- data/example/rails/simplepay/app/views/layouts/application.html.erb +15 -0
- data/example/rails/simplepay/app/views/layouts/mailer.html.erb +13 -0
- data/example/rails/simplepay/app/views/layouts/mailer.text.erb +1 -0
- data/example/rails/simplepay/app/views/pay/notify.html.erb +2 -0
- data/example/rails/simplepay/bin/bundle +3 -0
- data/example/rails/simplepay/bin/rails +9 -0
- data/example/rails/simplepay/bin/rake +9 -0
- data/example/rails/simplepay/bin/setup +34 -0
- data/example/rails/simplepay/bin/spring +16 -0
- data/example/rails/simplepay/bin/update +29 -0
- data/example/rails/simplepay/config.ru +5 -0
- data/example/rails/simplepay/config/application.rb +15 -0
- data/example/rails/simplepay/config/boot.rb +3 -0
- data/example/rails/simplepay/config/cable.yml +9 -0
- data/example/rails/simplepay/config/database.yml +25 -0
- data/example/rails/simplepay/config/environment.rb +5 -0
- data/example/rails/simplepay/config/environments/development.rb +57 -0
- data/example/rails/simplepay/config/environments/production.rb +86 -0
- data/example/rails/simplepay/config/environments/test.rb +42 -0
- data/example/rails/simplepay/config/initializers/application_controller_renderer.rb +6 -0
- data/example/rails/simplepay/config/initializers/assets.rb +11 -0
- data/example/rails/simplepay/config/initializers/backtrace_silencers.rb +7 -0
- data/example/rails/simplepay/config/initializers/cookies_serializer.rb +5 -0
- data/example/rails/simplepay/config/initializers/filter_parameter_logging.rb +4 -0
- data/example/rails/simplepay/config/initializers/inflections.rb +16 -0
- data/example/rails/simplepay/config/initializers/mime_types.rb +4 -0
- data/example/rails/simplepay/config/initializers/new_framework_defaults.rb +24 -0
- data/example/rails/simplepay/config/initializers/session_store.rb +3 -0
- data/example/rails/simplepay/config/initializers/veritrans.rb +46 -0
- data/example/rails/simplepay/config/initializers/wrap_parameters.rb +14 -0
- data/example/rails/simplepay/config/locales/en.yml +23 -0
- data/example/rails/simplepay/config/puma.rb +47 -0
- data/example/rails/simplepay/config/routes.rb +5 -0
- data/example/rails/simplepay/config/secrets.yml +22 -0
- data/example/rails/simplepay/config/spring.rb +6 -0
- data/example/rails/simplepay/config/veritrans.yml +18 -0
- data/example/rails/simplepay/db/development.sqlite3 +0 -0
- data/example/rails/simplepay/db/migrate/20161221090855_create_orders.rb +10 -0
- data/example/rails/simplepay/db/schema.rb +22 -0
- data/example/rails/simplepay/db/seeds.rb +7 -0
- data/example/rails/simplepay/db/test.sqlite3 +0 -0
- data/example/rails/simplepay/lib/assets/.keep +0 -0
- data/example/rails/simplepay/lib/tasks/.keep +0 -0
- data/example/rails/simplepay/public/404.html +67 -0
- data/example/rails/simplepay/public/422.html +67 -0
- data/example/rails/simplepay/public/500.html +66 -0
- data/example/rails/simplepay/public/apple-touch-icon-precomposed.png +0 -0
- data/example/rails/simplepay/public/apple-touch-icon.png +0 -0
- data/example/rails/simplepay/public/favicon.ico +0 -0
- data/example/rails/simplepay/public/robots.txt +5 -0
- data/example/rails/simplepay/vendor/assets/javascripts/.keep +0 -0
- data/example/rails/simplepay/vendor/assets/stylesheets/.keep +0 -0
- data/example/{README.md → sinatra/README.md} +0 -0
- data/example/{config.ru → sinatra/config.ru} +3 -0
- data/example/{index.erb → sinatra/index.erb} +7 -6
- data/example/{localization.erb → sinatra/localization.erb} +6 -5
- data/example/{points.erb → sinatra/points.erb} +6 -5
- data/example/{recurring.erb → sinatra/recurring.erb} +6 -6
- data/example/{response.erb → sinatra/response.erb} +4 -1
- data/example/{sinatra.rb → sinatra/sinatra.rb} +9 -3
- data/example/{style.css → sinatra/style.css} +11 -0
- data/example/{veritrans.yml → sinatra/veritrans.yml} +2 -2
- data/example/{widget.erb → sinatra/widget.erb} +18 -6
- data/lib/generators/templates/assets/credit_card_form.js +6 -0
- data/lib/generators/templates/payments_controller.rb +4 -4
- data/lib/generators/templates/veritrans.yml +5 -5
- data/lib/generators/templates/views/_credit_card_form.erb +2 -2
- data/lib/generators/templates/views/_veritrans_include.erb +1 -1
- data/lib/generators/veritrans/install_generator.rb +1 -1
- data/lib/generators/veritrans/payment_form_generator.rb +1 -1
- data/lib/veritrans.rb +106 -5
- data/lib/veritrans/api.rb +7 -7
- data/lib/veritrans/cli.rb +11 -5
- data/lib/veritrans/client.rb +7 -4
- data/lib/veritrans/config.rb +5 -3
- data/lib/veritrans/events.rb +46 -35
- data/lib/veritrans/result.rb +58 -2
- data/lib/veritrans/testing.rb +156 -0
- data/lib/veritrans/version.rb +1 -1
- data/spec/cli_spec.rb +2 -2
- data/spec/fixtures/approve_failed.yml +1 -1
- data/spec/fixtures/cancel_failed.yml +1 -1
- data/spec/fixtures/cancel_success.yml +2 -2
- data/spec/fixtures/capture_failed.yml +1 -1
- data/spec/fixtures/charge.yml +2 -2
- data/spec/fixtures/charge_direct.yml +1 -1
- data/spec/fixtures/charge_vtweb.yml +2 -2
- data/spec/fixtures/cli_test_1111-not-exists.yml +1 -1
- data/spec/fixtures/cli_test_not_exists.yml +1 -1
- data/spec/fixtures/cli_test_real_txn.yml +1 -1
- data/spec/fixtures/cli_test_unauthorized.yml +1 -1
- data/spec/fixtures/events_test_real_txn.yml +1 -1
- data/spec/fixtures/expire_failed.yml +1 -1
- data/spec/fixtures/expire_success.yml +1 -1
- data/spec/fixtures/midtrans_status.yml +2 -2
- data/spec/fixtures/status_fail.yml +1 -1
- data/spec/fixtures/status_success.yml +2 -2
- data/spec/rails_plugin_spec.rb +37 -20
- data/spec/spec_helper.rb +0 -1
- data/spec/veritrans_client_spec.rb +1 -1
- data/spec/veritrans_config_spec.rb +1 -1
- data/spec/veritrans_events_spec.rb +6 -6
- data/spec/veritrans_testing_spec.rb +184 -0
- data/testing_webhooks.md +2 -2
- data/veritrans.gemspec +1 -1
- metadata +195 -16
- data/lib/veritrans/core_extensions.rb +0 -32
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: post
|
5
|
-
uri: https://api.sandbox.
|
5
|
+
uri: https://api.sandbox.midtrans.com/v2/af3fb136-c405-4103-9a36-5a6a9e2855a9/expire
|
6
6
|
body:
|
7
7
|
encoding: UTF-8
|
8
8
|
string: 'null'
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: post
|
5
|
-
uri: https://api.sandbox.
|
5
|
+
uri: https://api.sandbox.midtrans.com/v2/charge
|
6
6
|
body:
|
7
7
|
encoding: UTF-8
|
8
8
|
string: '{"payment_type":"permata","transaction_details":{"order_id":"2016-10-20
|
@@ -58,7 +58,7 @@ http_interactions:
|
|
58
58
|
recorded_at: Thu, 20 Oct 2016 05:39:18 GMT
|
59
59
|
- request:
|
60
60
|
method: get
|
61
|
-
uri: https://api.sandbox.
|
61
|
+
uri: https://api.sandbox.midtrans.com/v2/2016-10-20%2012:39:16%20+0700/status
|
62
62
|
body:
|
63
63
|
encoding: US-ASCII
|
64
64
|
string: ''
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: post
|
5
|
-
uri: https://api.sandbox.
|
5
|
+
uri: https://api.sandbox.midtrans.com/v2/charge
|
6
6
|
body:
|
7
7
|
encoding: UTF-8
|
8
8
|
string: '{"payment_type":"permata","transaction_details":{"order_id":1415110500,"gross_amount":100000}}'
|
@@ -54,7 +54,7 @@ http_interactions:
|
|
54
54
|
recorded_at: Tue, 04 Nov 2014 14:15:00 GMT
|
55
55
|
- request:
|
56
56
|
method: get
|
57
|
-
uri: https://api.sandbox.
|
57
|
+
uri: https://api.sandbox.midtrans.com/v2/1415110500/status
|
58
58
|
body:
|
59
59
|
encoding: US-ASCII
|
60
60
|
string: ''
|
data/spec/rails_plugin_spec.rb
CHANGED
@@ -6,11 +6,11 @@ require 'socket'
|
|
6
6
|
describe "Rails plugin", vcr: false do
|
7
7
|
include Capybara::DSL
|
8
8
|
|
9
|
-
MAIN_RAILS_VER = "5.
|
9
|
+
MAIN_RAILS_VER = "5.1.0"
|
10
10
|
APP_DIR = "plugin_test"
|
11
11
|
PLUGIN_DIR = File.expand_path("..", File.dirname(__FILE__))
|
12
12
|
|
13
|
-
RAILS_VERSIONS = ["4.
|
13
|
+
RAILS_VERSIONS = ["4.1.16", "4.2.8", "5.0.2", "5.1.0"]
|
14
14
|
|
15
15
|
before :all do
|
16
16
|
FileUtils.mkdir_p("#{PLUGIN_DIR}/tmp")
|
@@ -31,19 +31,21 @@ describe "Rails plugin", vcr: false do
|
|
31
31
|
def run_cmd(cmd, cli_args = [])
|
32
32
|
full_cmd = ([cmd] + cli_args).join.strip
|
33
33
|
|
34
|
-
|
34
|
+
puts "RUN: #{full_cmd}" if ENV['DEBUG']
|
35
|
+
|
36
|
+
output, status = Open3.capture2e(full_cmd)
|
35
37
|
|
36
38
|
if status != 0
|
37
39
|
puts "CMD: #{full_cmd}"
|
38
40
|
puts "FAILED"
|
39
|
-
puts
|
41
|
+
puts output
|
40
42
|
|
41
43
|
exit 1
|
42
44
|
end
|
43
45
|
|
44
46
|
#puts stdout_str
|
45
47
|
|
46
|
-
return
|
48
|
+
return output
|
47
49
|
end
|
48
50
|
|
49
51
|
def install_rails_in_tmp(rails_version = MAIN_RAILS_VER)
|
@@ -70,9 +72,6 @@ describe "Rails plugin", vcr: false do
|
|
70
72
|
end
|
71
73
|
|
72
74
|
def generate_rails_app(rails_version)
|
73
|
-
gen = "rails _#{rails_version}_ new #{APP_DIR} -B -G --skip-spring -d sqlite3 --skip-turbolinks --skip-test-unit --skip-action-cable --no-rc --skip-puma --skip-listen"
|
74
|
-
run_cmd(gen)
|
75
|
-
|
76
75
|
gemfile_content = "
|
77
76
|
source 'https://rubygems.org'
|
78
77
|
|
@@ -83,6 +82,13 @@ describe "Rails plugin", vcr: false do
|
|
83
82
|
gem 'veritrans', path: '#{PLUGIN_DIR}'
|
84
83
|
".gsub(/^\s+/, '')
|
85
84
|
|
85
|
+
File.open("./Gemfile", "w") {|f| f.write(gemfile_content) }
|
86
|
+
run_cmd("bundle")
|
87
|
+
|
88
|
+
gen = "bundle exec rails _#{rails_version}_ new #{APP_DIR} -B -G --skip-spring -d sqlite3 --skip-turbolinks --skip-test-unit --skip-action-cable --no-rc --skip-puma --skip-listen"
|
89
|
+
|
90
|
+
run_cmd(gen)
|
91
|
+
|
86
92
|
File.open("#{@app_abs_path}/Gemfile", "w") {|f| f.write(gemfile_content) }
|
87
93
|
|
88
94
|
Dir.chdir(@app_abs_path) do
|
@@ -100,7 +106,7 @@ describe "Rails plugin", vcr: false do
|
|
100
106
|
development:
|
101
107
|
client_key: VT-client-NArmatJZqzsmTmzR
|
102
108
|
server_key: VT-server-9Htb-RxXkg7-7hznSCCjxvoY
|
103
|
-
api_host: https://api.sandbox.
|
109
|
+
api_host: https://api.sandbox.midtrans.com
|
104
110
|
"
|
105
111
|
|
106
112
|
File.open("#{@app_abs_path}/config/veritrans.yml", "w") {|f| f.write(config_content) }
|
@@ -109,31 +115,40 @@ development:
|
|
109
115
|
def run_rails_app
|
110
116
|
@rails_port = find_open_port
|
111
117
|
|
118
|
+
server_cmd = "./bin/rails server -p #{@rails_port} -b 127.0.0.1"
|
119
|
+
server_env = {"RAILS_ENV" => "development", "BUNDLE_GEMFILE" => @app_abs_path + "/Gemfile"}
|
120
|
+
spawn_opts = {chdir: @app_abs_path}
|
121
|
+
spawn_opts.merge!([:err, :out] => "/dev/null") unless ENV['DEBUG']
|
122
|
+
|
112
123
|
Bundler.with_clean_env do
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
end
|
124
|
+
puts "RUN: #{server_cmd} #{spawn_opts}" if ENV['DEBUG']
|
125
|
+
@runner_pid = spawn(server_env, server_cmd, spawn_opts)
|
126
|
+
puts "Process running PID: #{$runner_pid}" if ENV['DEBUG']
|
117
127
|
end
|
118
128
|
|
119
129
|
Capybara.app_host = "http://127.0.0.1:#{@rails_port}"
|
120
130
|
|
121
131
|
#puts "RAILS_DIR: #{@app_abs_path}"
|
122
132
|
|
133
|
+
check_cmd = "curl #{Capybara.app_host}/payments/new"
|
134
|
+
|
123
135
|
failed = 0
|
124
|
-
while failed <
|
125
|
-
|
126
|
-
|
136
|
+
while failed < 100
|
137
|
+
puts "Check if rails server UP (#{Capybara.app_host})" if ENV['DEBUG']
|
138
|
+
output, status = Open3.capture2e(check_cmd)
|
139
|
+
if status == 0 && output =~ /credit_card_number/
|
140
|
+
puts "Server is running, output:"
|
141
|
+
puts output
|
127
142
|
break
|
128
|
-
|
143
|
+
else
|
129
144
|
failed += 1
|
130
|
-
p error
|
131
|
-
puts "Retry"
|
145
|
+
#p error
|
146
|
+
#puts "Retry"
|
132
147
|
sleep 0.3
|
133
148
|
end
|
134
149
|
end
|
135
150
|
|
136
|
-
if failed ==
|
151
|
+
if failed == 100
|
137
152
|
puts `tail -100 #{@app_abs_path}/log/development.log`
|
138
153
|
raise Exception, "can not start rails server"
|
139
154
|
end
|
@@ -188,8 +203,10 @@ development:
|
|
188
203
|
|
189
204
|
RAILS_VERSIONS.each_with_index do |rails_version, spec_index|
|
190
205
|
next if rails_version.start_with?("5") && RUBY_VERSION < "2.2.2"
|
206
|
+
next if RUBY_VERSION >= "2.4.0" && rails_version < "4.2.0"
|
191
207
|
|
192
208
|
it "should tests plugin (Rails #{rails_version})" do
|
209
|
+
puts "Testing with Rails #{rails_version} and Ruby #{RUBY_VERSION}"
|
193
210
|
# PREPARE APP
|
194
211
|
install_rails_in_tmp(rails_version)
|
195
212
|
run_rails_app
|
data/spec/spec_helper.rb
CHANGED
@@ -21,7 +21,7 @@ describe Veritrans::Client do
|
|
21
21
|
|
22
22
|
result = Veritrans.request_with_logging(:get, Veritrans.config.api_host + "/ping", {})
|
23
23
|
|
24
|
-
api_request.headers["Host"].should == "api.sandbox.
|
24
|
+
api_request.headers["Host"].should == "api.sandbox.midtrans.com:443"
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should use Veritrans.http_options to attach hedaers", vcr: false do
|
@@ -12,7 +12,7 @@ describe Veritrans::Config do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should have sandbox api_host by defualt" do
|
15
|
-
Veritrans.config.api_host.should == "https://api.sandbox.
|
15
|
+
Veritrans.config.api_host.should == "https://api.sandbox.midtrans.com"
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should set client key and server key" do
|
@@ -6,13 +6,13 @@ describe Veritrans do
|
|
6
6
|
Veritrans.logger = Logger.new(STDOUT)
|
7
7
|
Veritrans.file_logger = Logger.new(STDOUT)
|
8
8
|
Veritrans.setup do
|
9
|
-
config.load_yml "./example/veritrans.yml#development"
|
9
|
+
config.load_yml "./example/sinatra/veritrans.yml#development"
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
after do
|
14
|
-
if Veritrans.
|
15
|
-
Veritrans.
|
14
|
+
if Veritrans::Events.listeners
|
15
|
+
Veritrans::Events.listeners.clear
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -34,13 +34,13 @@ describe Veritrans do
|
|
34
34
|
DOUBLE_ENCODED_JSON_RESPONSE = JSON.dump(JSON_RESPONSE)
|
35
35
|
|
36
36
|
def stub_vt_status_response
|
37
|
-
stub_request(:any, /.*veritrans.*/).to_return(lambda {|request|
|
37
|
+
stub_request(:any, /.*(veritrans|midtrans).*/).to_return(lambda {|request|
|
38
38
|
{status: 200, body: JSON_RESPONSE}
|
39
39
|
})
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should work with single encoded json" do
|
43
|
-
Veritrans.
|
43
|
+
Veritrans::Events.subscribe('payment.success') do |payment|
|
44
44
|
@payment = payment
|
45
45
|
end
|
46
46
|
|
@@ -55,7 +55,7 @@ describe Veritrans do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should work with double encoded json" do
|
58
|
-
Veritrans.
|
58
|
+
Veritrans::Events.subscribe('payment.success') do |payment|
|
59
59
|
@payment = payment
|
60
60
|
end
|
61
61
|
|
@@ -0,0 +1,184 @@
|
|
1
|
+
describe Veritrans::Testing, skip: true do
|
2
|
+
|
3
|
+
before do
|
4
|
+
hide_const("Rails")
|
5
|
+
#Veritrans.logger = Logger.new("/dev/null")
|
6
|
+
Veritrans.setup do
|
7
|
+
config.load_config "./spec/configs/real_key.yml"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context "Peramata VA" do
|
12
|
+
it "It should pay Peramata VA txn", vcr: false do
|
13
|
+
txn_result = Veritrans.charge("bank_transfer",
|
14
|
+
bank_transfer: {bank: "permata"},
|
15
|
+
transaction_details: txn_details
|
16
|
+
)
|
17
|
+
txn_result.success?.should == true
|
18
|
+
txn_result.status_message.should == "Success, PERMATA VA transaction is successful"
|
19
|
+
|
20
|
+
result = Veritrans::Testing.pay_permata_va(txn_result.permata_va_number)
|
21
|
+
|
22
|
+
result['status'].should == 'SUCCESS'
|
23
|
+
assert_txn_status(txn_result.order_id, 'settlement')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "bca va" do
|
28
|
+
it "should pay for BCA VA", vcr: false do
|
29
|
+
txn_result = Veritrans.charge("bank_transfer",
|
30
|
+
bank_transfer: {bank: "bca"},
|
31
|
+
transaction_details: txn_details
|
32
|
+
)
|
33
|
+
va_number = txn_result.va_numbers[0]['va_number']
|
34
|
+
|
35
|
+
result = Veritrans::Testing.pay_bca_va(va_number)
|
36
|
+
|
37
|
+
result['status'].should == 'SUCCESS'
|
38
|
+
assert_txn_status(txn_result.order_id, 'settlement')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "Mandiri Bill" do
|
43
|
+
it "should pay for Mandiri Bill", vcr: false do
|
44
|
+
txn_result = Veritrans.charge('echannel',
|
45
|
+
echannel: {bill_info1: "Payment for", bill_info2: "Test txn"},
|
46
|
+
transaction_details: txn_details,
|
47
|
+
item_details: [ { id: 'a1', price: txn_details[:gross_amount], quantity: 1, name: 'Violin' } ]
|
48
|
+
)
|
49
|
+
|
50
|
+
result = Veritrans::Testing.pay_mandiri_bill(txn_result.bill_key)
|
51
|
+
result['status'].should == 'SUCCESS'
|
52
|
+
assert_txn_status(txn_result.order_id, 'settlement')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "klik bca" do
|
57
|
+
it "should pay for klik bca", vcr: false do
|
58
|
+
txn_result = Veritrans.charge("bca_klikbca",
|
59
|
+
bca_klikbca: {user_id: 'testuser123', description: "Test txn"},
|
60
|
+
transaction_details: txn_details
|
61
|
+
)
|
62
|
+
|
63
|
+
result = Veritrans::Testing.pay_klik_bca('1234000937', 'testuser123', txn_result.order_id)
|
64
|
+
|
65
|
+
result['status'].should == 'SUCCESS'
|
66
|
+
assert_txn_status(txn_result.order_id, 'settlement')
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "indomaret" do
|
71
|
+
it "should pay for indomaret transaction", vcr: false do
|
72
|
+
txn_result = Veritrans.charge('cstore',
|
73
|
+
cstore: {store: "Indomaret", message: "Buah Mangga"},
|
74
|
+
transaction_details: txn_details
|
75
|
+
)
|
76
|
+
|
77
|
+
result = Veritrans::Testing.pay_indomaret(txn_result.payment_code)
|
78
|
+
|
79
|
+
result['status'].should == 'SUCCESS'
|
80
|
+
assert_txn_status(txn_result.order_id, 'settlement')
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context "cimb clicks" do
|
85
|
+
it "should get cimb clicks txn info", vcr: false do
|
86
|
+
|
87
|
+
txn_result = Veritrans.charge("cimb_clicks",
|
88
|
+
cimb_clicks: { description: "My Payment" },
|
89
|
+
transaction_details: txn_details
|
90
|
+
)
|
91
|
+
|
92
|
+
cimb_txn = Veritrans::Testing.get_cimb_clicks(txn_result.redirect_url)
|
93
|
+
|
94
|
+
cimb_txn.should == {
|
95
|
+
"status_code" => "00",
|
96
|
+
"amount" => "100000.00",
|
97
|
+
"status" => "SUCCESS",
|
98
|
+
"user_email" => "noreply@veritrans.co.id",
|
99
|
+
"message" => "Success Inquiry Cimb Clicks",
|
100
|
+
"user_name" => "Veritrans"
|
101
|
+
}
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should pay cimb clicks txn", vcr: false do
|
105
|
+
txn_result = Veritrans.charge("cimb_clicks",
|
106
|
+
cimb_clicks: { description: "My Payment" },
|
107
|
+
transaction: { order_id: Time.now.to_s, gross_amount: 100_000 }
|
108
|
+
)
|
109
|
+
|
110
|
+
result = Veritrans::Testing.pay_cimb_clicks(txn_result.redirect_url)
|
111
|
+
|
112
|
+
result['status'].should == 'SUCCESS'
|
113
|
+
assert_txn_status(txn_result.order_id, 'settlement')
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should reject cimb clicks txn with wrong user_id", vcr: false do
|
117
|
+
txn_result = Veritrans.charge("cimb_clicks",
|
118
|
+
cimb_clicks: { description: "My Payment" },
|
119
|
+
transaction: { order_id: Time.now.to_s, gross_amount: 100_000 }
|
120
|
+
)
|
121
|
+
|
122
|
+
result = Veritrans::Testing.pay_cimb_clicks(txn_result.redirect_url, 'aaaa')
|
123
|
+
|
124
|
+
result['status'].should == 'ERROR'
|
125
|
+
assert_txn_status(txn_result.order_id, 'pending')
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
context "SNAP" do
|
130
|
+
it "should confirm snap payment", vcr: false do
|
131
|
+
snap_txn_details = txn_details
|
132
|
+
result = Veritrans.create_snap_token(transaction_details: snap_txn_details)
|
133
|
+
|
134
|
+
snap_result = Veritrans::Testing.pay_snap(result.token, 'mandiri_clickpay', {
|
135
|
+
payment_params: {
|
136
|
+
mandiri_card_no: "4111111111111111",
|
137
|
+
input3: 43044,
|
138
|
+
token_response: '000000'
|
139
|
+
}
|
140
|
+
})
|
141
|
+
|
142
|
+
snap_result['status_code'].should == '200'
|
143
|
+
snap_result['transaction_status'].should == 'settlement'
|
144
|
+
snap_result['finish_redirect_url'].should =~ /.+/
|
145
|
+
|
146
|
+
assert_txn_status(snap_txn_details[:order_id], 'settlement')
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should complete snap payment for permata VA", vcr: false do
|
150
|
+
snap_txn_details = txn_details
|
151
|
+
result = Veritrans.create_snap_token(transaction_details: snap_txn_details)
|
152
|
+
|
153
|
+
snap_result = Veritrans::Testing.pay_snap(result.token, 'permata_va', {
|
154
|
+
#customer_details: {
|
155
|
+
# email: "budi@utomo.com"
|
156
|
+
#}
|
157
|
+
})
|
158
|
+
|
159
|
+
snap_result['status_code'].should == '201'
|
160
|
+
snap_result['transaction_status'].should == 'pending'
|
161
|
+
snap_result['permata_va_number'].should =~ /.+/
|
162
|
+
|
163
|
+
result = Veritrans::Testing.pay_permata_va(snap_result['permata_va_number'])
|
164
|
+
|
165
|
+
result['status'].should == 'SUCCESS'
|
166
|
+
assert_txn_status(snap_txn_details[:order_id], 'settlement')
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def txn_details
|
171
|
+
{ order_id: "gem-testing-" + (Time.now.to_f * 1000).round.to_s(36), gross_amount: 100_000 }
|
172
|
+
end
|
173
|
+
|
174
|
+
def assert_txn_status(order_id, status)
|
175
|
+
status_result = nil
|
176
|
+
3.times do
|
177
|
+
status_result = Veritrans.status(order_id)
|
178
|
+
break if status_result.transaction_status == status
|
179
|
+
sleep 0.3
|
180
|
+
end
|
181
|
+
status_result.transaction_status.should == status
|
182
|
+
end
|
183
|
+
|
184
|
+
end
|
data/testing_webhooks.md
CHANGED
@@ -5,7 +5,7 @@ For better security we recommend to use webhooks and check status of transaction
|
|
5
5
|
Webhook is http post request that veritrans send to merchant's server when any transaction change status.
|
6
6
|
It can be success transaction, can be failed transaction, and when transaction settled.
|
7
7
|
|
8
|
-
Now you can set webhook url at https://
|
8
|
+
Now you can set webhook url at https://dashboard.sandbox.midtrans.com/settings/vtweb_configuration
|
9
9
|
|
10
10
|
## Veritrans command line tool
|
11
11
|
|
@@ -53,7 +53,7 @@ Also you can collect requests online for further inspection.
|
|
53
53
|
|
54
54
|
To receive http notification from veritrans you can try to make transaction or use callback tester in merchant portal
|
55
55
|
|
56
|
-
https://
|
56
|
+
https://dashboard.sandbox.midtrans.com/settings/vtweb_configuration/test_callback
|
57
57
|
|
58
58
|
|
59
59
|
## Format
|