veritrans 2.1.3 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +6 -1
  3. data/.travis.yml +3 -5
  4. data/CHANGELOG.md +20 -0
  5. data/Gemfile +1 -1
  6. data/Gemfile.lock +89 -94
  7. data/Procfile +1 -1
  8. data/README.md +62 -13
  9. data/api_reference.md +10 -10
  10. data/example/rails/cable/Gemfile +48 -0
  11. data/example/rails/cable/Gemfile.lock +184 -0
  12. data/example/rails/cable/README.md +29 -0
  13. data/example/rails/cable/Rakefile +6 -0
  14. data/example/rails/cable/app/assets/config/manifest.js +3 -0
  15. data/example/rails/cable/app/assets/images/.keep +0 -0
  16. data/example/rails/cable/app/assets/javascripts/application.js +15 -0
  17. data/example/rails/cable/app/assets/javascripts/cable.js +13 -0
  18. data/example/rails/cable/app/assets/javascripts/channels/.keep +0 -0
  19. data/example/rails/cable/app/assets/javascripts/chats.js +39 -0
  20. data/example/rails/cable/app/assets/javascripts/rooms.js +55 -0
  21. data/example/rails/cable/app/assets/stylesheets/application.css +16 -0
  22. data/example/rails/cable/app/assets/stylesheets/chatbox.scss +31 -0
  23. data/example/rails/cable/app/assets/stylesheets/peoplebox.scss +6 -0
  24. data/example/rails/cable/app/channels/application_cable/channel.rb +4 -0
  25. data/example/rails/cable/app/channels/application_cable/connection.rb +4 -0
  26. data/example/rails/cable/app/channels/rooms_texting_channel.rb +13 -0
  27. data/example/rails/cable/app/controllers/application_controller.rb +3 -0
  28. data/example/rails/cable/app/controllers/chats_controller.rb +18 -0
  29. data/example/rails/cable/app/controllers/concerns/.keep +0 -0
  30. data/example/rails/cable/app/controllers/pays_controller.rb +28 -0
  31. data/example/rails/cable/app/controllers/rooms_controller.rb +4 -0
  32. data/example/rails/cable/app/helpers/application_helper.rb +2 -0
  33. data/example/rails/cable/app/helpers/chats_helper.rb +2 -0
  34. data/example/rails/cable/app/helpers/rooms_helper.rb +5 -0
  35. data/example/rails/cable/app/jobs/application_job.rb +2 -0
  36. data/example/rails/cable/app/jobs/chat_broadcaster_job.rb +15 -0
  37. data/example/rails/cable/app/mailers/application_mailer.rb +4 -0
  38. data/example/rails/cable/app/models/application_record.rb +3 -0
  39. data/example/rails/cable/app/models/chat.rb +41 -0
  40. data/example/rails/cable/app/models/concerns/.keep +0 -0
  41. data/example/rails/cable/app/models/order.rb +2 -0
  42. data/example/rails/cable/app/models/user.rb +2 -0
  43. data/example/rails/cable/app/views/chats/_chat.html.erb +18 -0
  44. data/example/rails/cable/app/views/layouts/application.html.erb +19 -0
  45. data/example/rails/cable/app/views/layouts/mailer.html.erb +13 -0
  46. data/example/rails/cable/app/views/layouts/mailer.text.erb +1 -0
  47. data/example/rails/cable/app/views/rooms/_chatbox.html.erb +13 -0
  48. data/example/rails/cable/app/views/rooms/_online_people.html.erb +53 -0
  49. data/example/rails/cable/app/views/rooms/index.html.erb +9 -0
  50. data/example/rails/cable/bin/bundle +3 -0
  51. data/example/rails/cable/bin/rails +9 -0
  52. data/example/rails/cable/bin/rake +9 -0
  53. data/example/rails/cable/bin/setup +34 -0
  54. data/example/rails/cable/bin/spring +16 -0
  55. data/example/rails/cable/bin/update +29 -0
  56. data/example/rails/cable/config.ru +5 -0
  57. data/example/rails/cable/config/application.rb +16 -0
  58. data/example/rails/cable/config/boot.rb +3 -0
  59. data/example/rails/cable/config/cable.yml +9 -0
  60. data/example/rails/cable/config/database.yml +20 -0
  61. data/example/rails/cable/config/environment.rb +5 -0
  62. data/example/rails/cable/config/environments/development.rb +57 -0
  63. data/example/rails/cable/config/environments/production.rb +86 -0
  64. data/example/rails/cable/config/environments/test.rb +42 -0
  65. data/example/rails/cable/config/initializers/application_controller_renderer.rb +6 -0
  66. data/example/rails/cable/config/initializers/assets.rb +11 -0
  67. data/example/rails/cable/config/initializers/backtrace_silencers.rb +7 -0
  68. data/example/rails/cable/config/initializers/cookies_serializer.rb +5 -0
  69. data/example/rails/cable/config/initializers/filter_parameter_logging.rb +4 -0
  70. data/example/rails/cable/config/initializers/inflections.rb +16 -0
  71. data/example/rails/cable/config/initializers/mime_types.rb +4 -0
  72. data/example/rails/cable/config/initializers/new_framework_defaults.rb +24 -0
  73. data/example/rails/cable/config/initializers/session_store.rb +3 -0
  74. data/example/rails/cable/config/initializers/sidekiq.rb +2 -0
  75. data/example/rails/cable/config/initializers/veritrans.rb +46 -0
  76. data/example/rails/cable/config/initializers/wrap_parameters.rb +14 -0
  77. data/example/rails/cable/config/locales/en.yml +23 -0
  78. data/example/rails/cable/config/puma.rb +47 -0
  79. data/example/rails/cable/config/routes.rb +18 -0
  80. data/example/rails/cable/config/secrets.yml +22 -0
  81. data/example/rails/cable/config/spring.rb +6 -0
  82. data/example/rails/cable/config/veritrans.yml +13 -0
  83. data/example/rails/cable/db/development.sqlite3 +0 -0
  84. data/example/rails/cable/db/migrate/20161215070044_create_chats.rb +10 -0
  85. data/example/rails/cable/db/migrate/20161215072021_create_users.rb +10 -0
  86. data/example/rails/cable/db/migrate/20161219110219_create_orders.rb +11 -0
  87. data/example/rails/cable/db/schema.rb +37 -0
  88. data/example/rails/cable/db/seeds.rb +41 -0
  89. data/example/rails/cable/db/test.sqlite3 +0 -0
  90. data/example/rails/cable/lib/assets/.keep +0 -0
  91. data/example/rails/cable/lib/tasks/.keep +0 -0
  92. data/example/rails/cable/public/404.html +67 -0
  93. data/example/rails/cable/public/422.html +67 -0
  94. data/example/rails/cable/public/500.html +66 -0
  95. data/example/rails/cable/public/apple-touch-icon-precomposed.png +0 -0
  96. data/example/rails/cable/public/apple-touch-icon.png +0 -0
  97. data/example/rails/cable/public/favicon.ico +0 -0
  98. data/example/rails/cable/public/images/avatar1.jpg +0 -0
  99. data/example/rails/cable/public/images/avatar2.jpg +0 -0
  100. data/example/rails/cable/public/images/avatar3.jpg +0 -0
  101. data/example/rails/cable/public/images/avatar4.jpg +0 -0
  102. data/example/rails/cable/public/images/avatar5.jpg +0 -0
  103. data/example/rails/cable/public/images/avatar6.jpg +0 -0
  104. data/example/rails/cable/public/robots.txt +5 -0
  105. data/example/rails/cable/vendor/assets/javascripts/.keep +0 -0
  106. data/example/rails/cable/vendor/assets/stylesheets/.keep +0 -0
  107. data/example/rails/cable/vendor/assets/stylesheets/photon.css +2333 -0
  108. data/example/rails/simplepay/Gemfile +54 -0
  109. data/example/rails/simplepay/Gemfile.lock +178 -0
  110. data/example/rails/simplepay/README.md +30 -0
  111. data/example/rails/simplepay/Rakefile +6 -0
  112. data/example/rails/simplepay/app/assets/config/manifest.js +3 -0
  113. data/example/rails/simplepay/app/assets/images/.keep +0 -0
  114. data/example/rails/simplepay/app/assets/javascripts/application.js +16 -0
  115. data/example/rails/simplepay/app/assets/javascripts/cable.js +13 -0
  116. data/example/rails/simplepay/app/assets/javascripts/channels/.keep +0 -0
  117. data/example/rails/simplepay/app/assets/javascripts/pay.js +18 -0
  118. data/example/rails/simplepay/app/assets/stylesheets/application.css +15 -0
  119. data/example/rails/simplepay/app/assets/stylesheets/style.css +254 -0
  120. data/example/rails/simplepay/app/channels/application_cable/channel.rb +4 -0
  121. data/example/rails/simplepay/app/channels/application_cable/connection.rb +4 -0
  122. data/example/rails/simplepay/app/controllers/application_controller.rb +3 -0
  123. data/example/rails/simplepay/app/controllers/concerns/.keep +0 -0
  124. data/example/rails/simplepay/app/controllers/home_controller.rb +16 -0
  125. data/example/rails/simplepay/app/controllers/pay_controller.rb +10 -0
  126. data/example/rails/simplepay/app/helpers/application_helper.rb +2 -0
  127. data/example/rails/simplepay/app/helpers/pay_helper.rb +2 -0
  128. data/example/rails/simplepay/app/jobs/application_job.rb +2 -0
  129. data/example/rails/simplepay/app/mailers/application_mailer.rb +4 -0
  130. data/example/rails/simplepay/app/models/application_record.rb +3 -0
  131. data/example/rails/simplepay/app/models/concerns/.keep +0 -0
  132. data/example/rails/simplepay/app/models/order.rb +2 -0
  133. data/example/rails/simplepay/app/views/home/index.html.erb +19 -0
  134. data/example/rails/simplepay/app/views/layouts/application.html.erb +15 -0
  135. data/example/rails/simplepay/app/views/layouts/mailer.html.erb +13 -0
  136. data/example/rails/simplepay/app/views/layouts/mailer.text.erb +1 -0
  137. data/example/rails/simplepay/app/views/pay/notify.html.erb +2 -0
  138. data/example/rails/simplepay/bin/bundle +3 -0
  139. data/example/rails/simplepay/bin/rails +9 -0
  140. data/example/rails/simplepay/bin/rake +9 -0
  141. data/example/rails/simplepay/bin/setup +34 -0
  142. data/example/rails/simplepay/bin/spring +16 -0
  143. data/example/rails/simplepay/bin/update +29 -0
  144. data/example/rails/simplepay/config.ru +5 -0
  145. data/example/rails/simplepay/config/application.rb +15 -0
  146. data/example/rails/simplepay/config/boot.rb +3 -0
  147. data/example/rails/simplepay/config/cable.yml +9 -0
  148. data/example/rails/simplepay/config/database.yml +25 -0
  149. data/example/rails/simplepay/config/environment.rb +5 -0
  150. data/example/rails/simplepay/config/environments/development.rb +57 -0
  151. data/example/rails/simplepay/config/environments/production.rb +86 -0
  152. data/example/rails/simplepay/config/environments/test.rb +42 -0
  153. data/example/rails/simplepay/config/initializers/application_controller_renderer.rb +6 -0
  154. data/example/rails/simplepay/config/initializers/assets.rb +11 -0
  155. data/example/rails/simplepay/config/initializers/backtrace_silencers.rb +7 -0
  156. data/example/rails/simplepay/config/initializers/cookies_serializer.rb +5 -0
  157. data/example/rails/simplepay/config/initializers/filter_parameter_logging.rb +4 -0
  158. data/example/rails/simplepay/config/initializers/inflections.rb +16 -0
  159. data/example/rails/simplepay/config/initializers/mime_types.rb +4 -0
  160. data/example/rails/simplepay/config/initializers/new_framework_defaults.rb +24 -0
  161. data/example/rails/simplepay/config/initializers/session_store.rb +3 -0
  162. data/example/rails/simplepay/config/initializers/veritrans.rb +46 -0
  163. data/example/rails/simplepay/config/initializers/wrap_parameters.rb +14 -0
  164. data/example/rails/simplepay/config/locales/en.yml +23 -0
  165. data/example/rails/simplepay/config/puma.rb +47 -0
  166. data/example/rails/simplepay/config/routes.rb +5 -0
  167. data/example/rails/simplepay/config/secrets.yml +22 -0
  168. data/example/rails/simplepay/config/spring.rb +6 -0
  169. data/example/rails/simplepay/config/veritrans.yml +18 -0
  170. data/example/rails/simplepay/db/development.sqlite3 +0 -0
  171. data/example/rails/simplepay/db/migrate/20161221090855_create_orders.rb +10 -0
  172. data/example/rails/simplepay/db/schema.rb +22 -0
  173. data/example/rails/simplepay/db/seeds.rb +7 -0
  174. data/example/rails/simplepay/db/test.sqlite3 +0 -0
  175. data/example/rails/simplepay/lib/assets/.keep +0 -0
  176. data/example/rails/simplepay/lib/tasks/.keep +0 -0
  177. data/example/rails/simplepay/public/404.html +67 -0
  178. data/example/rails/simplepay/public/422.html +67 -0
  179. data/example/rails/simplepay/public/500.html +66 -0
  180. data/example/rails/simplepay/public/apple-touch-icon-precomposed.png +0 -0
  181. data/example/rails/simplepay/public/apple-touch-icon.png +0 -0
  182. data/example/rails/simplepay/public/favicon.ico +0 -0
  183. data/example/rails/simplepay/public/robots.txt +5 -0
  184. data/example/rails/simplepay/vendor/assets/javascripts/.keep +0 -0
  185. data/example/rails/simplepay/vendor/assets/stylesheets/.keep +0 -0
  186. data/example/{README.md → sinatra/README.md} +0 -0
  187. data/example/{config.ru → sinatra/config.ru} +3 -0
  188. data/example/{index.erb → sinatra/index.erb} +7 -6
  189. data/example/{localization.erb → sinatra/localization.erb} +6 -5
  190. data/example/{points.erb → sinatra/points.erb} +6 -5
  191. data/example/{recurring.erb → sinatra/recurring.erb} +6 -6
  192. data/example/{response.erb → sinatra/response.erb} +4 -1
  193. data/example/{sinatra.rb → sinatra/sinatra.rb} +9 -3
  194. data/example/{style.css → sinatra/style.css} +11 -0
  195. data/example/{veritrans.yml → sinatra/veritrans.yml} +2 -2
  196. data/example/{widget.erb → sinatra/widget.erb} +18 -6
  197. data/lib/generators/templates/assets/credit_card_form.js +6 -0
  198. data/lib/generators/templates/payments_controller.rb +4 -4
  199. data/lib/generators/templates/veritrans.yml +5 -5
  200. data/lib/generators/templates/views/_credit_card_form.erb +2 -2
  201. data/lib/generators/templates/views/_veritrans_include.erb +1 -1
  202. data/lib/generators/veritrans/install_generator.rb +1 -1
  203. data/lib/generators/veritrans/payment_form_generator.rb +1 -1
  204. data/lib/veritrans.rb +106 -5
  205. data/lib/veritrans/api.rb +7 -7
  206. data/lib/veritrans/cli.rb +11 -5
  207. data/lib/veritrans/client.rb +7 -4
  208. data/lib/veritrans/config.rb +5 -3
  209. data/lib/veritrans/events.rb +46 -35
  210. data/lib/veritrans/result.rb +58 -2
  211. data/lib/veritrans/testing.rb +156 -0
  212. data/lib/veritrans/version.rb +1 -1
  213. data/spec/cli_spec.rb +2 -2
  214. data/spec/fixtures/approve_failed.yml +1 -1
  215. data/spec/fixtures/cancel_failed.yml +1 -1
  216. data/spec/fixtures/cancel_success.yml +2 -2
  217. data/spec/fixtures/capture_failed.yml +1 -1
  218. data/spec/fixtures/charge.yml +2 -2
  219. data/spec/fixtures/charge_direct.yml +1 -1
  220. data/spec/fixtures/charge_vtweb.yml +2 -2
  221. data/spec/fixtures/cli_test_1111-not-exists.yml +1 -1
  222. data/spec/fixtures/cli_test_not_exists.yml +1 -1
  223. data/spec/fixtures/cli_test_real_txn.yml +1 -1
  224. data/spec/fixtures/cli_test_unauthorized.yml +1 -1
  225. data/spec/fixtures/events_test_real_txn.yml +1 -1
  226. data/spec/fixtures/expire_failed.yml +1 -1
  227. data/spec/fixtures/expire_success.yml +1 -1
  228. data/spec/fixtures/midtrans_status.yml +2 -2
  229. data/spec/fixtures/status_fail.yml +1 -1
  230. data/spec/fixtures/status_success.yml +2 -2
  231. data/spec/rails_plugin_spec.rb +37 -20
  232. data/spec/spec_helper.rb +0 -1
  233. data/spec/veritrans_client_spec.rb +1 -1
  234. data/spec/veritrans_config_spec.rb +1 -1
  235. data/spec/veritrans_events_spec.rb +6 -6
  236. data/spec/veritrans_testing_spec.rb +184 -0
  237. data/testing_webhooks.md +2 -2
  238. data/veritrans.gemspec +1 -1
  239. metadata +195 -16
  240. data/lib/veritrans/core_extensions.rb +0 -32
