veritrans 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (275) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/.idea/.gitignore +8 -0
  4. data/.rubocop.yml +1 -1
  5. data/.travis.yml +2 -1
  6. data/CHANGELOG.md +13 -0
  7. data/Gemfile +2 -11
  8. data/Gemfile.lock +116 -145
  9. data/Maintaining.MD +8 -0
  10. data/README.md +247 -278
  11. data/api_reference.md +482 -173
  12. data/example/coreapi/core_api_credit_card_example.rb +66 -0
  13. data/example/coreapi/readme.md +4 -0
  14. data/example/sinatra/Gemfile +7 -0
  15. data/example/sinatra/README.md +4 -6
  16. data/example/sinatra/index.erb +180 -192
  17. data/example/sinatra/response.erb +1 -40
  18. data/example/sinatra/snap.erb +33 -0
  19. data/example/sinatra/snap_redirect.erb +10 -0
  20. data/example/sinatra/webapp.rb +113 -0
  21. data/example/snap/readme.md +4 -0
  22. data/example/snap/snap_example.rb +39 -0
  23. data/lib/test/all.rb +1 -0
  24. data/lib/test/api_test.rb +319 -0
  25. data/lib/test/config_test.rb +26 -0
  26. data/lib/test/gopay_tokenization_test.rb +80 -0
  27. data/lib/test/snap_test.rb +79 -0
  28. data/lib/test/subscription_test.rb +116 -0
  29. data/lib/test/transaction_test.rb +160 -0
  30. data/lib/veritrans/api.rb +105 -8
  31. data/lib/veritrans/client.rb +40 -7
  32. data/lib/veritrans/config.rb +26 -3
  33. data/lib/veritrans/midtrans_error.rb +15 -0
  34. data/lib/veritrans/version.rb +1 -1
  35. data/lib/veritrans.rb +5 -6
  36. data/veritrans.gemspec +1 -2
  37. metadata +25 -248
  38. data/.rspec +0 -2
  39. data/Procfile +0 -1
  40. data/Rakefile +0 -16
  41. data/bin/midtrans +0 -3
  42. data/bin/veritrans +0 -68
  43. data/example/rails/cable/Gemfile +0 -48
  44. data/example/rails/cable/Gemfile.lock +0 -184
  45. data/example/rails/cable/README.md +0 -29
  46. data/example/rails/cable/Rakefile +0 -6
  47. data/example/rails/cable/app/assets/config/manifest.js +0 -3
  48. data/example/rails/cable/app/assets/images/.keep +0 -0
  49. data/example/rails/cable/app/assets/javascripts/application.js +0 -15
  50. data/example/rails/cable/app/assets/javascripts/cable.js +0 -13
  51. data/example/rails/cable/app/assets/javascripts/channels/.keep +0 -0
  52. data/example/rails/cable/app/assets/javascripts/chats.js +0 -39
  53. data/example/rails/cable/app/assets/javascripts/rooms.js +0 -55
  54. data/example/rails/cable/app/assets/stylesheets/application.css +0 -16
  55. data/example/rails/cable/app/assets/stylesheets/chatbox.scss +0 -31
  56. data/example/rails/cable/app/assets/stylesheets/peoplebox.scss +0 -6
  57. data/example/rails/cable/app/channels/application_cable/channel.rb +0 -4
  58. data/example/rails/cable/app/channels/application_cable/connection.rb +0 -4
  59. data/example/rails/cable/app/channels/rooms_texting_channel.rb +0 -13
  60. data/example/rails/cable/app/controllers/application_controller.rb +0 -3
  61. data/example/rails/cable/app/controllers/chats_controller.rb +0 -18
  62. data/example/rails/cable/app/controllers/concerns/.keep +0 -0
  63. data/example/rails/cable/app/controllers/pays_controller.rb +0 -28
  64. data/example/rails/cable/app/controllers/rooms_controller.rb +0 -4
  65. data/example/rails/cable/app/helpers/application_helper.rb +0 -2
  66. data/example/rails/cable/app/helpers/chats_helper.rb +0 -2
  67. data/example/rails/cable/app/helpers/rooms_helper.rb +0 -5
  68. data/example/rails/cable/app/jobs/application_job.rb +0 -2
  69. data/example/rails/cable/app/jobs/chat_broadcaster_job.rb +0 -15
  70. data/example/rails/cable/app/mailers/application_mailer.rb +0 -4
  71. data/example/rails/cable/app/models/application_record.rb +0 -3
  72. data/example/rails/cable/app/models/chat.rb +0 -41
  73. data/example/rails/cable/app/models/concerns/.keep +0 -0
  74. data/example/rails/cable/app/models/order.rb +0 -2
  75. data/example/rails/cable/app/models/user.rb +0 -2
  76. data/example/rails/cable/app/views/chats/_chat.html.erb +0 -18
  77. data/example/rails/cable/app/views/layouts/application.html.erb +0 -19
  78. data/example/rails/cable/app/views/layouts/mailer.html.erb +0 -13
  79. data/example/rails/cable/app/views/layouts/mailer.text.erb +0 -1
  80. data/example/rails/cable/app/views/rooms/_chatbox.html.erb +0 -13
  81. data/example/rails/cable/app/views/rooms/_online_people.html.erb +0 -53
  82. data/example/rails/cable/app/views/rooms/index.html.erb +0 -9
  83. data/example/rails/cable/bin/bundle +0 -3
  84. data/example/rails/cable/bin/rails +0 -9
  85. data/example/rails/cable/bin/rake +0 -9
  86. data/example/rails/cable/bin/setup +0 -34
  87. data/example/rails/cable/bin/spring +0 -16
  88. data/example/rails/cable/bin/update +0 -29
  89. data/example/rails/cable/config/application.rb +0 -16
  90. data/example/rails/cable/config/boot.rb +0 -3
  91. data/example/rails/cable/config/cable.yml +0 -9
  92. data/example/rails/cable/config/database.yml +0 -20
  93. data/example/rails/cable/config/environment.rb +0 -5
  94. data/example/rails/cable/config/environments/development.rb +0 -57
  95. data/example/rails/cable/config/environments/production.rb +0 -86
  96. data/example/rails/cable/config/environments/test.rb +0 -42
  97. data/example/rails/cable/config/initializers/application_controller_renderer.rb +0 -6
  98. data/example/rails/cable/config/initializers/assets.rb +0 -11
  99. data/example/rails/cable/config/initializers/backtrace_silencers.rb +0 -7
  100. data/example/rails/cable/config/initializers/cookies_serializer.rb +0 -5
  101. data/example/rails/cable/config/initializers/filter_parameter_logging.rb +0 -4
  102. data/example/rails/cable/config/initializers/inflections.rb +0 -16
  103. data/example/rails/cable/config/initializers/mime_types.rb +0 -4
  104. data/example/rails/cable/config/initializers/new_framework_defaults.rb +0 -24
  105. data/example/rails/cable/config/initializers/session_store.rb +0 -3
  106. data/example/rails/cable/config/initializers/sidekiq.rb +0 -2
  107. data/example/rails/cable/config/initializers/veritrans.rb +0 -46
  108. data/example/rails/cable/config/initializers/wrap_parameters.rb +0 -14
  109. data/example/rails/cable/config/locales/en.yml +0 -23
  110. data/example/rails/cable/config/puma.rb +0 -47
  111. data/example/rails/cable/config/routes.rb +0 -18
  112. data/example/rails/cable/config/secrets.yml +0 -22
  113. data/example/rails/cable/config/spring.rb +0 -6
  114. data/example/rails/cable/config/veritrans.yml +0 -13
  115. data/example/rails/cable/config.ru +0 -5
  116. data/example/rails/cable/db/development.sqlite3 +0 -0
  117. data/example/rails/cable/db/migrate/20161215070044_create_chats.rb +0 -10
  118. data/example/rails/cable/db/migrate/20161215072021_create_users.rb +0 -10
  119. data/example/rails/cable/db/migrate/20161219110219_create_orders.rb +0 -11
  120. data/example/rails/cable/db/schema.rb +0 -37
  121. data/example/rails/cable/db/seeds.rb +0 -41
  122. data/example/rails/cable/db/test.sqlite3 +0 -0
  123. data/example/rails/cable/lib/assets/.keep +0 -0
  124. data/example/rails/cable/lib/tasks/.keep +0 -0
  125. data/example/rails/cable/log/.keep +0 -0
  126. data/example/rails/cable/public/404.html +0 -67
  127. data/example/rails/cable/public/422.html +0 -67
  128. data/example/rails/cable/public/500.html +0 -66
  129. data/example/rails/cable/public/apple-touch-icon-precomposed.png +0 -0
  130. data/example/rails/cable/public/apple-touch-icon.png +0 -0
  131. data/example/rails/cable/public/favicon.ico +0 -0
  132. data/example/rails/cable/public/images/avatar1.jpg +0 -0
  133. data/example/rails/cable/public/images/avatar2.jpg +0 -0
  134. data/example/rails/cable/public/images/avatar3.jpg +0 -0
  135. data/example/rails/cable/public/images/avatar4.jpg +0 -0
  136. data/example/rails/cable/public/images/avatar5.jpg +0 -0
  137. data/example/rails/cable/public/images/avatar6.jpg +0 -0
  138. data/example/rails/cable/public/robots.txt +0 -5
  139. data/example/rails/cable/vendor/assets/javascripts/.keep +0 -0
  140. data/example/rails/cable/vendor/assets/stylesheets/.keep +0 -0
  141. data/example/rails/cable/vendor/assets/stylesheets/photon.css +0 -2333
  142. data/example/rails/simplepay/Gemfile +0 -54
  143. data/example/rails/simplepay/Gemfile.lock +0 -178
  144. data/example/rails/simplepay/README.md +0 -30
  145. data/example/rails/simplepay/Rakefile +0 -6
  146. data/example/rails/simplepay/app/assets/config/manifest.js +0 -3
  147. data/example/rails/simplepay/app/assets/images/.keep +0 -0
  148. data/example/rails/simplepay/app/assets/javascripts/application.js +0 -16
  149. data/example/rails/simplepay/app/assets/javascripts/cable.js +0 -13
  150. data/example/rails/simplepay/app/assets/javascripts/channels/.keep +0 -0
  151. data/example/rails/simplepay/app/assets/javascripts/pay.js +0 -18
  152. data/example/rails/simplepay/app/assets/stylesheets/application.css +0 -15
  153. data/example/rails/simplepay/app/assets/stylesheets/style.css +0 -254
  154. data/example/rails/simplepay/app/channels/application_cable/channel.rb +0 -4
  155. data/example/rails/simplepay/app/channels/application_cable/connection.rb +0 -4
  156. data/example/rails/simplepay/app/controllers/application_controller.rb +0 -3
  157. data/example/rails/simplepay/app/controllers/concerns/.keep +0 -0
  158. data/example/rails/simplepay/app/controllers/home_controller.rb +0 -16
  159. data/example/rails/simplepay/app/controllers/pay_controller.rb +0 -10
  160. data/example/rails/simplepay/app/helpers/application_helper.rb +0 -2
  161. data/example/rails/simplepay/app/helpers/pay_helper.rb +0 -2
  162. data/example/rails/simplepay/app/jobs/application_job.rb +0 -2
  163. data/example/rails/simplepay/app/mailers/application_mailer.rb +0 -4
  164. data/example/rails/simplepay/app/models/application_record.rb +0 -3
  165. data/example/rails/simplepay/app/models/concerns/.keep +0 -0
  166. data/example/rails/simplepay/app/models/order.rb +0 -2
  167. data/example/rails/simplepay/app/views/home/index.html.erb +0 -19
  168. data/example/rails/simplepay/app/views/layouts/application.html.erb +0 -15
  169. data/example/rails/simplepay/app/views/layouts/mailer.html.erb +0 -13
  170. data/example/rails/simplepay/app/views/layouts/mailer.text.erb +0 -1
  171. data/example/rails/simplepay/app/views/pay/notify.html.erb +0 -2
  172. data/example/rails/simplepay/bin/bundle +0 -3
  173. data/example/rails/simplepay/bin/rails +0 -9
  174. data/example/rails/simplepay/bin/rake +0 -9
  175. data/example/rails/simplepay/bin/setup +0 -34
  176. data/example/rails/simplepay/bin/spring +0 -16
  177. data/example/rails/simplepay/bin/update +0 -29
  178. data/example/rails/simplepay/config/application.rb +0 -15
  179. data/example/rails/simplepay/config/boot.rb +0 -3
  180. data/example/rails/simplepay/config/cable.yml +0 -9
  181. data/example/rails/simplepay/config/database.yml +0 -25
  182. data/example/rails/simplepay/config/environment.rb +0 -5
  183. data/example/rails/simplepay/config/environments/development.rb +0 -57
  184. data/example/rails/simplepay/config/environments/production.rb +0 -86
  185. data/example/rails/simplepay/config/environments/test.rb +0 -42
  186. data/example/rails/simplepay/config/initializers/application_controller_renderer.rb +0 -6
  187. data/example/rails/simplepay/config/initializers/assets.rb +0 -11
  188. data/example/rails/simplepay/config/initializers/backtrace_silencers.rb +0 -7
  189. data/example/rails/simplepay/config/initializers/cookies_serializer.rb +0 -5
  190. data/example/rails/simplepay/config/initializers/filter_parameter_logging.rb +0 -4
  191. data/example/rails/simplepay/config/initializers/inflections.rb +0 -16
  192. data/example/rails/simplepay/config/initializers/mime_types.rb +0 -4
  193. data/example/rails/simplepay/config/initializers/new_framework_defaults.rb +0 -24
  194. data/example/rails/simplepay/config/initializers/session_store.rb +0 -3
  195. data/example/rails/simplepay/config/initializers/veritrans.rb +0 -46
  196. data/example/rails/simplepay/config/initializers/wrap_parameters.rb +0 -14
  197. data/example/rails/simplepay/config/locales/en.yml +0 -23
  198. data/example/rails/simplepay/config/puma.rb +0 -47
  199. data/example/rails/simplepay/config/routes.rb +0 -5
  200. data/example/rails/simplepay/config/secrets.yml +0 -22
  201. data/example/rails/simplepay/config/spring.rb +0 -6
  202. data/example/rails/simplepay/config/veritrans.yml +0 -18
  203. data/example/rails/simplepay/config.ru +0 -5
  204. data/example/rails/simplepay/db/development.sqlite3 +0 -0
  205. data/example/rails/simplepay/db/migrate/20161221090855_create_orders.rb +0 -10
  206. data/example/rails/simplepay/db/schema.rb +0 -22
  207. data/example/rails/simplepay/db/seeds.rb +0 -7
  208. data/example/rails/simplepay/db/test.sqlite3 +0 -0
  209. data/example/rails/simplepay/lib/assets/.keep +0 -0
  210. data/example/rails/simplepay/lib/tasks/.keep +0 -0
  211. data/example/rails/simplepay/log/.keep +0 -0
  212. data/example/rails/simplepay/public/404.html +0 -67
  213. data/example/rails/simplepay/public/422.html +0 -67
  214. data/example/rails/simplepay/public/500.html +0 -66
  215. data/example/rails/simplepay/public/apple-touch-icon-precomposed.png +0 -0
  216. data/example/rails/simplepay/public/apple-touch-icon.png +0 -0
  217. data/example/rails/simplepay/public/favicon.ico +0 -0
  218. data/example/rails/simplepay/public/robots.txt +0 -5
  219. data/example/rails/simplepay/vendor/assets/javascripts/.keep +0 -0
  220. data/example/rails/simplepay/vendor/assets/stylesheets/.keep +0 -0
  221. data/example/sinatra/config.ru +0 -9
  222. data/example/sinatra/localization.erb +0 -249
  223. data/example/sinatra/points.erb +0 -188
  224. data/example/sinatra/recurring.erb +0 -201
  225. data/example/sinatra/sinatra.rb +0 -194
  226. data/example/sinatra/style.css +0 -137
  227. data/example/sinatra/veritrans.yml +0 -11
  228. data/example/sinatra/widget.erb +0 -63
  229. data/lib/generators/templates/assets/credit_card_form.js +0 -57
  230. data/lib/generators/templates/payments_controller.rb +0 -85
  231. data/lib/generators/templates/veritrans.rb +0 -46
  232. data/lib/generators/templates/veritrans.yml +0 -18
  233. data/lib/generators/templates/views/_credit_card_form.erb +0 -42
  234. data/lib/generators/templates/views/_veritrans_include.erb +0 -10
  235. data/lib/generators/templates/views/payments/create.erb +0 -15
  236. data/lib/generators/templates/views/payments/new.erb +0 -6
  237. data/lib/generators/veritrans/install_generator.rb +0 -32
  238. data/lib/generators/veritrans/payment_form_generator.rb +0 -45
  239. data/lib/veritrans/cli.rb +0 -161
  240. data/lib/veritrans/testing.rb +0 -156
  241. data/spec/cli_spec.rb +0 -83
  242. data/spec/configs/real_key.yml +0 -4
  243. data/spec/configs/veritrans.yml +0 -7
  244. data/spec/configs/veritrans_flat.yml +0 -2
  245. data/spec/configs/veritrans_with_erb.yml +0 -2
  246. data/spec/fixtures/approve_failed.yml +0 -48
  247. data/spec/fixtures/cancel_failed.yml +0 -48
  248. data/spec/fixtures/cancel_success.yml +0 -126
  249. data/spec/fixtures/capture_failed.yml +0 -48
  250. data/spec/fixtures/charge.yml +0 -50
  251. data/spec/fixtures/charge_direct.yml +0 -56
  252. data/spec/fixtures/charge_vtweb.yml +0 -50
  253. data/spec/fixtures/cli_test_1111-not-exists.yml +0 -45
  254. data/spec/fixtures/cli_test_not_exists.yml +0 -45
  255. data/spec/fixtures/cli_test_real_txn.yml +0 -55
  256. data/spec/fixtures/cli_test_unauthorized.yml +0 -47
  257. data/spec/fixtures/deny_failed.yml +0 -144
  258. data/spec/fixtures/events_test_real_txn.yml +0 -55
  259. data/spec/fixtures/expire_failed.yml +0 -50
  260. data/spec/fixtures/expire_success.yml +0 -56
  261. data/spec/fixtures/midtrans_status.yml +0 -117
  262. data/spec/fixtures/refund_failed.yml +0 -54
  263. data/spec/fixtures/status_fail.yml +0 -48
  264. data/spec/fixtures/status_success.yml +0 -128
  265. data/spec/fixtures/test_token.yml +0 -49
  266. data/spec/midtrans_rename_spec.rb +0 -27
  267. data/spec/rails_plugin_spec.rb +0 -317
  268. data/spec/spec_helper.rb +0 -71
  269. data/spec/veritrans_client_spec.rb +0 -235
  270. data/spec/veritrans_config_spec.rb +0 -70
  271. data/spec/veritrans_events_spec.rb +0 -72
  272. data/spec/veritrans_logger_spec.rb +0 -46
  273. data/spec/veritrans_snap_spec.rb +0 -54
  274. data/spec/veritrans_testing_spec.rb +0 -184
  275. data/testing_webhooks.md +0 -78
