veritrans 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/.idea/.gitignore +8 -0
- data/.rubocop.yml +1 -1
- data/.travis.yml +2 -1
- data/CHANGELOG.md +13 -0
- data/Gemfile +2 -11
- data/Gemfile.lock +116 -145
- data/Maintaining.MD +8 -0
- data/README.md +247 -278
- data/api_reference.md +482 -173
- data/example/coreapi/core_api_credit_card_example.rb +66 -0
- data/example/coreapi/readme.md +4 -0
- data/example/sinatra/Gemfile +7 -0
- data/example/sinatra/README.md +4 -6
- data/example/sinatra/index.erb +180 -192
- data/example/sinatra/response.erb +1 -40
- data/example/sinatra/snap.erb +33 -0
- data/example/sinatra/snap_redirect.erb +10 -0
- data/example/sinatra/webapp.rb +113 -0
- data/example/snap/readme.md +4 -0
- data/example/snap/snap_example.rb +39 -0
- data/lib/test/all.rb +1 -0
- data/lib/test/api_test.rb +319 -0
- data/lib/test/config_test.rb +26 -0
- data/lib/test/gopay_tokenization_test.rb +80 -0
- data/lib/test/snap_test.rb +79 -0
- data/lib/test/subscription_test.rb +116 -0
- data/lib/test/transaction_test.rb +160 -0
- data/lib/veritrans/api.rb +105 -8
- data/lib/veritrans/client.rb +40 -7
- data/lib/veritrans/config.rb +26 -3
- data/lib/veritrans/midtrans_error.rb +15 -0
- data/lib/veritrans/version.rb +1 -1
- data/lib/veritrans.rb +5 -6
- data/veritrans.gemspec +1 -2
- metadata +25 -248
- data/.rspec +0 -2
- data/Procfile +0 -1
- data/Rakefile +0 -16
- data/bin/midtrans +0 -3
- data/bin/veritrans +0 -68
- data/example/rails/cable/Gemfile +0 -48
- data/example/rails/cable/Gemfile.lock +0 -184
- data/example/rails/cable/README.md +0 -29
- data/example/rails/cable/Rakefile +0 -6
- data/example/rails/cable/app/assets/config/manifest.js +0 -3
- data/example/rails/cable/app/assets/images/.keep +0 -0
- data/example/rails/cable/app/assets/javascripts/application.js +0 -15
- data/example/rails/cable/app/assets/javascripts/cable.js +0 -13
- data/example/rails/cable/app/assets/javascripts/channels/.keep +0 -0
- data/example/rails/cable/app/assets/javascripts/chats.js +0 -39
- data/example/rails/cable/app/assets/javascripts/rooms.js +0 -55
- data/example/rails/cable/app/assets/stylesheets/application.css +0 -16
- data/example/rails/cable/app/assets/stylesheets/chatbox.scss +0 -31
- data/example/rails/cable/app/assets/stylesheets/peoplebox.scss +0 -6
- data/example/rails/cable/app/channels/application_cable/channel.rb +0 -4
- data/example/rails/cable/app/channels/application_cable/connection.rb +0 -4
- data/example/rails/cable/app/channels/rooms_texting_channel.rb +0 -13
- data/example/rails/cable/app/controllers/application_controller.rb +0 -3
- data/example/rails/cable/app/controllers/chats_controller.rb +0 -18
- data/example/rails/cable/app/controllers/concerns/.keep +0 -0
- data/example/rails/cable/app/controllers/pays_controller.rb +0 -28
- data/example/rails/cable/app/controllers/rooms_controller.rb +0 -4
- data/example/rails/cable/app/helpers/application_helper.rb +0 -2
- data/example/rails/cable/app/helpers/chats_helper.rb +0 -2
- data/example/rails/cable/app/helpers/rooms_helper.rb +0 -5
- data/example/rails/cable/app/jobs/application_job.rb +0 -2
- data/example/rails/cable/app/jobs/chat_broadcaster_job.rb +0 -15
- data/example/rails/cable/app/mailers/application_mailer.rb +0 -4
- data/example/rails/cable/app/models/application_record.rb +0 -3
- data/example/rails/cable/app/models/chat.rb +0 -41
- data/example/rails/cable/app/models/concerns/.keep +0 -0
- data/example/rails/cable/app/models/order.rb +0 -2
- data/example/rails/cable/app/models/user.rb +0 -2
- data/example/rails/cable/app/views/chats/_chat.html.erb +0 -18
- data/example/rails/cable/app/views/layouts/application.html.erb +0 -19
- data/example/rails/cable/app/views/layouts/mailer.html.erb +0 -13
- data/example/rails/cable/app/views/layouts/mailer.text.erb +0 -1
- data/example/rails/cable/app/views/rooms/_chatbox.html.erb +0 -13
- data/example/rails/cable/app/views/rooms/_online_people.html.erb +0 -53
- data/example/rails/cable/app/views/rooms/index.html.erb +0 -9
- data/example/rails/cable/bin/bundle +0 -3
- data/example/rails/cable/bin/rails +0 -9
- data/example/rails/cable/bin/rake +0 -9
- data/example/rails/cable/bin/setup +0 -34
- data/example/rails/cable/bin/spring +0 -16
- data/example/rails/cable/bin/update +0 -29
- data/example/rails/cable/config/application.rb +0 -16
- data/example/rails/cable/config/boot.rb +0 -3
- data/example/rails/cable/config/cable.yml +0 -9
- data/example/rails/cable/config/database.yml +0 -20
- data/example/rails/cable/config/environment.rb +0 -5
- data/example/rails/cable/config/environments/development.rb +0 -57
- data/example/rails/cable/config/environments/production.rb +0 -86
- data/example/rails/cable/config/environments/test.rb +0 -42
- data/example/rails/cable/config/initializers/application_controller_renderer.rb +0 -6
- data/example/rails/cable/config/initializers/assets.rb +0 -11
- data/example/rails/cable/config/initializers/backtrace_silencers.rb +0 -7
- data/example/rails/cable/config/initializers/cookies_serializer.rb +0 -5
- data/example/rails/cable/config/initializers/filter_parameter_logging.rb +0 -4
- data/example/rails/cable/config/initializers/inflections.rb +0 -16
- data/example/rails/cable/config/initializers/mime_types.rb +0 -4
- data/example/rails/cable/config/initializers/new_framework_defaults.rb +0 -24
- data/example/rails/cable/config/initializers/session_store.rb +0 -3
- data/example/rails/cable/config/initializers/sidekiq.rb +0 -2
- data/example/rails/cable/config/initializers/veritrans.rb +0 -46
- data/example/rails/cable/config/initializers/wrap_parameters.rb +0 -14
- data/example/rails/cable/config/locales/en.yml +0 -23
- data/example/rails/cable/config/puma.rb +0 -47
- data/example/rails/cable/config/routes.rb +0 -18
- data/example/rails/cable/config/secrets.yml +0 -22
- data/example/rails/cable/config/spring.rb +0 -6
- data/example/rails/cable/config/veritrans.yml +0 -13
- data/example/rails/cable/config.ru +0 -5
- data/example/rails/cable/db/development.sqlite3 +0 -0
- data/example/rails/cable/db/migrate/20161215070044_create_chats.rb +0 -10
- data/example/rails/cable/db/migrate/20161215072021_create_users.rb +0 -10
- data/example/rails/cable/db/migrate/20161219110219_create_orders.rb +0 -11
- data/example/rails/cable/db/schema.rb +0 -37
- data/example/rails/cable/db/seeds.rb +0 -41
- 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/log/.keep +0 -0
- data/example/rails/cable/public/404.html +0 -67
- data/example/rails/cable/public/422.html +0 -67
- data/example/rails/cable/public/500.html +0 -66
- 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 +0 -5
- 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 +0 -2333
- data/example/rails/simplepay/Gemfile +0 -54
- data/example/rails/simplepay/Gemfile.lock +0 -178
- data/example/rails/simplepay/README.md +0 -30
- data/example/rails/simplepay/Rakefile +0 -6
- data/example/rails/simplepay/app/assets/config/manifest.js +0 -3
- data/example/rails/simplepay/app/assets/images/.keep +0 -0
- data/example/rails/simplepay/app/assets/javascripts/application.js +0 -16
- data/example/rails/simplepay/app/assets/javascripts/cable.js +0 -13
- data/example/rails/simplepay/app/assets/javascripts/channels/.keep +0 -0
- data/example/rails/simplepay/app/assets/javascripts/pay.js +0 -18
- data/example/rails/simplepay/app/assets/stylesheets/application.css +0 -15
- data/example/rails/simplepay/app/assets/stylesheets/style.css +0 -254
- data/example/rails/simplepay/app/channels/application_cable/channel.rb +0 -4
- data/example/rails/simplepay/app/channels/application_cable/connection.rb +0 -4
- data/example/rails/simplepay/app/controllers/application_controller.rb +0 -3
- data/example/rails/simplepay/app/controllers/concerns/.keep +0 -0
- data/example/rails/simplepay/app/controllers/home_controller.rb +0 -16
- data/example/rails/simplepay/app/controllers/pay_controller.rb +0 -10
- data/example/rails/simplepay/app/helpers/application_helper.rb +0 -2
- data/example/rails/simplepay/app/helpers/pay_helper.rb +0 -2
- data/example/rails/simplepay/app/jobs/application_job.rb +0 -2
- data/example/rails/simplepay/app/mailers/application_mailer.rb +0 -4
- data/example/rails/simplepay/app/models/application_record.rb +0 -3
- data/example/rails/simplepay/app/models/concerns/.keep +0 -0
- data/example/rails/simplepay/app/models/order.rb +0 -2
- data/example/rails/simplepay/app/views/home/index.html.erb +0 -19
- data/example/rails/simplepay/app/views/layouts/application.html.erb +0 -15
- data/example/rails/simplepay/app/views/layouts/mailer.html.erb +0 -13
- data/example/rails/simplepay/app/views/layouts/mailer.text.erb +0 -1
- data/example/rails/simplepay/app/views/pay/notify.html.erb +0 -2
- data/example/rails/simplepay/bin/bundle +0 -3
- data/example/rails/simplepay/bin/rails +0 -9
- data/example/rails/simplepay/bin/rake +0 -9
- data/example/rails/simplepay/bin/setup +0 -34
- data/example/rails/simplepay/bin/spring +0 -16
- data/example/rails/simplepay/bin/update +0 -29
- data/example/rails/simplepay/config/application.rb +0 -15
- data/example/rails/simplepay/config/boot.rb +0 -3
- data/example/rails/simplepay/config/cable.yml +0 -9
- data/example/rails/simplepay/config/database.yml +0 -25
- data/example/rails/simplepay/config/environment.rb +0 -5
- data/example/rails/simplepay/config/environments/development.rb +0 -57
- data/example/rails/simplepay/config/environments/production.rb +0 -86
- data/example/rails/simplepay/config/environments/test.rb +0 -42
- data/example/rails/simplepay/config/initializers/application_controller_renderer.rb +0 -6
- data/example/rails/simplepay/config/initializers/assets.rb +0 -11
- data/example/rails/simplepay/config/initializers/backtrace_silencers.rb +0 -7
- data/example/rails/simplepay/config/initializers/cookies_serializer.rb +0 -5
- data/example/rails/simplepay/config/initializers/filter_parameter_logging.rb +0 -4
- data/example/rails/simplepay/config/initializers/inflections.rb +0 -16
- data/example/rails/simplepay/config/initializers/mime_types.rb +0 -4
- data/example/rails/simplepay/config/initializers/new_framework_defaults.rb +0 -24
- data/example/rails/simplepay/config/initializers/session_store.rb +0 -3
- data/example/rails/simplepay/config/initializers/veritrans.rb +0 -46
- data/example/rails/simplepay/config/initializers/wrap_parameters.rb +0 -14
- data/example/rails/simplepay/config/locales/en.yml +0 -23
- data/example/rails/simplepay/config/puma.rb +0 -47
- data/example/rails/simplepay/config/routes.rb +0 -5
- data/example/rails/simplepay/config/secrets.yml +0 -22
- data/example/rails/simplepay/config/spring.rb +0 -6
- data/example/rails/simplepay/config/veritrans.yml +0 -18
- data/example/rails/simplepay/config.ru +0 -5
- data/example/rails/simplepay/db/development.sqlite3 +0 -0
- data/example/rails/simplepay/db/migrate/20161221090855_create_orders.rb +0 -10
- data/example/rails/simplepay/db/schema.rb +0 -22
- data/example/rails/simplepay/db/seeds.rb +0 -7
- 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/log/.keep +0 -0
- data/example/rails/simplepay/public/404.html +0 -67
- data/example/rails/simplepay/public/422.html +0 -67
- data/example/rails/simplepay/public/500.html +0 -66
- 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 +0 -5
- data/example/rails/simplepay/vendor/assets/javascripts/.keep +0 -0
- data/example/rails/simplepay/vendor/assets/stylesheets/.keep +0 -0
- data/example/sinatra/config.ru +0 -9
- data/example/sinatra/localization.erb +0 -249
- data/example/sinatra/points.erb +0 -188
- data/example/sinatra/recurring.erb +0 -201
- data/example/sinatra/sinatra.rb +0 -194
- data/example/sinatra/style.css +0 -137
- data/example/sinatra/veritrans.yml +0 -11
- data/example/sinatra/widget.erb +0 -63
- data/lib/generators/templates/assets/credit_card_form.js +0 -57
- data/lib/generators/templates/payments_controller.rb +0 -85
- data/lib/generators/templates/veritrans.rb +0 -46
- data/lib/generators/templates/veritrans.yml +0 -18
- data/lib/generators/templates/views/_credit_card_form.erb +0 -42
- data/lib/generators/templates/views/_veritrans_include.erb +0 -10
- data/lib/generators/templates/views/payments/create.erb +0 -15
- data/lib/generators/templates/views/payments/new.erb +0 -6
- data/lib/generators/veritrans/install_generator.rb +0 -32
- data/lib/generators/veritrans/payment_form_generator.rb +0 -45
- data/lib/veritrans/cli.rb +0 -161
- data/lib/veritrans/testing.rb +0 -156
- data/spec/cli_spec.rb +0 -83
- data/spec/configs/real_key.yml +0 -4
- data/spec/configs/veritrans.yml +0 -7
- data/spec/configs/veritrans_flat.yml +0 -2
- data/spec/configs/veritrans_with_erb.yml +0 -2
- data/spec/fixtures/approve_failed.yml +0 -48
- data/spec/fixtures/cancel_failed.yml +0 -48
- data/spec/fixtures/cancel_success.yml +0 -126
- data/spec/fixtures/capture_failed.yml +0 -48
- data/spec/fixtures/charge.yml +0 -50
- data/spec/fixtures/charge_direct.yml +0 -56
- data/spec/fixtures/charge_vtweb.yml +0 -50
- data/spec/fixtures/cli_test_1111-not-exists.yml +0 -45
- data/spec/fixtures/cli_test_not_exists.yml +0 -45
- data/spec/fixtures/cli_test_real_txn.yml +0 -55
- data/spec/fixtures/cli_test_unauthorized.yml +0 -47
- data/spec/fixtures/deny_failed.yml +0 -144
- data/spec/fixtures/events_test_real_txn.yml +0 -55
- data/spec/fixtures/expire_failed.yml +0 -50
- data/spec/fixtures/expire_success.yml +0 -56
- data/spec/fixtures/midtrans_status.yml +0 -117
- data/spec/fixtures/refund_failed.yml +0 -54
- data/spec/fixtures/status_fail.yml +0 -48
- data/spec/fixtures/status_success.yml +0 -128
- data/spec/fixtures/test_token.yml +0 -49
- data/spec/midtrans_rename_spec.rb +0 -27
- data/spec/rails_plugin_spec.rb +0 -317
- data/spec/spec_helper.rb +0 -71
- data/spec/veritrans_client_spec.rb +0 -235
- data/spec/veritrans_config_spec.rb +0 -70
- data/spec/veritrans_events_spec.rb +0 -72
- data/spec/veritrans_logger_spec.rb +0 -46
- data/spec/veritrans_snap_spec.rb +0 -54
- data/spec/veritrans_testing_spec.rb +0 -184
- data/testing_webhooks.md +0 -78
data/example/sinatra/style.css
DELETED
@@ -1,137 +0,0 @@
|
|
1
|
-
body {
|
2
|
-
max-width: 900px;
|
3
|
-
margin: 0 auto;
|
4
|
-
font-size: 16px;
|
5
|
-
background: white;
|
6
|
-
}
|
7
|
-
a {
|
8
|
-
color: #00E;
|
9
|
-
}
|
10
|
-
a:hover, a:focus {
|
11
|
-
color: #00E;
|
12
|
-
}
|
13
|
-
|
14
|
-
header {
|
15
|
-
background: #F5FAFC;
|
16
|
-
padding: 3px 5px;
|
17
|
-
border-bottom: 1px solid #ccc;
|
18
|
-
overflow: hidden;
|
19
|
-
}
|
20
|
-
|
21
|
-
header .github {
|
22
|
-
float: right;
|
23
|
-
margin: 18px 0;
|
24
|
-
}
|
25
|
-
|
26
|
-
header h3 {
|
27
|
-
float: left;
|
28
|
-
margin: 18px 0;
|
29
|
-
}
|
30
|
-
|
31
|
-
section {
|
32
|
-
padding: 1em 0;
|
33
|
-
}
|
34
|
-
|
35
|
-
section + section {
|
36
|
-
border-top: 1px solid #ccc;
|
37
|
-
}
|
38
|
-
|
39
|
-
label {
|
40
|
-
display: inline-block;
|
41
|
-
min-width: 100px;
|
42
|
-
vertical-align: top;
|
43
|
-
}
|
44
|
-
.card-numbers {
|
45
|
-
margin-left: 100px;
|
46
|
-
}
|
47
|
-
.card-numbers a {
|
48
|
-
text-decoration: none;
|
49
|
-
border-bottom: 1px dotted #88f;
|
50
|
-
margin-right: 10px;
|
51
|
-
cursor: pointer;
|
52
|
-
}
|
53
|
-
.card-numbers a[href] {
|
54
|
-
text-decoration: underline;
|
55
|
-
border: none;
|
56
|
-
}
|
57
|
-
|
58
|
-
fieldset {
|
59
|
-
margin: 25px 0 12px;
|
60
|
-
}
|
61
|
-
|
62
|
-
.white-popup {
|
63
|
-
position: relative;
|
64
|
-
background: #FFF;
|
65
|
-
padding: 20px;
|
66
|
-
width: auto;
|
67
|
-
max-width: 600px;
|
68
|
-
margin: 20px auto;
|
69
|
-
}
|
70
|
-
|
71
|
-
.white-popup pre code {
|
72
|
-
white-space: pre-wrap;
|
73
|
-
}
|
74
|
-
|
75
|
-
#vtweb_form label {
|
76
|
-
min-width: 180px;
|
77
|
-
}
|
78
|
-
|
79
|
-
#vtweb_form ul {
|
80
|
-
display: inline-block;
|
81
|
-
vertical-align: top;
|
82
|
-
margin-top: 0;
|
83
|
-
padding-left: 0px;
|
84
|
-
}
|
85
|
-
|
86
|
-
#vtweb_form ul li {
|
87
|
-
list-style-type: none;
|
88
|
-
margin-bottom: 1px;
|
89
|
-
font-size: 15px;
|
90
|
-
}
|
91
|
-
|
92
|
-
#vtweb_form small {
|
93
|
-
margin-left: 184px;
|
94
|
-
}
|
95
|
-
|
96
|
-
.recurring-page .cards {
|
97
|
-
border: 1px dashed #acf;
|
98
|
-
padding: 10px;
|
99
|
-
}
|
100
|
-
|
101
|
-
.recurring-page .cards ul {
|
102
|
-
padding-left: 0;
|
103
|
-
margin-bottom: 3px;
|
104
|
-
}
|
105
|
-
|
106
|
-
.recurring-page .cards ul li {
|
107
|
-
list-style-type: none;
|
108
|
-
display: block;
|
109
|
-
background: #f5f5f5;
|
110
|
-
padding: 7px 9px;
|
111
|
-
box-shadow: inset 0px 0px 2px rgba(0, 0, 64, 0.25);
|
112
|
-
}
|
113
|
-
|
114
|
-
.recurring-page .cards ul li + li {
|
115
|
-
margin-top: 10px;
|
116
|
-
}
|
117
|
-
|
118
|
-
.recurring-page .cards ul li code {
|
119
|
-
margin: 0 18px 0 4px;
|
120
|
-
}
|
121
|
-
.recurring-page .cards ul li i {
|
122
|
-
margin: 0 35px 0 4px;
|
123
|
-
font-style: normal;
|
124
|
-
}
|
125
|
-
|
126
|
-
.recurring-page .cards ul li a {
|
127
|
-
margin-right: 10px;
|
128
|
-
}
|
129
|
-
|
130
|
-
.recurring-page .cards ul li small {
|
131
|
-
display: block;
|
132
|
-
margin-top: 7px;
|
133
|
-
color: #666;
|
134
|
-
font-family: monospace;
|
135
|
-
font-size: 10px;
|
136
|
-
}
|
137
|
-
|
@@ -1,11 +0,0 @@
|
|
1
|
-
development:
|
2
|
-
# merchant_id: M000937
|
3
|
-
|
4
|
-
client_key: VT-client-NArmatJZqzsmTmzR
|
5
|
-
server_key: VT-server-9Htb-RxXkg7-7hznSCCjxvoY
|
6
|
-
|
7
|
-
# For production use
|
8
|
-
# api_host: https://api.midtrans.com
|
9
|
-
|
10
|
-
# For sandbox use
|
11
|
-
# api_host: https://api.sandbox.midtrans.com
|
data/example/sinatra/widget.erb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>veritrans-ruby demo</title>
|
5
|
-
<link rel="icon" type="image/x-icon" href="https://account.midtrans.com/favicon.ico" />
|
6
|
-
<link rel="stylesheet" href="/style.css">
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
|
10
|
-
<header>
|
11
|
-
<h3>
|
12
|
-
<a href="/">Midtrans sinatra app</a>
|
13
|
-
</h3>
|
14
|
-
<a href="https://github.com/veritrans/veritrans-ruby" class="github">Source Code</a>
|
15
|
-
</header>
|
16
|
-
|
17
|
-
<section>
|
18
|
-
<h4>Midtrans SNAP example</h4>
|
19
|
-
|
20
|
-
<section>
|
21
|
-
<p>
|
22
|
-
<label>Snap Token</label>
|
23
|
-
<input type="text" id="token" value="<%= @token %>" readonly size="50">
|
24
|
-
</p>
|
25
|
-
<button id="snap_pay">Pay Now</button>
|
26
|
-
</section>
|
27
|
-
|
28
|
-
<p>
|
29
|
-
To complete payment in sandbox mode, plese use <a href="https://docs.midtrans.com/en/api/test_credentials.html" target="_blank">testing credentials</a>.<br/>
|
30
|
-
For more details see <a href="https://snap-docs.midtrans.com/">SNAP Documentation</a>
|
31
|
-
<p>
|
32
|
-
|
33
|
-
<code>
|
34
|
-
<pre class="callback-result"></pre>
|
35
|
-
</code>
|
36
|
-
</section>
|
37
|
-
|
38
|
-
<script src="https://app.sandbox.midtrans.com/snap/snap.js"></script>
|
39
|
-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
40
|
-
|
41
|
-
<script type="text/javascript">
|
42
|
-
$('#snap_pay').on('click', function (e) {
|
43
|
-
e.preventDefault();
|
44
|
-
snap.pay($('#token').val() + "?locale=en", {
|
45
|
-
onSuccess: function (res) {
|
46
|
-
console.log('onSuccess', res);
|
47
|
-
$('.callback-result').text("SNAP Callback parameters:\n" + JSON.stringify(res, null, 4));
|
48
|
-
if (confirm(res.status_message + "\nRedirect to confirm page?")) {
|
49
|
-
window.location = "/widget/confirm/" + res.transaction_id;
|
50
|
-
}
|
51
|
-
},
|
52
|
-
onPending: function (res) {
|
53
|
-
console.log('onPending', res);
|
54
|
-
},
|
55
|
-
onError: function (res) {
|
56
|
-
console.log('onError', res);
|
57
|
-
}
|
58
|
-
});
|
59
|
-
});
|
60
|
-
</script>
|
61
|
-
|
62
|
-
</body>
|
63
|
-
</html>
|
@@ -1,57 +0,0 @@
|
|
1
|
-
// Veritrans is defined in https://api.midtrans.com/v2/assets/js/midtrans.min.js
|
2
|
-
// and it has no JS dependecies, but this example uses jquery for simplicity
|
3
|
-
|
4
|
-
//= require jquery
|
5
|
-
|
6
|
-
$(document).ready(function () {
|
7
|
-
|
8
|
-
function VT_createTokenData() {
|
9
|
-
return {
|
10
|
-
// Optional params:
|
11
|
-
// secure: true
|
12
|
-
// bank: 'MANDIRI'
|
13
|
-
// gross_amount: 1000
|
14
|
-
|
15
|
-
card_number: $('#credit_card_number').val(),
|
16
|
-
card_cvv: $('#credit_card_cvv').val(),
|
17
|
-
card_exp_month: $('#credit_card_expire').val().match(/(\d+) \//)[1],
|
18
|
-
card_exp_year: '20' + $('#credit_card_expire').val().match(/\/ (\d+)/)[1],
|
19
|
-
gross_amount: $('#payment_amount').val(),
|
20
|
-
secure: $('#payment_credit_card_secure')[0].checked
|
21
|
-
};
|
22
|
-
}
|
23
|
-
|
24
|
-
$('.veritrans-payment-form').on('submit', function (event) {
|
25
|
-
event.preventDefault();
|
26
|
-
|
27
|
-
var form = this;
|
28
|
-
var button = $(form).find('input[type=submit]:last');
|
29
|
-
var buttonValBefore = button.val();
|
30
|
-
button.val("Processing ...");
|
31
|
-
button.attr('disabled', true); // prevent double submit
|
32
|
-
|
33
|
-
Veritrans.token(VT_createTokenData, function (data) {
|
34
|
-
//console.log('Get token response:');
|
35
|
-
//console.log(JSON.stringify(VT_createTokenData()));
|
36
|
-
//console.log(JSON.stringify(data));
|
37
|
-
|
38
|
-
// if we get redirect_url then it's 3d-secure transaction
|
39
|
-
// so we need to open that page
|
40
|
-
// this callback function will be called again after user confirm 3d-secure
|
41
|
-
// you can also redirect on server side
|
42
|
-
|
43
|
-
if (data.redirect_url) {
|
44
|
-
// it works nice with lightbox js libraries
|
45
|
-
$('#3d-secure-iframe').attr('src', data.redirect_url).show();
|
46
|
-
// if no redirect_url and we have token_id then just make charge request
|
47
|
-
} else if (data.token_id) {
|
48
|
-
$('#payment_token_id').val(data.token_id);
|
49
|
-
form.submit();
|
50
|
-
// if no redirect_url and no token_id, then it should be error
|
51
|
-
} else {
|
52
|
-
alert(data.validation_messages ? data.validation_messages.join("\n") : data.status_message);
|
53
|
-
button.removeAttr('disabled').val(buttonValBefore);
|
54
|
-
}
|
55
|
-
});
|
56
|
-
});
|
57
|
-
});
|
@@ -1,85 +0,0 @@
|
|
1
|
-
class PaymentsController < ApplicationController # :nodoc:
|
2
|
-
skip_before_action :verify_authenticity_token, only: [:receive_webhook]
|
3
|
-
|
4
|
-
def new
|
5
|
-
@payment = make_payment
|
6
|
-
end
|
7
|
-
|
8
|
-
# Creating example payment
|
9
|
-
def create
|
10
|
-
@payment = make_payment
|
11
|
-
|
12
|
-
if params[:type] == "vtweb"
|
13
|
-
@result = Veritrans.charge(
|
14
|
-
payment_type: "VTWEB",
|
15
|
-
transaction_details: {
|
16
|
-
order_id: @payment.order_id,
|
17
|
-
gross_amount: @payment.amount
|
18
|
-
}
|
19
|
-
)
|
20
|
-
redirect_to @result.redirect_url
|
21
|
-
return
|
22
|
-
end
|
23
|
-
|
24
|
-
@result = Veritrans.charge(
|
25
|
-
payment_type: "credit_card",
|
26
|
-
credit_card: { token_id: params[:payment][:token_id] },
|
27
|
-
transaction_details: {
|
28
|
-
order_id: @payment.order_id,
|
29
|
-
gross_amount: params[:payment][:amount].presence || @payment.amount
|
30
|
-
}
|
31
|
-
)
|
32
|
-
end
|
33
|
-
|
34
|
-
# Processing HTTP Notification from Veritrans
|
35
|
-
# POST request with JSON-encoded body
|
36
|
-
# If you using Veritrans::Events then you don't need this
|
37
|
-
def receive_webhook
|
38
|
-
post_body = request.body.read
|
39
|
-
|
40
|
-
Veritrans.file_logger.info("Callback for order: " +
|
41
|
-
"#{params[:order_id]} #{params[:transaction_status]}\n" +
|
42
|
-
post_body + "\n"
|
43
|
-
)
|
44
|
-
|
45
|
-
verified_data = Veritrans.status(params["transaction_id"])
|
46
|
-
|
47
|
-
if verified_data.status_code != 404
|
48
|
-
puts "--- Transaction callback ---"
|
49
|
-
puts "Payment: #{verified_data.data[:order_id]}"
|
50
|
-
puts "Payment type: #{verified_data.data[:payment_type]}"
|
51
|
-
puts "Payment status: #{verified_data.data[:transaction_status]}"
|
52
|
-
puts "Fraud status: #{verified_data.data[:fraud_status]}" if verified_data.data[:fraud_status]
|
53
|
-
puts "Payment amount: #{verified_data.data[:gross_amount]}"
|
54
|
-
puts "--- Transaction callback ---"
|
55
|
-
|
56
|
-
render plain: "ok"
|
57
|
-
else
|
58
|
-
Veritrans.file_logger.info("Callback verification failed for order: " +
|
59
|
-
"#{params[:order_id]} #{params[:transaction_status]}}\n" +
|
60
|
-
verified_data.body + "\n"
|
61
|
-
)
|
62
|
-
|
63
|
-
render plain: "error", :status => :not_found
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
# You should replace this with your own model
|
69
|
-
private
|
70
|
-
def make_payment
|
71
|
-
@paymentKlass = Struct.new("Payment", :amount, :token_id, :order_id, :credit_card_secure) do
|
72
|
-
extend ActiveModel::Naming
|
73
|
-
include ActiveModel::Conversion
|
74
|
-
|
75
|
-
def persisted?; false; end
|
76
|
-
|
77
|
-
def self.name
|
78
|
-
"Payment"
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
@paymentKlass.new(100_000, '', "testing-#{rand.round(4)}-#{Time.now.to_i}", false)
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
Veritrans.setup do
|
2
|
-
config.load_config Rails.root.join("config/veritrans.yml"), Rails.env
|
3
|
-
|
4
|
-
# Or set it manually...
|
5
|
-
# config.server_key = ""
|
6
|
-
# config.client_key = ""
|
7
|
-
# config.api_host = ""
|
8
|
-
|
9
|
-
# Veritrans::Events is rack application to handle http notifications from Veritrans
|
10
|
-
# To enable it, add in config/routes.rb
|
11
|
-
#
|
12
|
-
# mount Veritrans::Events.new => '/vt_events'
|
13
|
-
#
|
14
|
-
# All possible events:
|
15
|
-
#
|
16
|
-
# 'payment.success' == ['authorize', 'capture', 'settlement']
|
17
|
-
# 'payment.failed' == ['deny', 'cancel', 'expire']
|
18
|
-
# 'payment.challenge' # when payment.fraud_status == 'challenge'
|
19
|
-
#
|
20
|
-
# 'payment.authorize'
|
21
|
-
# 'payment.capture'
|
22
|
-
# 'payment.settlement'
|
23
|
-
# 'payment.deny'
|
24
|
-
# 'payment.cancel'
|
25
|
-
# 'payment.expire'
|
26
|
-
|
27
|
-
# events.subscribe 'payment.success' do |payment|
|
28
|
-
# payment is instance of Veritrans::Result
|
29
|
-
# puts "Payment #{payment.data[:order_id]} is successful"
|
30
|
-
# end
|
31
|
-
#
|
32
|
-
# events.subscribe 'payment.failed' do |payment|
|
33
|
-
# puts "Payment #{payment.data[:order_id]} is failed"
|
34
|
-
# end
|
35
|
-
#
|
36
|
-
# events.subscribe 'payment.challenge' do |payment|
|
37
|
-
# puts "Payment #{payment.data[:order_id]} chellenged by fraud system"
|
38
|
-
# payment.mark_challenge!
|
39
|
-
# end
|
40
|
-
#
|
41
|
-
# events.subscribe /.+/ do |payment, event_name|
|
42
|
-
# puts "Payment #{payment.data[:order_id]} has status #{payment.data[:transaction_status]}"
|
43
|
-
# p payment
|
44
|
-
# end
|
45
|
-
|
46
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
development:
|
2
|
-
# Register in sandbox veritrans and get your keys here:
|
3
|
-
# https://dashboard.sandbox.midtrans.com/settings/config_info
|
4
|
-
client_key: ""
|
5
|
-
server_key: ""
|
6
|
-
api_host: https://api.sandbox.midtrans.com
|
7
|
-
|
8
|
-
production:
|
9
|
-
# Register and get your keys here:
|
10
|
-
# https://dashboard.midtrans.com/settings/config_info
|
11
|
-
client_key: <%= ENV['VERITRANS_CLIENT_KEY'] %>
|
12
|
-
server_key: <%= ENV['VERITRANS_SERVER_KEY'] %>
|
13
|
-
api_host: https://api.midtrans.com
|
14
|
-
|
15
|
-
staging:
|
16
|
-
client_key: <%= ENV['VT_SANDBOX_CLIENT_KEY'] %>
|
17
|
-
server_key: <%= ENV['VT_SANDBOX_SERVER_KEY'] %>
|
18
|
-
api_host: https://api.sandbox.midtrans.com
|
@@ -1,42 +0,0 @@
|
|
1
|
-
<%= form_for @payment, html: {class: "veritrans-payment-form"} do |f| %>
|
2
|
-
<%= f.hidden_field :token_id %>
|
3
|
-
<input type="submit" style="display: none">
|
4
|
-
<p>
|
5
|
-
<%= f.label :amount %>
|
6
|
-
<%= f.number_field :amount %>
|
7
|
-
</p>
|
8
|
-
|
9
|
-
<p>
|
10
|
-
<%= label_tag :credit_card_number %>
|
11
|
-
<%= text_field_tag :credit_card_number, '4811 1111 1111 1114', name: nil, size: 25 %>
|
12
|
-
</p>
|
13
|
-
<p>
|
14
|
-
<button onclick="$('#credit_card_number').val('5810 1111 1111 1112'); return false">success MasterCard</button>
|
15
|
-
<button onclick="$('#credit_card_number').val('4811 1111 1111 1114'); return false">success Visa</button>
|
16
|
-
<button onclick="$('#credit_card_number').val('4511 1111 1111 1117'); return false">challenge</button>
|
17
|
-
<button onclick="$('#credit_card_number').val('4611 1111 1111 1116'); return false">Deny by FDS</button>
|
18
|
-
<button onclick="$('#credit_card_number').val('4911 1111 1111 1113'); return false">Deny by bank</button>
|
19
|
-
<a href="https://docs.midtrans.com/en/reference/test.html" target="_blank">documentation</a>
|
20
|
-
</p>
|
21
|
-
|
22
|
-
<p>
|
23
|
-
<%= label_tag :credit_card_cvv %>
|
24
|
-
<%= text_field_tag :credit_card_cvv, '123', name: nil %>
|
25
|
-
</p>
|
26
|
-
|
27
|
-
<p>
|
28
|
-
<%= label_tag :credit_card_expire %>
|
29
|
-
<%= text_field_tag :credit_card_expire, '12 / 20', placeholder: "MM / YY", name: nil %>
|
30
|
-
</p>
|
31
|
-
|
32
|
-
<p>
|
33
|
-
<%= f.label :credit_card_secure, "3D-secure" %>
|
34
|
-
<%= f.check_box :credit_card_secure %>
|
35
|
-
</p>
|
36
|
-
|
37
|
-
<p>
|
38
|
-
<%= f.submit "Pay via VT-Direct" %>
|
39
|
-
</p>
|
40
|
-
<% end %>
|
41
|
-
|
42
|
-
<iframe id="3d-secure-iframe" style="display: none; width: 500px; height: 600px"></iframe>
|
@@ -1,10 +0,0 @@
|
|
1
|
-
<%= javascript_include_tag "#{Veritrans.config.api_host}/v2/assets/js/midtrans.min.js" %>
|
2
|
-
|
3
|
-
<script type="text/javascript">
|
4
|
-
Veritrans.url = "<%= Veritrans.config.api_host %>/v2/token";
|
5
|
-
Veritrans.client_key = "<%= Veritrans.config.client_key %>";
|
6
|
-
</script>
|
7
|
-
|
8
|
-
<% unless Veritrans.config.client_key.present? %>
|
9
|
-
<h4 style="color: red">Please add client_key in config/veritrans.yml</h4>
|
10
|
-
<% end %>
|
@@ -1,15 +0,0 @@
|
|
1
|
-
<strong>
|
2
|
-
<% if @result.success? %><span style="color: green"><% end %>
|
3
|
-
<%= @result.status_message %>
|
4
|
-
</span>
|
5
|
-
</strong>
|
6
|
-
|
7
|
-
<br>
|
8
|
-
|
9
|
-
<code>
|
10
|
-
<pre>
|
11
|
-
<%= @result.response.body %>
|
12
|
-
</pre>
|
13
|
-
</code>
|
14
|
-
|
15
|
-
<%= link_to "Go back", :new_payment %>
|
@@ -1,32 +0,0 @@
|
|
1
|
-
class Veritrans
|
2
|
-
class InstallGenerator < ::Rails::Generators::Base # :nodoc:
|
3
|
-
source_root File.expand_path("../../templates", __FILE__)
|
4
|
-
|
5
|
-
desc %{
|
6
|
-
Description:
|
7
|
-
Copies Veritrans configuration file to your application's initializer directory.
|
8
|
-
}
|
9
|
-
|
10
|
-
desc "copy veritrans.yml"
|
11
|
-
def copy_config_file
|
12
|
-
copy_file "veritrans.yml", "config/veritrans.yml"
|
13
|
-
end
|
14
|
-
|
15
|
-
desc "copy initializer veritrans.rb"
|
16
|
-
def copy_initializer_file
|
17
|
-
copy_file "./veritrans.rb", "config/initializers/veritrans.rb"
|
18
|
-
|
19
|
-
say_status "", %{
|
20
|
-
|
21
|
-
We copy configs in your rails application
|
22
|
-
Please edit:
|
23
|
-
|
24
|
-
config/veritrans.yml
|
25
|
-
|
26
|
-
}
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
class Veritrans
|
2
|
-
class PaymentFormGenerator < ::Rails::Generators::Base # :nodoc:
|
3
|
-
source_root File.expand_path("../../templates", __FILE__)
|
4
|
-
|
5
|
-
desc %{
|
6
|
-
Description:
|
7
|
-
Copies Veritrans payment form example to your rails application.
|
8
|
-
}
|
9
|
-
|
10
|
-
def copy_shared_views
|
11
|
-
copy_file "views/_veritrans_include.erb", "app/views/shared/_veritrans_include.erb"
|
12
|
-
copy_file "views/_credit_card_form.erb", "app/views/shared/_credit_card_form.erb"
|
13
|
-
end
|
14
|
-
|
15
|
-
def copy_controller
|
16
|
-
copy_file "payments_controller.rb", "app/controllers/payments_controller.rb"
|
17
|
-
|
18
|
-
route "resources :payments do\n" +
|
19
|
-
" collection do\n" +
|
20
|
-
" post :receive_webhook\n" +
|
21
|
-
" end\n" +
|
22
|
-
" end"
|
23
|
-
|
24
|
-
copy_file "views/payments/new.erb", "app/views/payments/new.erb"
|
25
|
-
copy_file "views/payments/create.erb", "app/views/payments/create.erb"
|
26
|
-
end
|
27
|
-
|
28
|
-
def append_javascript_file
|
29
|
-
copy_file "assets/credit_card_form.js", "app/assets/javascripts/credit_card_form.js"
|
30
|
-
insert_into_file "app/assets/javascripts/application.js", :after => %r{//= require +['"]?jquery['"]?$} do
|
31
|
-
"\n//= require credit_card_form"
|
32
|
-
end
|
33
|
-
|
34
|
-
say_status "", %{
|
35
|
-
|
36
|
-
Sample form installed in you app!
|
37
|
-
It contains example for VT-Web and VT-Direct
|
38
|
-
|
39
|
-
Now open http://localhost:3000/payments/new
|
40
|
-
|
41
|
-
}
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|