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/api_reference.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# API Reference
|
2
2
|
|
3
|
-
|
4
|
-
please use our [documentation](https://api-docs.midtrans.com/)
|
3
|
+
This is only partial reference of the APIs that are implemented in this Ruby Gem. For more details refer to [documentation](https://api-docs.midtrans.com/)
|
5
4
|
|
6
5
|
|
7
6
|
<table>
|
@@ -16,136 +15,170 @@ please use our [documentation](https://api-docs.midtrans.com/)
|
|
16
15
|
|
17
16
|
<tbody>
|
18
17
|
<tr>
|
19
|
-
<td><a href="#charge">
|
20
|
-
<td>Charge Transaction</td>
|
18
|
+
<td><a href="#charge">Midtrans.charge(data)</a></td>
|
19
|
+
<td>Charge Transaction (Core API)</td>
|
21
20
|
<td>POST</td>
|
22
21
|
<td>api.midtrans.com/v2/charge</td>
|
23
22
|
</tr>
|
24
23
|
<tr>
|
25
|
-
<td><a href="#token">
|
24
|
+
<td><a href="#token">Midtrans.create_card_token(data)</a></td>
|
26
25
|
<td>Get Token for Card</td>
|
27
26
|
<td>GET</td>
|
28
27
|
<td>api.midtrans.com/v2/token</td>
|
29
28
|
</tr>
|
30
29
|
<tr>
|
31
|
-
<td><a href="#status">
|
30
|
+
<td><a href="#status">Midtrans.status(id)</a></td>
|
32
31
|
<td>Get Last Status</td>
|
33
32
|
<td>GET</td>
|
34
33
|
<td>api.midtrans.com/v2/{id}/status</td>
|
35
34
|
</tr>
|
36
35
|
<tr>
|
37
|
-
<td><a href="#cancel">
|
36
|
+
<td><a href="#cancel">Midtrans.cancel(id)</a></td>
|
38
37
|
<td>Cancel Transaction</td>
|
39
38
|
<td>POST</td>
|
40
39
|
<td>api.midtrans.com/v2/{id}/cancel</td>
|
41
40
|
</tr>
|
42
41
|
<tr>
|
43
|
-
<td><a href="#approve">
|
42
|
+
<td><a href="#approve">Midtrans.approve(id)</a></td>
|
44
43
|
<td>Approve Challenge Transaction</td>
|
45
44
|
<td>POST</td>
|
46
45
|
<td>api.midtrans.com/v2/{id}/approve</td>
|
47
46
|
</tr>
|
48
47
|
<tr>
|
49
|
-
<td><a href="#refund">
|
48
|
+
<td><a href="#refund">Midtrans.refund(id)</a></td>
|
50
49
|
<td>Refund Successful Transaction</td>
|
51
50
|
<td>POST</td>
|
52
51
|
<td>api.midtrans.com/v2/{id}/refund</td>
|
53
52
|
</tr>
|
54
53
|
<tr>
|
55
|
-
<td><a href="#capture">
|
54
|
+
<td><a href="#capture">Midtrans.capture(id)</a></td>
|
56
55
|
<td>Capture Authorise Transaction</td>
|
57
56
|
<td>POST</td>
|
58
57
|
<td>api.midtrans.com/v2/{id}/capture</td>
|
59
58
|
</tr>
|
60
59
|
<tr>
|
61
|
-
<td><a href="#expire">
|
60
|
+
<td><a href="#expire">Midtrans.expire(id)</a></td>
|
62
61
|
<td>Expire Pending Transaction</td>
|
63
62
|
<td>POST</td>
|
64
63
|
<td>api.midtrans.com/v2/{id}/expire</td>
|
65
64
|
</tr>
|
66
65
|
<tr>
|
67
|
-
<td><a href="#deny">
|
66
|
+
<td><a href="#deny">Midtrans.deny(id)</a></td>
|
68
67
|
<td>Deny Challenged Transaction</td>
|
69
68
|
<td>POST</td>
|
70
69
|
<td>api.midtrans.com/v2/{id}/deny</td>
|
70
|
+
</tr>
|
71
|
+
<tr>
|
72
|
+
<td><a href="#snap">Midtrans.create_snap_token(data)</a></td>
|
73
|
+
<td>Charge Transaction (SNAP)</td>
|
74
|
+
<td>POST</td>
|
75
|
+
<td>app.midtrans.com/snap/v1/transactions</td>
|
76
|
+
</tr>
|
77
|
+
<tr>
|
78
|
+
<td><a href="#link">Midtrans.link_payment_account(data)</a></td>
|
79
|
+
<td>Link the customer's payment provider account to be used for payments using specific payment channel.</td>
|
80
|
+
<td>POST</td>
|
81
|
+
<td>api.midtrans.com/v2/pay/account</td>
|
82
|
+
</tr>
|
83
|
+
<tr>
|
84
|
+
<td><a href="#get_payment_account">Midtrans.get_payment_account(id)</a></td>
|
85
|
+
<td>Get account to use for specific payment channel.</td>
|
86
|
+
<td>GET</td>
|
87
|
+
<td>api.midtrans.com/v2/pay/account/{account_id}</td>
|
88
|
+
</tr>
|
89
|
+
<tr>
|
90
|
+
<td><a href="#unlink_payment_account">Midtrans.unlink_payment_account(id)</a></td>
|
91
|
+
<td>Unlink the linked customer account.</td>
|
92
|
+
<td>POST</td>
|
93
|
+
<td>api.midtrans.com/v2/pay/account/{account_id}/unbind</td>
|
94
|
+
</tr>
|
95
|
+
<tr>
|
96
|
+
<td><a href="#create_subscription">Midtrans.create_subscription(data)</a></td>
|
97
|
+
<td>Create a subscription transaction</td>
|
98
|
+
<td>POST</td>
|
99
|
+
<td>api.midtrans.com/v1/subscriptions</td>
|
100
|
+
</tr>
|
101
|
+
<tr>
|
102
|
+
<td><a href="#get_subscription">Midtrans.get_subscription(id)</a></td>
|
103
|
+
<td>Retrieve the subscription details of a customer</td>
|
104
|
+
<td>GET</td>
|
105
|
+
<td>api.midtrans.com/v1/subscriptions/{subscription_id}</td>
|
106
|
+
</tr>
|
107
|
+
<tr>
|
108
|
+
<td><a href="#disable_subscription">Midtrans.disable_subscription(id)</a></td>
|
109
|
+
<td>Disable a customer's subscription account</td>
|
110
|
+
<td>POST</td>
|
111
|
+
<td>api.midtrans.com/v1/subscriptions/{subscription_id}/disable</td>
|
112
|
+
</tr>
|
113
|
+
<tr>
|
114
|
+
<td><a href="#enable_subscription">Midtrans.enable_subscription(id)</a></td>
|
115
|
+
<td>Enable a customer's subscription account</td>
|
116
|
+
<td>POST</td>
|
117
|
+
<td>api.midtrans.com/v1/subscriptions/{subscription_id}/enable</td>
|
118
|
+
</tr>
|
119
|
+
<tr>
|
120
|
+
<td><a href="#update_subscription">Midtrans.update_subscription(data)</a></td>
|
121
|
+
<td>Update the details of a customer's existing subscription account</td>
|
122
|
+
<td>PATCH</td>
|
123
|
+
<td>api.midtrans.com/v1/subscriptions/{subscription_id}</td>
|
71
124
|
</tr>
|
72
125
|
</tbody>
|
73
126
|
</table>
|
74
127
|
|
75
128
|
|
76
|
-
|
77
|
-
|
78
|
-
### Charge
|
79
|
-
|
80
|
-
Actually make transaction. But for vt-web create a redirect url, and for vt-link creates payment page
|
129
|
+
## Usage Example
|
81
130
|
|
82
|
-
|
83
|
-
|
84
|
-
```ruby
|
85
|
-
q = Veritrans.charge({
|
86
|
-
payment_type: "VTWEB",
|
87
|
-
transaction_details: {
|
88
|
-
order_id: "order-1",
|
89
|
-
gross_amount: 100_000
|
90
|
-
}
|
91
|
-
})
|
92
|
-
|
93
|
-
q.class # => Veritrans::Result
|
94
|
-
q.data == {
|
95
|
-
status_code: "201",
|
96
|
-
status_message: "OK, success do VTWeb transaction, please go to redirect_url",
|
97
|
-
redirect_url: "https://vtweb.sandbox.midtrans.com/v2/vtweb/b27d421f-90ff-4427-83d2-fbe8acbbce89"
|
98
|
-
}
|
99
|
-
```
|
131
|
+
### Create Transaction
|
100
132
|
|
101
|
-
|
133
|
+
<a name="charge"></a>
|
134
|
+
#### Core API
|
102
135
|
|
136
|
+
Perform a transaction with various available payment methods and features. Example below: credit card charge.
|
103
137
|
```ruby
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
});
|
143
|
-
|
144
|
-
|
145
|
-
q.data == {
|
138
|
+
response = Midtrans.charge({
|
139
|
+
# *required
|
140
|
+
payment_type: "credit_card",
|
141
|
+
# *required
|
142
|
+
transaction_details: {
|
143
|
+
order_id: "order-2",
|
144
|
+
gross_amount: 100_000
|
145
|
+
},
|
146
|
+
# *required (but different for different payment type)
|
147
|
+
credit_card: {
|
148
|
+
token_id: "dcd6cd71-bc4c-4f4b-8752-49cb0a3f204c",
|
149
|
+
bank: "cimb"
|
150
|
+
},
|
151
|
+
# optional
|
152
|
+
item_details: [
|
153
|
+
{
|
154
|
+
id: "ITEM1",
|
155
|
+
price: 100_000,
|
156
|
+
quantity: 1,
|
157
|
+
name: "T-Short Infinity"
|
158
|
+
}
|
159
|
+
],
|
160
|
+
# optional
|
161
|
+
customer_details: {
|
162
|
+
first_name: "Nadia",
|
163
|
+
last_name: "Modjo",
|
164
|
+
email: "noreply@midtrans.com",
|
165
|
+
phone: "+6281 123 12345",
|
166
|
+
billing_address: {
|
167
|
+
address: "Jalan Raya Kalijati",
|
168
|
+
city: "Subang",
|
169
|
+
postal_code: "41271",
|
170
|
+
},
|
171
|
+
},
|
172
|
+
# optional
|
173
|
+
custom_field1: "age: 25",
|
174
|
+
custom_field2: "new_year_promo",
|
175
|
+
custom_field3: "submerchant_id: 23"
|
176
|
+
});
|
177
|
+
# this will be Hash representation of the API JSON response:
|
178
|
+
puts response.data == {
|
146
179
|
status_code: "200",
|
147
180
|
status_message: "Success, Credit Card transaction is successful",
|
148
|
-
transaction_id: "20bcc3dd-6fa5-4a9a-a9ad-615af992aa3d",
|
181
|
+
transaction_id: "20bcc3dd-6fa5-4a9a-a9ad-615af992aa3d",
|
149
182
|
masked_card: "481111-1114",
|
150
183
|
order_id: "order-2",
|
151
184
|
payment_type: "credit_card",
|
@@ -155,190 +188,466 @@ q.data == {
|
|
155
188
|
approval_code: "1415006572598",
|
156
189
|
gross_amount: "100000.00"
|
157
190
|
}
|
191
|
+
```
|
158
192
|
|
159
|
-
|
193
|
+
<a name="snap"></a>
|
194
|
+
#### Snap
|
195
|
+
Snap allows you (as a merchant) to easily integrate with Midtrans payment system to start accepting payments. Snap payment page can be displayed as a seamless pop-up within your web/app during checkout, or as a (Midtrans hosted) web page url redirect.
|
196
|
+
Example below: create Snap transaction.
|
197
|
+
```ruby
|
198
|
+
response = Midtrans.create_snap_token(
|
199
|
+
transaction_details: {
|
200
|
+
order_id: generate_order_id,
|
201
|
+
gross_amount: 100000
|
202
|
+
})
|
203
|
+
# this will be Hash representation of the API JSON response:
|
204
|
+
puts response.data == {
|
205
|
+
status_code: "201",
|
206
|
+
"token": "2b3ccb6c-d0fb-499a-9d46-ef53ad51fe62",
|
207
|
+
"redirect_url": "https://app.sandbox.midtrans.com/snap/v2/vtweb/2b3ccb6c-d0fb-499a-9d46-ef53ad51fe62"
|
208
|
+
}
|
160
209
|
```
|
161
210
|
|
162
211
|
<a name="token"></a>
|
163
|
-
### Test Token
|
164
212
|
|
165
|
-
|
213
|
+
### Create card token
|
214
|
+
|
215
|
+
Creating card token, in production create token should be handled on Frontend please refer to [API docs](https://docs.midtrans.com/en/core-api/credit-card).
|
166
216
|
|
167
217
|
```ruby
|
168
218
|
card =
|
169
219
|
{
|
170
220
|
card_number: 4_811_111_111_111_114,
|
171
221
|
card_cvv: 123,
|
172
|
-
card_exp_month:
|
173
|
-
card_exp_year:
|
222
|
+
card_exp_month: 12,
|
223
|
+
card_exp_year: 2025
|
174
224
|
}
|
175
225
|
|
176
|
-
|
226
|
+
result = Midtrans.create_card_token(card)
|
177
227
|
|
178
|
-
|
228
|
+
result.token_id == "481111-1114-a901971f-2f1b-4781-802a-df326fbf0e9c"
|
179
229
|
```
|
180
230
|
|
181
231
|
<a name="status"></a>
|
182
|
-
### Status
|
183
232
|
|
184
|
-
|
233
|
+
### Status
|
185
234
|
|
235
|
+
Get Transaction Status is triggered to obtain the transaction_status and other details of a specific transaction.
|
186
236
|
```ruby
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
order_id: "
|
195
|
-
payment_type: "
|
196
|
-
|
197
|
-
|
237
|
+
response = Midtrans.status("ruby-lib-test-1633926689")
|
238
|
+
|
239
|
+
# this will be Hash representation of the API JSON response:
|
240
|
+
puts response.data == {
|
241
|
+
transaction_time: "2021-10-11 11:31:29",
|
242
|
+
gross_amount: "10000.00",
|
243
|
+
currency: "IDR",
|
244
|
+
order_id: "ruby-lib-test-1633926689",
|
245
|
+
payment_type: "bank_transfer",
|
246
|
+
signature_key: "412c0a69df9c74d05666ffb079d09b404e3d596b927dbb027bd470d072401a767b0f9ad4659248118979ce274e5bcec3dd683abf9e279ce001eab67f49de5866",
|
247
|
+
status_code: "201",
|
248
|
+
transaction_id: "569a305d-9fec-4fa1-a707-294ee97f7b2a",
|
249
|
+
transaction_status: "pending",
|
198
250
|
fraud_status: "accept",
|
199
|
-
|
200
|
-
|
201
|
-
|
251
|
+
status_message: "Success, transaction is found",
|
252
|
+
merchant_id: "G686051436",
|
253
|
+
permata_va_number: "514003740741123"
|
202
254
|
}
|
203
255
|
```
|
204
256
|
|
205
|
-
|
206
257
|
<a name="cancel"></a>
|
207
|
-
### Cancel
|
208
258
|
|
209
|
-
Cancel
|
210
|
-
Usually we do settlement next day after payment happen, about 4pm.
|
259
|
+
### Cancel
|
211
260
|
|
212
|
-
|
213
|
-
you can't cancel it as simple as credit card, but before user sent money you can cancel pending transactions.
|
261
|
+
Cancel a transaction with a specific order_id. Cancelation can only be done before settlement process.
|
214
262
|
|
215
263
|
```ruby
|
216
|
-
|
264
|
+
response = Midtrans.cancel("ruby-lib-test-1633926562")
|
217
265
|
|
218
|
-
|
266
|
+
# this will be Hash representation of the API JSON response:
|
267
|
+
puts response.data == {
|
219
268
|
status_code: "200",
|
220
269
|
status_message: "Success, transaction is canceled",
|
221
|
-
transaction_id: "
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
270
|
+
transaction_id: "7e75d03e-54a4-44c6-a385-6bbdd28d85c3",
|
271
|
+
order_id: "ruby-lib-test-1633926562",
|
272
|
+
gross_amount: "10000.00",
|
273
|
+
currency: "IDR",
|
274
|
+
payment_type: "bank_transfer",
|
275
|
+
transaction_time: "2021-10-11 11:29:23",
|
226
276
|
transaction_status: "cancel",
|
227
277
|
fraud_status: "accept",
|
228
|
-
|
229
|
-
gross_amount: "100000.00"
|
278
|
+
merchant_id: "G686051436"
|
230
279
|
}
|
231
280
|
```
|
232
281
|
|
233
|
-
|
234
282
|
<a name="approve"></a>
|
283
|
+
|
235
284
|
### Approve
|
236
285
|
|
237
|
-
|
238
|
-
but you also can do it programatically, via API
|
286
|
+
Approve transaction is triggered to accept the card payment transaction with `fraud_status:challenge`
|
239
287
|
|
240
288
|
```ruby
|
241
|
-
|
289
|
+
response = Midtrans.approve("ruby-lib-test-1633926990")
|
242
290
|
|
243
|
-
|
291
|
+
# this will be Hash representation of the API JSON response:
|
292
|
+
puts response.data == {
|
244
293
|
status_code: "200",
|
245
294
|
status_message: "Success, transaction is approved",
|
246
|
-
|
247
|
-
|
248
|
-
|
295
|
+
bank: "bni",
|
296
|
+
transaction_id: "23e5ad9a-c28c-466c-8894-cbbc5445eb97",
|
297
|
+
masked_card: "551011-1115",
|
298
|
+
order_id: "ruby-lib-test-1633926990",
|
299
|
+
merchant_id: "G686051436",
|
249
300
|
payment_type: "credit_card",
|
250
|
-
transaction_time: "
|
301
|
+
transaction_time: "2021-10-11 11:36:33",
|
251
302
|
transaction_status: "capture",
|
252
303
|
fraud_status: "accept",
|
253
|
-
|
254
|
-
|
304
|
+
gross_amount: "10000.00",
|
305
|
+
currency: "IDR",
|
306
|
+
approval_code: "1633926993796"
|
255
307
|
}
|
256
308
|
```
|
257
309
|
|
258
310
|
<a name="refund"></a>
|
311
|
+
|
259
312
|
### Refund
|
260
313
|
|
261
|
-
|
262
|
-
one day after charge request. Defaults to full refund if not specified.
|
314
|
+
Refund transaction is triggered to update the transaction status to refund, when the customer decides to cancel a completed transaction or a payment that is settled.
|
263
315
|
|
264
316
|
```ruby
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
317
|
+
response = Midtrans.refund("ruby-example-coreapi-creditcard-1633678954")
|
318
|
+
|
319
|
+
# this will be Hash representation of the API JSON response:
|
320
|
+
puts response.data == {
|
321
|
+
status_code: "200",
|
322
|
+
status_message: "Success, refund offline request is approved",
|
323
|
+
bank: "bni",
|
324
|
+
transaction_id: "b2a62a3d-03e1-4232-b6b4-5832d5aa7eeb",
|
325
|
+
order_id: "ruby-example-coreapi-creditcard-1633678954",
|
326
|
+
merchant_id: "G686051436",
|
327
|
+
gross_amount: "10000.00",
|
328
|
+
currency: "IDR",
|
329
|
+
payment_type: "credit_card",
|
330
|
+
transaction_time: "2021-10-08 14:42:34",
|
331
|
+
transaction_status: "partial_refund",
|
332
|
+
fraud_status: "accept",
|
333
|
+
approval_code: "1633678955297",
|
334
|
+
masked_card: "521111-1117",
|
335
|
+
refund_chargeback_id: 101293,
|
336
|
+
refund_chargeback_uuid: "c720cb44-272d-4b64-b97d-47d89e86da02",
|
337
|
+
refund_amount: "2000.00",
|
338
|
+
settlement_time: "2021-10-09 16:35:04",
|
339
|
+
refund_key: "reference1"
|
279
340
|
}
|
280
341
|
```
|
281
342
|
|
282
343
|
<a name="capture"></a>
|
344
|
+
|
283
345
|
### Capture
|
284
346
|
|
285
347
|
This API method is only for merchants who have pre-authorise feature (can be requested) and have pre-authorise payments.
|
286
348
|
|
287
349
|
```ruby
|
288
|
-
|
289
|
-
|
350
|
+
response = Midtrans.capture("testing-0.2072-1415086078", 101_000)
|
351
|
+
response.success? # => true
|
290
352
|
```
|
291
353
|
|
292
354
|
<a name="expire"></a>
|
355
|
+
|
293
356
|
### Expire
|
294
357
|
|
295
|
-
To expire pending transactions. For example if a merchant chooses to pay via ATM and
|
296
|
-
|
297
|
-
|
358
|
+
To expire pending transactions. For example if a merchant chooses to pay via ATM and then the user changes their mind
|
359
|
+
and now wants to pay with credit card. In this situation the previous transaction should be expired. The same order_id
|
360
|
+
can be used again.
|
298
361
|
|
299
362
|
```ruby
|
300
|
-
|
301
|
-
|
363
|
+
response = Midtrans.expire("ruby-lib-test-1633927809")
|
364
|
+
# this will be Hash representation of the API JSON response:
|
365
|
+
puts response.data == {
|
366
|
+
status_code: "407",
|
367
|
+
status_message: "Success, transaction has expired",
|
368
|
+
transaction_id: "6ff22198-875e-4a6d-a15d-e23ab3345a4d",
|
369
|
+
order_id: "ruby-lib-test-1633927809",
|
370
|
+
gross_amount: "10000.00",
|
371
|
+
currency: "IDR",
|
372
|
+
payment_type: "bank_transfer",
|
373
|
+
transaction_time: "2021-10-11 11:50:09",
|
374
|
+
transaction_status: "expire",
|
375
|
+
fraud_status: "accept",
|
376
|
+
merchant_id: "G686051436"
|
377
|
+
}
|
302
378
|
```
|
303
379
|
|
304
380
|
<a name="deny"></a>
|
381
|
+
|
305
382
|
### Deny
|
306
|
-
Used to deny a card payment transaction in which `fraud_status` is `challenge`
|
307
383
|
|
384
|
+
Deny transaction is triggered to immediately deny the card payment transaction with `fraud_status:challenge`
|
308
385
|
```ruby
|
309
|
-
|
386
|
+
response = Midtrans.deny("ruby-lib-test-1633927987")
|
310
387
|
|
311
|
-
|
388
|
+
# this will be Hash representation of the API JSON response:
|
389
|
+
puts response.data == {
|
312
390
|
status_code: "200",
|
313
391
|
status_message: "Success, transaction is denied",
|
314
|
-
|
315
|
-
|
316
|
-
|
392
|
+
bank: "bni",
|
393
|
+
transaction_id: "91cf84b9-1523-45b4-adf7-cd76751f71c6",
|
394
|
+
masked_card: "551011-1115",
|
395
|
+
order_id: "ruby-lib-test-1633927987",
|
396
|
+
merchant_id: "G686051436",
|
317
397
|
payment_type: "credit_card",
|
318
|
-
transaction_time: "
|
319
|
-
transaction_status: "
|
398
|
+
transaction_time: "2021-10-11 11:53:07",
|
399
|
+
transaction_status: "cancel",
|
320
400
|
fraud_status: "deny",
|
321
|
-
|
322
|
-
|
401
|
+
gross_amount: "10000.00",
|
402
|
+
currency: "IDR",
|
403
|
+
approval_code: "1633927988537"
|
404
|
+
}
|
405
|
+
```
|
406
|
+
|
407
|
+
<a name="link"></a>
|
408
|
+
### Link payment account
|
409
|
+
Link the customer account to be used for specific payment channels.
|
410
|
+
|
411
|
+
```ruby
|
412
|
+
param = {
|
413
|
+
"payment_type": "gopay",
|
414
|
+
"gopay_partner": {
|
415
|
+
"phone_number": "81987654321",
|
416
|
+
"country_code": "62",
|
417
|
+
"redirect_url": "https://www.gojek.com"
|
418
|
+
}
|
419
|
+
}
|
420
|
+
|
421
|
+
response = Midtrans.link_payment_account(param)
|
422
|
+
|
423
|
+
# this will be Hash representation of the API JSON response:
|
424
|
+
puts response.data == {
|
425
|
+
"status_code": "201",
|
426
|
+
"payment_type": "gopay",
|
427
|
+
"account_id": "f2b21e66-c72d-4fc2-9296-7b2682c82a96",
|
428
|
+
"account_status": "PENDING",
|
429
|
+
"actions": [
|
430
|
+
{
|
431
|
+
"name": "activation-deeplink",
|
432
|
+
"method": "GET",
|
433
|
+
"url": "https://api.sandbox.midtrans.com/v2/pay/account/gpar_8a719131-cd69-44ca-bd12-5c134f925f06/link"
|
434
|
+
},
|
435
|
+
{
|
436
|
+
"name": "activation-link-url",
|
437
|
+
"method": "GET",
|
438
|
+
"url": "https://api.sandbox.midtrans.com/v2/pay/account/gpar_8a719131-cd69-44ca-bd12-5c134f925f06/link"
|
439
|
+
},
|
440
|
+
{
|
441
|
+
"name": "activation-link-app",
|
442
|
+
"method": "GET",
|
443
|
+
"url": "https://simulator.sandbox.midtrans.com/gopay/partner/web/otp?id=18060c31-2542-43be-a1b5-bd5c0cdd1f8d"
|
444
|
+
}
|
445
|
+
],
|
446
|
+
"metadata": {
|
447
|
+
"reference_id": "ec20c478-f81a-4f60-91a8-725cf0c1fd94"
|
448
|
+
}
|
449
|
+
}
|
450
|
+
```
|
451
|
+
|
452
|
+
<a name="get_payment_account"></a>
|
453
|
+
### Get payment account
|
454
|
+
Get Pay Account is triggered to get a customer account to use for specific payment channel.
|
455
|
+
```ruby
|
456
|
+
response = Midtrans.get_payment_account("f2b21e66-c72d-4fc2-9296-7b2682c82a96")
|
457
|
+
|
458
|
+
# this will be Hash representation of the API JSON response:
|
459
|
+
puts response.data == {
|
460
|
+
"status_code": "201",
|
461
|
+
"payment_type": "gopay",
|
462
|
+
"account_id": "f2b21e66-c72d-4fc2-9296-7b2682c82a96",
|
463
|
+
"account_status": "PENDING"
|
464
|
+
}
|
465
|
+
```
|
466
|
+
|
467
|
+
<a name="unlink_payment_account"></a>
|
468
|
+
### Unlink payment account
|
469
|
+
Unbind Pay Account is triggered to remove the linked customer account.
|
470
|
+
```ruby
|
471
|
+
response = Midtrans.unlink_payment_account("f2b21e66-c72d-4fc2-9296-7b2682c82a96")
|
472
|
+
|
473
|
+
# this will be Hash representation of the API JSON response:
|
474
|
+
puts response.data == {
|
475
|
+
"status_code": "204",
|
476
|
+
"payment_type": "gopay",
|
477
|
+
"account_id": "f2b21e66-c72d-4fc2-9296-7b2682c82a96",
|
478
|
+
"account_status": "DISABLED",
|
479
|
+
"channel_response_code": "0",
|
480
|
+
"channel_response_message": "Process service request successfully."
|
481
|
+
}
|
482
|
+
```
|
483
|
+
|
484
|
+
<a name="create_subscription"></a>
|
485
|
+
### Create subscription
|
486
|
+
Create a subscription transaction by sending all the details required to create a transaction. The details such as name, amount, currency, payment_type, token, and schedule are sent in the request. Successful request returns id status:active, and other subscription details.
|
487
|
+
|
488
|
+
```ruby
|
489
|
+
param = {
|
490
|
+
"name": "MONTHLY_2021",
|
491
|
+
"amount": "17000",
|
492
|
+
"currency": "IDR",
|
493
|
+
"payment_type": "credit_card",
|
494
|
+
"token": "dummy",
|
495
|
+
"schedule": {
|
496
|
+
"interval": 1,
|
497
|
+
"interval_unit": "month",
|
498
|
+
"max_interval": 12,
|
499
|
+
"start_time": "2021-10-10 07:25:01 +0700"
|
500
|
+
},
|
501
|
+
"metadata": {
|
502
|
+
"description": "Recurring payment for A"
|
503
|
+
},
|
504
|
+
"customer_details": {
|
505
|
+
"first_name": "John",
|
506
|
+
"last_name": "Doe",
|
507
|
+
"email": "johndoe@email.com",
|
508
|
+
"phone": "+62812345678"
|
509
|
+
}
|
510
|
+
}
|
511
|
+
|
512
|
+
response = Midtrans.create_subscription(param)
|
513
|
+
|
514
|
+
# this will be Hash representation of the API JSON response:
|
515
|
+
puts response.data == {
|
516
|
+
"id": "d137e7f4-9474-4fc2-9847-672e09cb16f6",
|
517
|
+
"name": "MONTHLY_2021",
|
518
|
+
"amount": "17000",
|
519
|
+
"currency": "IDR",
|
520
|
+
"created_at": "2021-09-28 10:40:29",
|
521
|
+
"schedule": {
|
522
|
+
"interval": 1,
|
523
|
+
"current_interval": 0,
|
524
|
+
"max_interval": 12,
|
525
|
+
"interval_unit": "month",
|
526
|
+
"start_time": "2021-10-10 07:25:01",
|
527
|
+
"next_execution_at": "2021-10-10 07:25:01"
|
528
|
+
},
|
529
|
+
"status": "active",
|
530
|
+
"token": "dummy",
|
531
|
+
"payment_type": "credit_card",
|
532
|
+
"transaction_ids": [
|
533
|
+
|
534
|
+
],
|
535
|
+
"metadata": {
|
536
|
+
"description": "Recurring payment for A"
|
537
|
+
},
|
538
|
+
"customer_details": {
|
539
|
+
"email": "johndoe@email.com",
|
540
|
+
"first_name": "John",
|
541
|
+
"last_name": "Doe",
|
542
|
+
"phone": "+62812345678"
|
543
|
+
}
|
544
|
+
}
|
545
|
+
```
|
546
|
+
|
547
|
+
<a name="get_subscription"></a>
|
548
|
+
### Get subscription
|
549
|
+
Retrieve the subscription details of a customer using the subscription_id. Successful request returns subscription object and status:active.
|
550
|
+
```ruby
|
551
|
+
response = Midtrans.get_subscription("d137e7f4-9474-4fc2-9847-672e09cb16f6")
|
552
|
+
|
553
|
+
# this will be Hash representation of the API JSON response:
|
554
|
+
puts response.data == {
|
555
|
+
"id": "d137e7f4-9474-4fc2-9847-672e09cb16f6",
|
556
|
+
"name": "MONTHLY_2021",
|
557
|
+
"amount": "17000",
|
558
|
+
"currency": "IDR",
|
559
|
+
"created_at": "2021-09-28 10:40:30",
|
560
|
+
"schedule": {
|
561
|
+
"interval": 1,
|
562
|
+
"current_interval": 0,
|
563
|
+
"max_interval": 12,
|
564
|
+
"interval_unit": "month",
|
565
|
+
"start_time": "2021-10-10 07:25:01",
|
566
|
+
"next_execution_at": "2021-10-10 07:25:01"
|
567
|
+
},
|
568
|
+
"status": "active",
|
569
|
+
"token": "dummy",
|
570
|
+
"payment_type": "credit_card",
|
571
|
+
"transaction_ids": [
|
572
|
+
|
573
|
+
],
|
574
|
+
"metadata": {
|
575
|
+
"description": "Recurring payment for A"
|
576
|
+
},
|
577
|
+
"customer_details": {
|
578
|
+
"email": "johndoe@email.com",
|
579
|
+
"first_name": "John",
|
580
|
+
"last_name": "Doe",
|
581
|
+
"phone": "+62812345678"
|
582
|
+
}
|
583
|
+
}
|
584
|
+
```
|
585
|
+
|
586
|
+
<a name="disable_subscription"></a>
|
587
|
+
### Disable subscription
|
588
|
+
Disable a customer's subscription account with a specific subscription_id so that the customer is not charged for the subscription in the future. Successful request returns status_message indicating that the subscription details are updated.
|
589
|
+
|
590
|
+
```ruby
|
591
|
+
response = Midtrans.disable_subscription("d137e7f4-9474-4fc2-9847-672e09cb16f6")
|
592
|
+
|
593
|
+
# this will be Hash representation of the API JSON response:
|
594
|
+
puts response.data == {
|
595
|
+
"status_message": "Subscription is updated."
|
323
596
|
}
|
324
597
|
```
|
325
598
|
|
599
|
+
<a name="enable_subscription"></a>
|
600
|
+
### Enable subscription
|
601
|
+
Activate a customer's subscription account with a specific subscription_id, so that the customer can start paying for the subscription immediately. Successful request returns status_message indicating that the subscription details are updated.
|
602
|
+
```ruby
|
603
|
+
response = Midtrans.enable_subscription("d137e7f4-9474-4fc2-9847-672e09cb16f6")
|
326
604
|
|
605
|
+
# this will be Hash representation of the API JSON response:
|
606
|
+
puts response.data == {
|
607
|
+
"status_message": "Subscription is updated."
|
608
|
+
}
|
609
|
+
```
|
327
610
|
|
328
|
-
|
611
|
+
<a name="update_subscription"></a>
|
612
|
+
### Update subscription
|
613
|
+
Update the details of a customer's existing subscription account with the specific subscription_id. Successful request returns status_message indicating that the subscription details are updated.
|
614
|
+
```ruby
|
615
|
+
param = {
|
616
|
+
"name": "MONTHLY_2021",
|
617
|
+
"amount": "21000",
|
618
|
+
"currency": "IDR",
|
619
|
+
"token": "dummy",
|
620
|
+
"schedule": {
|
621
|
+
"interval": 1
|
622
|
+
}
|
623
|
+
}
|
329
624
|
|
625
|
+
response = Midtrans.update_subscription("d137e7f4-9474-4fc2-9847-672e09cb16f6", param)
|
626
|
+
|
627
|
+
# this will be Hash representation of the API JSON response:
|
628
|
+
puts response.data == {
|
629
|
+
"status_message": "Subscription is updated."
|
630
|
+
}
|
631
|
+
```
|
632
|
+
|
633
|
+
## Get json field value from Midtrans API result
|
330
634
|
```ruby
|
331
|
-
result =
|
635
|
+
result = Midtrans.charge(...)
|
636
|
+
|
637
|
+
# If in the future there is a new attribute in the Midtrans Result.
|
638
|
+
# The recommended way to retrieve the value is like example below.
|
639
|
+
# :new_attribute is the new field name in API response JSON
|
640
|
+
result.data[:new_attribute]
|
332
641
|
|
333
|
-
|
642
|
+
# Alternatively you can also retrieve the value like below.
|
643
|
+
# When the field name is not actually exists on the API response JSON, it will trigger an error. Make sure to handle it.
|
644
|
+
result.new_attribute
|
334
645
|
```
|
335
646
|
|
336
|
-
* `
|
337
|
-
* `
|
338
|
-
* `
|
339
|
-
* `
|
340
|
-
* `
|
341
|
-
* `
|
342
|
-
* `
|
343
|
-
* `Veritrans::Result#response` - `Excon::Response` instance
|
344
|
-
* `Veritrans::Result#method_mising` - acessing fields of `data`. E.g. `result.transction_status`, `result.masked_card`, `result.approval_code`
|
647
|
+
* `Midtrans::Result#success?` - `boolean`, Based on `status_code` field in API response JSON
|
648
|
+
* `Midtrans::Result#status_code` - `integer`, e.g. 200, 402. Documentation https://api-docs.midtrans.com/#status-code
|
649
|
+
* `Midtrans::Result#status_message` - `string`, e.g."Success, Credit Card transaction is successful"
|
650
|
+
* `Midtrans::Result#redirect_url` - `string`, For Snap payment page, where customer can be redirected to complete the payment
|
651
|
+
* `Midtrans::Result#body` - `string`, Raw HTTP response body
|
652
|
+
* `Midtrans::Result#data` - `hash`, Parsed API response JSON body as hash
|
653
|
+
* `Midtrans::Result#response` - Raw `Excon::Response` instance
|