@@ -1,7 +1,7 @@
1
1
  # API Reference
2
2
 
3
3
  Here is only reference for API of this gem, to see complete information
4
- please use our [documentation](http://docs.veritrans.co.id/en/api/introduction.html)
4
+ please use our [documentation](https://api-docs.midtrans.com/)
5
5
 
6
6
 
7
7
  <table>
@@ -19,37 +19,37 @@ please use our [documentation](http://docs.veritrans.co.id/en/api/introduction.h
19
19
  <td><a href="#charge">Veritrans.charge(data)</a></td>
20
20
  <td>Charge Transaction</td>
21
21
  <td>POST</td>
22
- <td>api.veritrans.co.id/v2/charge</td>
22
+ <td>api.midtrans.com/v2/charge</td>
23
23
  </tr>
24
24
  <tr>
25
25
  <td><a href="#status">Veritrans.status(id)</a></td>
26
26
  <td>Get Last Status</td>
27
27
  <td>GET</td>
28
- <td>api.veritrans.co.id/v2/{id}/status</td>
28
+ <td>api.midtrans.com/v2/{id}/status</td>
29
29
  </tr>
30
30
  <tr>
31
31
  <td><a href="#cancel">Veritrans.cancel(id)</a></td>
32
32
  <td>Cancel Transaction</td>
33
33
  <td>POST</td>
34
- <td>api.veritrans.co.id/v2/{id}/cancel</td>
34
+ <td>api.midtrans.com/v2/{id}/cancel</td>
35
35
  </tr>
36
36
  <tr>
37
37
  <td><a href="#approve">Veritrans.approve(id)</a></td>
38
38
  <td>Approve Challenge Transaction</td>
39
39
  <td>POST</td>
40
- <td>api.veritrans.co.id/v2/{id}/approve</td>
40
+ <td>api.midtrans.com/v2/{id}/approve</td>
41
41
  </tr>
42
42
  <tr>
43
43
  <td><a href="#capture">Veritrans.capture(id)</a></td>
44
44
  <td>Capture Authorise Transaction</td>
45
45
  <td>POST</td>
46
- <td>api.veritrans.co.id/v2/{id}/capture</td>
46
+ <td>api.midtrans.com/v2/{id}/capture</td>
47
47
  </tr>
48
48
  <tr>
49
49
  <td><a href="#expire">Veritrans.expire(id)</a></td>
50
50
  <td>Expire Pending Transaction</td>
51
51
  <td>POST</td>
52
- <td>api.veritrans.co.id/v2/{id}/expire</td>
52
+ <td>api.midtrans.com/v2/{id}/expire</td>
53
53
  </tr>
54
54
  </tbody>
55
55
  </table>
@@ -76,7 +76,7 @@ q.class # => Veritrans::Result
76
76
  q.data == {
77
77
  status_code: "201",
78
78
  status_message: "OK, success do VTWeb transaction, please go to redirect_url",
79
- redirect_url: "https://vtweb.sandbox.veritrans.co.id/v2/vtweb/b27d421f-90ff-4427-83d2-fbe8acbbce89"
79
+ redirect_url: "https://vtweb.sandbox.midtrans.com/v2/vtweb/b27d421f-90ff-4427-83d2-fbe8acbbce89"
80
80
  }
81
81
  ```
82
82
 
@@ -109,7 +109,7 @@ q = Veritrans.charge({
109
109
  customer_details: {
110
110
  first_name: "Nadia",
111
111
  last_name: "Modjo",
112
- email: "noreply@veritrans.co.id",
112
+ email: "noreply@midtrans.com",
113
113
  phone: "+6281 123 12345",
114
114
  billing_address: {
115
115
  address: "Jalan Raya Kalijati",
@@ -253,7 +253,7 @@ result.class # => Veritrans::Result
253
253
 
254
254
  * `Veritrans::Result#success?` - `boolean`, base on `status_code` field in json
255
255
  * `Veritrans::Result#created?` - `boolean`, for VT-Link
256
- * `Veritrans::Result#status_code` - `integer`, e.g. 200, 402. Documentation http://docs.veritrans.co.id/en/api/status_code.html
256
+ * `Veritrans::Result#status_code` - `integer`, e.g. 200, 402. Documentation https://api-docs.midtrans.com/#status-code
257
257
  * `Veritrans::Result#status_message` - `string`, e.g. "OK, success do VTWeb transaction, please go to redirect_url"
258
258
  * `Veritrans::Result#redirect_url` - `string`, redirect URL for VT-Web and VT-Link
259
259
  * `Veritrans::Result#body` - `string`, raw HTTP request body
@@ -0,0 +1,48 @@
1
+ source 'https://rubygems.org'
2
+
3
+
4
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
5
+ gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
6
+ # Use sqlite3 as the database for Active Record
7
+ gem 'mysql2'
8
+ # Use Puma as the app server
9
+ gem 'puma', '~> 3.0'
10
+ # Use SCSS for stylesheets
11
+ gem 'sass-rails', '~> 5.0'
12
+ # Use Uglifier as compressor for JavaScript assets
13
+ gem 'uglifier', '>= 1.3.0'
14
+ # Use CoffeeScript for .coffee assets and views
15
+ gem 'coffee-rails', '~> 4.2'
16
+ # See https://github.com/rails/execjs#readme for more supported runtimes
17
+ # gem 'therubyracer', platforms: :ruby
18
+ gem 'sidekiq'
19
+ gem 'veritrans', '~> 2'
20
+
21
+ # Use jquery as the JavaScript library
22
+ gem 'jquery-rails'
23
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
24
+ gem 'jbuilder', '~> 2.5'
25
+ # Use Redis adapter to run Action Cable in production
26
+ # gem 'redis', '~> 3.0'
27
+ # Use ActiveModel has_secure_password
28
+ # gem 'bcrypt', '~> 3.1.7'
29
+
30
+ # Use Capistrano for deployment
31
+ # gem 'capistrano-rails', group: :development
32
+
33
+ group :development, :test do
34
+ # Call 'byebug' anywhere in the code to stop execution and get a debugger console
35
+ gem 'byebug', platform: :mri
36
+ end
37
+
38
+ group :development do
39
+ # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
40
+ gem 'web-console'
41
+ gem 'listen', '~> 3.0.5'
42
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
43
+ gem 'spring'
44
+ gem 'spring-watcher-listen', '~> 2.0.0'
45
+ end
46
+
47
+ # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
48
+ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
@@ -0,0 +1,184 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ actioncable (5.0.0.1)
5
+ actionpack (= 5.0.0.1)
6
+ nio4r (~> 1.2)
7
+ websocket-driver (~> 0.6.1)
8
+ actionmailer (5.0.0.1)
9
+ actionpack (= 5.0.0.1)
10
+ actionview (= 5.0.0.1)
11
+ activejob (= 5.0.0.1)
12
+ mail (~> 2.5, >= 2.5.4)
13
+ rails-dom-testing (~> 2.0)
14
+ actionpack (5.0.0.1)
15
+ actionview (= 5.0.0.1)
16
+ activesupport (= 5.0.0.1)
17
+ rack (~> 2.0)
18
+ rack-test (~> 0.6.3)
19
+ rails-dom-testing (~> 2.0)
20
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
21
+ actionview (5.0.0.1)
22
+ activesupport (= 5.0.0.1)
23
+ builder (~> 3.1)
24
+ erubis (~> 2.7.0)
25
+ rails-dom-testing (~> 2.0)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
+ activejob (5.0.0.1)
28
+ activesupport (= 5.0.0.1)
29
+ globalid (>= 0.3.6)
30
+ activemodel (5.0.0.1)
31
+ activesupport (= 5.0.0.1)
32
+ activerecord (5.0.0.1)
33
+ activemodel (= 5.0.0.1)
34
+ activesupport (= 5.0.0.1)
35
+ arel (~> 7.0)
36
+ activesupport (5.0.0.1)
37
+ concurrent-ruby (~> 1.0, >= 1.0.2)
38
+ i18n (~> 0.7)
39
+ minitest (~> 5.1)
40
+ tzinfo (~> 1.1)
41
+ arel (7.1.4)
42
+ builder (3.2.2)
43
+ byebug (9.0.6)
44
+ coffee-rails (4.2.1)
45
+ coffee-script (>= 2.2.0)
46
+ railties (>= 4.0.0, < 5.2.x)
47
+ coffee-script (2.4.1)
48
+ coffee-script-source
49
+ execjs
50
+ coffee-script-source (1.11.1)
51
+ concurrent-ruby (1.0.2)
52
+ connection_pool (2.2.1)
53
+ debug_inspector (0.0.2)
54
+ erubis (2.7.0)
55
+ excon (0.54.0)
56
+ execjs (2.7.0)
57
+ ffi (1.9.14)
58
+ globalid (0.3.7)
59
+ activesupport (>= 4.1.0)
60
+ i18n (0.7.0)
61
+ jbuilder (2.6.1)
62
+ activesupport (>= 3.0.0, < 5.1)
63
+ multi_json (~> 1.2)
64
+ jquery-rails (4.2.1)
65
+ rails-dom-testing (>= 1, < 3)
66
+ railties (>= 4.2.0)
67
+ thor (>= 0.14, < 2.0)
68
+ listen (3.0.8)
69
+ rb-fsevent (~> 0.9, >= 0.9.4)
70
+ rb-inotify (~> 0.9, >= 0.9.7)
71
+ loofah (2.0.3)
72
+ nokogiri (>= 1.5.9)
73
+ mail (2.6.4)
74
+ mime-types (>= 1.16, < 4)
75
+ method_source (0.8.2)
76
+ mime-types (3.1)
77
+ mime-types-data (~> 3.2015)
78
+ mime-types-data (3.2016.0521)
79
+ mini_portile2 (2.1.0)
80
+ minitest (5.10.1)
81
+ multi_json (1.12.1)
82
+ mysql2 (0.4.4)
83
+ nio4r (1.2.1)
84
+ nokogiri (1.6.8.1)
85
+ mini_portile2 (~> 2.1.0)
86
+ puma (3.6.2)
87
+ rack (2.0.1)
88
+ rack-protection (1.5.3)
89
+ rack
90
+ rack-test (0.6.3)
91
+ rack (>= 1.0)
92
+ rails (5.0.0.1)
93
+ actioncable (= 5.0.0.1)
94
+ actionmailer (= 5.0.0.1)
95
+ actionpack (= 5.0.0.1)
96
+ actionview (= 5.0.0.1)
97
+ activejob (= 5.0.0.1)
98
+ activemodel (= 5.0.0.1)
99
+ activerecord (= 5.0.0.1)
100
+ activesupport (= 5.0.0.1)
101
+ bundler (>= 1.3.0, < 2.0)
102
+ railties (= 5.0.0.1)
103
+ sprockets-rails (>= 2.0.0)
104
+ rails-dom-testing (2.0.1)
105
+ activesupport (>= 4.2.0, < 6.0)
106
+ nokogiri (~> 1.6.0)
107
+ rails-html-sanitizer (1.0.3)
108
+ loofah (~> 2.0)
109
+ railties (5.0.0.1)
110
+ actionpack (= 5.0.0.1)
111
+ activesupport (= 5.0.0.1)
112
+ method_source
113
+ rake (>= 0.8.7)
114
+ thor (>= 0.18.1, < 2.0)
115
+ rake (12.0.0)
116
+ rb-fsevent (0.9.8)
117
+ rb-inotify (0.9.7)
118
+ ffi (>= 0.5.0)
119
+ redis (3.3.2)
120
+ sass (3.4.22)
121
+ sass-rails (5.0.6)
122
+ railties (>= 4.0.0, < 6)
123
+ sass (~> 3.1)
124
+ sprockets (>= 2.8, < 4.0)
125
+ sprockets-rails (>= 2.0, < 4.0)
126
+ tilt (>= 1.1, < 3)
127
+ sidekiq (4.2.7)
128
+ concurrent-ruby (~> 1.0)
129
+ connection_pool (~> 2.2, >= 2.2.0)
130
+ rack-protection (>= 1.5.0)
131
+ redis (~> 3.2, >= 3.2.1)
132
+ spring (2.0.0)
133
+ activesupport (>= 4.2)
134
+ spring-watcher-listen (2.0.1)
135
+ listen (>= 2.7, < 4.0)
136
+ spring (>= 1.2, < 3.0)
137
+ sprockets (3.7.0)
138
+ concurrent-ruby (~> 1.0)
139
+ rack (> 1, < 3)
140
+ sprockets-rails (3.2.0)
141
+ actionpack (>= 4.0)
142
+ activesupport (>= 4.0)
143
+ sprockets (>= 3.0.0)
144
+ thor (0.19.4)
145
+ thread_safe (0.3.5)
146
+ tilt (2.0.5)
147
+ tzinfo (1.2.2)
148
+ thread_safe (~> 0.1)
149
+ uglifier (3.0.4)
150
+ execjs (>= 0.3.0, < 3)
151
+ veritrans (2.1.3)
152
+ excon (~> 0.20)
153
+ web-console (3.4.0)
154
+ actionview (>= 5.0)
155
+ activemodel (>= 5.0)
156
+ debug_inspector
157
+ railties (>= 5.0)
158
+ websocket-driver (0.6.4)
159
+ websocket-extensions (>= 0.1.0)
160
+ websocket-extensions (0.1.2)
161
+
162
+ PLATFORMS
163
+ ruby
164
+
165
+ DEPENDENCIES
166
+ byebug
167
+ coffee-rails (~> 4.2)
168
+ jbuilder (~> 2.5)
169
+ jquery-rails
170
+ listen (~> 3.0.5)
171
+ mysql2
172
+ puma (~> 3.0)
173
+ rails (~> 5.0.0, >= 5.0.0.1)
174
+ sass-rails (~> 5.0)
175
+ sidekiq
176
+ spring
177
+ spring-watcher-listen (~> 2.0.0)
178
+ tzinfo-data
179
+ uglifier (>= 1.3.0)
180
+ veritrans (~> 2)
181
+ web-console
182
+
183
+ BUNDLED WITH
184
+ 1.13.6
@@ -0,0 +1,29 @@
1
+ # Cable: Slack on Rails
2
+
3
+ 1. To demonstrate Ruby language
4
+ 2. To demonstrate the use of Midtrans library's SNAP in handling payment
5
+ 3. To demonstrate ActionCable, ActiveRecords and Rails in general
6
+
7
+ Feel free to fork, copy, modify, etc.
8
+
9
+ ## Setting up procedures
10
+
11
+ 1. Install Ruby, Bundler, Ruby on Rails, Redis, and MySQL database.
12
+ 2. Clone the repository
13
+ 3. Run `bundle install` on the root folder of the cloned project
14
+ 4. If your MySQL configuration is standard, you can directly run `rake db:create db:migrate`. Otherwise edit `config/database.yml` and then run the same command.
15
+ 5. Run `rake db:seed` to initialise the database state with some data.
16
+ 6. Run `rails s` to start the web server. By default the system is served at `http://localhost:3000`
17
+ 7. Run `bundle exec sidekiq` to run the sidekiq background job processor that process incoming chat message and properly broadcast them.
18
+
19
+ ## How to make payment
20
+
21
+ Each payment link ("Beli") appear on a message that contains a pattern in the form of:
22
+
23
+ > (some text if any) jual (item name) (comma) (item price)
24
+
25
+ Example of texts that will create the "Beli" link:
26
+
27
+ 1. Jual buku, 50.000
28
+ 2. Nih gue jual stick PS, 50.000
29
+ 3. Gue jual stick PS, 50.000; memory card, 200.000
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative 'config/application'
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the rails generate channel command.
3
+ //
4
+ //= require action_cable
5
+ //= require_self
6
+ //= require_tree ./channels
7
+
8
+ (function() {
9
+ this.App || (this.App = {});
10
+
11
+ App.cable = ActionCable.createConsumer();
12
+
13
+ }).call(this);
@@ -0,0 +1,39 @@
1
+ function snapTokenGeneratorOnClickFor(elementQualifier) {
2
+ $(document).on("click", elementQualifier, function(event) {
3
+ var element = jQuery(this);
4
+ var chatId = element.data("chat-id");
5
+ var token = element.data("token");
6
+
7
+ if (token == "" || token == undefined) {
8
+ $.ajax({
9
+ url: '/chats/' + chatId + '/generate_checkout_token',
10
+ data: {},
11
+ success: function(data) {
12
+ var token = data.token;
13
+ element.data('token', token);
14
+ showSnapDialog(element);
15
+ }
16
+ });
17
+ } else { showSnapDialog(element); }
18
+ });
19
+ }
20
+
21
+ function showSnapDialog(element) {
22
+ var token = element.data("token");
23
+ console.log(token);
24
+ snap.pay(token, {
25
+ onSuccess: function(res) {
26
+
27
+ },
28
+ onPending: function(res) {
29
+
30
+ },
31
+ onError: function(res) {
32
+
33
+ }
34
+ });
35
+ }
36
+
37
+ jQuery(document).ready(function() {
38
+ snapTokenGeneratorOnClickFor('.buy-chat-items');
39
+ })
@@ -0,0 +1,55 @@
1
+ function makeSubscription() {
2
+ App.globalChat = App.cable.subscriptions.create({
3
+ channel: 'RoomsTextingChannel',
4
+ }, {
5
+ connected: function() {},
6
+
7
+ disconnected: function() {},
8
+
9
+ received: function(data) {
10
+ jQuery('.chats').append(data.chat);
11
+ scrollToBottom(jQuery('.chats'));
12
+ },
13
+
14
+ sendMessage: function(message) {
15
+ return this.perform('send_message', {
16
+ message: message,
17
+ });
18
+ }
19
+ });
20
+ }
21
+
22
+ function makeFormSubmitCallback(form) {
23
+ var messageTextArea = form.find('#chat-input-text');
24
+ messageTextArea.on('keypress', function(e) {
25
+ if (e.keyCode == 13) {
26
+ e.preventDefault();
27
+ form.submit();
28
+ }
29
+ });
30
+
31
+ form.submit(function(e) {
32
+ e.preventDefault();
33
+
34
+ var messageText = messageTextArea.val();
35
+ // tidak boleh mengirim text kosong
36
+ if (jQuery.trim(messageText).length > 1) {
37
+ App.globalChat.sendMessage(messageTextArea.val());
38
+ messageTextArea.val('');
39
+ } else {
40
+ console.error("Blank message, cannot send it");
41
+ }
42
+
43
+ return false;
44
+ });
45
+ }
46
+
47
+ function scrollToBottom(element) {
48
+ element.scrollTop(element.prop('scrollHeight'));
49
+ }
50
+
51
+ jQuery(document).ready(function() {
52
+ makeSubscription();
53
+ makeFormSubmitCallback(jQuery('#new_chat'));
54
+ scrollToBottom(jQuery('.chats'));
55
+ })