data/api_reference.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # API Reference
2
2
 
3
- Here is only reference for API of this gem, to see complete information
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">Veritrans.charge(data)</a></td>
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">Veritrans.test_token(data)</a></td>
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">Veritrans.status(id)</a></td>
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">Veritrans.cancel(id)</a></td>
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">Veritrans.approve(id)</a></td>
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">Veritrans.refund(id)</a></td>
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">Veritrans.capture(id)</a></td>
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">Veritrans.expire(id)</a></td>
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">Veritrans.deny(id)</a></td>
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
- <a name="charge"></a>
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
- **For VT-Web:**
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
- **For VT-Direct:**
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
- q = Veritrans.charge({
105
- # *required
106
- payment_type: "credit_card",
107
- # *required
108
- transaction_details: {
109
- order_id: "order-2",
110
- gross_amount: 100_000
111
- },
112
- # *required (but different for different payment type)
113
- credit_card: {
114
- token_id: "dcd6cd71-bc4c-4f4b-8752-49cb0a3f204c",
115
- bank: "cimb"
116
- },
117
- # optional
118
- item_details: [
119
- {
120
- id: "ITEM1",
121
- price: 100_000,
122
- quantity: 1,
123
- name: "T-Short Infinity"
124
- }
125
- ],
126
- # optional
127
- customer_details: {
128
- first_name: "Nadia",
129
- last_name: "Modjo",
130
- email: "noreply@midtrans.com",
131
- phone: "+6281 123 12345",
132
- billing_address: {
133
- address: "Jalan Raya Kalijati",
134
- city: "Subang",
135
- postal_code: "41271",
136
- },
137
- },
138
- # optional
139
- custom_field1: "age: 25",
140
- custom_field2: "new_year_promo",
141
- custom_field3: "submerchant_id: 23"
142
- });
143
-
144
- q.class # => Veritrans::Result
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
- q.success? # => true
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
- Get a token from card information for testing. **Not to be used outside of tests**
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: 0o1,
173
- card_exp_year: 2020
222
+ card_exp_month: 12,
223
+ card_exp_year: 2025
174
224
  }
175
225
 
176
- q = Veritrans.test_token(card)
226
+ result = Midtrans.create_card_token(card)
177
227
 
178
- q == '481111-1114-a901971f-2f1b-4781-802a-df326fbf0e9c'
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
- Return current status of transaction.
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
- q = Veritrans.status("order-2")
188
-
189
- q.data == {
190
- status_code: "200",
191
- status_message: "Success, transaction found",
192
- transaction_id: "20bcc3dd-6fa5-4a9a-a9ad-615af992aa3d",
193
- masked_card: "481111-1114",
194
- order_id: "order-2",
195
- payment_type: "credit_card",
196
- transaction_time: "2014-11-03 16:22:52",
197
- transaction_status: "settlement",
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
- signature_key: "639af8e985f68526839e6ed04c1...",
200
- bank: "bni",
201
- gross_amount: "100000.00"
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 transaction, before it was settled. For credit card payments you can cancel it before we trigger settlement in bank.
210
- Usually we do settlement next day after payment happen, about 4pm.
259
+ ### Cancel
211
260
 
212
- For internet banking, bank transfer, mobile payments, convenient store payments if user already made payment,
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
- q = Veritrans.cancel("testing-0.2072-1415086078")
264
+ response = Midtrans.cancel("ruby-lib-test-1633926562")
217
265
 
218
- q.data == {
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: "b38f598a-59ab-4850-b311-2aa14c78bc45",
222
- masked_card: "481111-1114",
223
- order_id: "testing-0.2072-1415086078",
224
- payment_type: "credit_card",
225
- transaction_time: "2014-11-04 14:29:47",
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
- bank: "bni",
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
- Some transactions marked as challenge. If challenge you can approve it or cancel it. Usual way is to use our dashboard web interface,
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
- q = Veritrans.cancel("testing-0.2072-1415086078")
289
+ response = Midtrans.approve("ruby-lib-test-1633926990")
242
290
 
243
- q.data == {
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
- transaction_id: "8492c240-1600-465a-9bf1-808863410b0e",
247
- masked_card: "451111-1117",
248
- order_id: "testing-0.0501-1415086808",
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: "2014-11-04 14:41:58",
301
+ transaction_time: "2021-10-11 11:36:33",
251
302
  transaction_status: "capture",
252
303
  fraud_status: "accept",
253
- bank: "bni",
254
- gross_amount: "100000.00"
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
- To be used to refund. Can only be used on transactions that are marked as `successful` which happens automatically after
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
- q = Veritrans.refund('testing-0.2072-1415086078')
266
-
267
- q == {
268
- status_code: "200",
269
- status_message: "Success, refund request is approved",
270
- transaction_id: "447e846a-403e-47db-a5da-d7f3f06375d6",
271
- order_id: "testing-0.2072-1415086078",
272
- payment_type: "credit_card",
273
- transaction_time: "2015-06-15 13:36:24",
274
- transaction_status: "refund",
275
- gross_amount: "10000.00",
276
- refund_chargeback_id: 1,
277
- refund_amount: "10000.00",
278
- refund_key: "reference1"
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
- q = Veritrans.capture("testing-0.2072-1415086078", 101_000)
289
- q.success? # => true
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
- then the user changes their mind and now wants to pay with credit card.
297
- In this situation the previous transaction should be expired. The same order_id can be used again.
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
- q = Veritrans.expire("testing-0.2072-1415086078")
301
- q.success? # => true
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
- q = Veritrans.deny("testing-0.2072-1415086078")
386
+ response = Midtrans.deny("ruby-lib-test-1633927987")
310
387
 
311
- q == {
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
- transaction_id: "ca297170-be4c-45ed-9dc9-be5ba99d30ee",
315
- masked_card: "451111-1117",
316
- order_id: "testing-0.2072-1415086078",
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: "2014-10-31 14:46:44",
319
- transaction_status: "deny",
398
+ transaction_time: "2021-10-11 11:53:07",
399
+ transaction_status: "cancel",
320
400
  fraud_status: "deny",
321
- bank: "bni",
322
- gross_amount: "30000.00"
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
- ### `Veritrans::Result`
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 = Veritrans.charge(...)
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
- result.class # => Veritrans::Result
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
- * `Veritrans::Result#success?` - `boolean`, base on `status_code` field in json
337
- * `Veritrans::Result#created?` - `boolean`, for VT-Link
338
- * `Veritrans::Result#status_code` - `integer`, e.g. 200, 402. Documentation https://api-docs.midtrans.com/#status-code
339
- * `Veritrans::Result#status_message` - `string`, e.g. "OK, success do VTWeb transaction, please go to redirect_url"
340
- * `Veritrans::Result#redirect_url` - `string`, redirect URL for VT-Web and VT-Link
341
- * `Veritrans::Result#body` - `string`, raw HTTP request body
342
- * `Veritrans::Result#data` - `hash`, parsed json body as hash
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