veritrans 2.0.4 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.travis.yml +11 -3
  4. data/CHANGELOG.md +15 -0
  5. data/Gemfile +10 -0
  6. data/Gemfile.lock +136 -97
  7. data/Procfile +1 -0
  8. data/README.md +12 -5
  9. data/Rakefile +7 -5
  10. data/api_reference.md +21 -1
  11. data/example/README.md +8 -0
  12. data/example/config.ru +6 -0
  13. data/example/index.erb +104 -9
  14. data/example/localization.erb +248 -0
  15. data/example/points.erb +187 -0
  16. data/example/recurring.erb +201 -0
  17. data/example/response.erb +10 -1
  18. data/example/sinatra.rb +120 -8
  19. data/example/style.css +83 -2
  20. data/example/veritrans.yml +0 -1
  21. data/example/widget.erb +52 -0
  22. data/lib/generators/templates/assets/credit_card_form.js +3 -2
  23. data/lib/generators/templates/payments_controller.rb +5 -0
  24. data/lib/generators/templates/veritrans.rb +20 -17
  25. data/lib/generators/veritrans/install_generator.rb +1 -1
  26. data/lib/generators/veritrans/payment_form_generator.rb +1 -1
  27. data/lib/veritrans.rb +73 -44
  28. data/lib/veritrans/api.rb +39 -5
  29. data/lib/veritrans/cli.rb +1 -1
  30. data/lib/veritrans/client.rb +15 -10
  31. data/lib/veritrans/config.rb +11 -4
  32. data/lib/veritrans/events.rb +4 -4
  33. data/lib/veritrans/result.rb +28 -7
  34. data/lib/veritrans/version.rb +2 -2
  35. data/spec/cli_spec.rb +1 -0
  36. data/spec/rails_plugin_spec.rb +72 -27
  37. data/spec/spec_helper.rb +1 -0
  38. data/spec/veritrans_client_spec.rb +57 -3
  39. data/spec/veritrans_config_spec.rb +1 -1
  40. data/spec/veritrans_events_spec.rb +2 -0
  41. data/spec/veritrans_snap_spec.rb +39 -0
  42. data/testing_webhooks.md +0 -2
  43. data/veritrans.gemspec +5 -5
  44. metadata +29 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c82962a7ae8c6e0cd05dd1f71ad62168d9bce06
4
- data.tar.gz: 8eebb1f2a1a600177b130c488548d722cf4adec0
3
+ metadata.gz: b793647405fbf0445648ea2ea9def74ed8396c0a
4
+ data.tar.gz: d40b25e0abe559a4d2a2314d3b46ef8efefa97df
5
5
  SHA512:
6
- metadata.gz: a80453ff8b48a43fa466500f51e91f4fccbe0a0fc1e572b0219b8fcee3bfd9b4d25ffbe719dfecf06862f341c956d1d6c35b92abecfc81e0cdc99281122dc8ed
7
- data.tar.gz: dae263f5c272b89bb291af5c315ea8de61b34134a3a99df66b13458dae44324e42d4044a33ae202c9ab4a50446c6ab958cca742a2fd31e1febd855d28c70384a
6
+ metadata.gz: 17c8354877faa0b5e75df829c59fdd2a8e2c05a3256d07d710589338a157c8b03f64410e36b4f51b6eb2f5a25aa600b12ff5f7c33204f849852a9008ce4be846
7
+ data.tar.gz: cf8a7fa7afcc7082c23cf8f6ac4db13f0a48dc92d9b5a15d86bcce36b23bac9903f3b33052e79161c9551027ca47876f2087068bfb032e0be1eea59f4fd47286
data/.gitignore CHANGED
@@ -2,4 +2,5 @@ coverage
2
2
  rails_example*
3
3
  .DS_Store
4
4
  tmp
5
- doc/
5
+ doc/
6
+ veritrans_credentials
@@ -1,5 +1,13 @@
1
+ language: ruby
2
+ cache: bundler
3
+ env:
4
+ - DEBUG=1
5
+
6
+ before_install:
7
+ - gem install bundler -v '~> 1.11'
8
+
1
9
  script: "bundle exec rspec"
10
+
2
11
  rvm:
3
- - 2.0.0
4
- - 2.1.5
5
- - 2.2.0
12
+ - 2.2.4
13
+ - 2.3.1
@@ -1,3 +1,18 @@
1
+ ### Version 2.1.0 (date 12 Aug 2016)
2
+
3
+ * Add support for rails 5
4
+ * Add Snap API and example
5
+ * Add support to create multiple instance of client
6
+ * Increase timeout to 120 seconds
7
+ * Fix network exception handling
8
+ * Add missing require 'logger'
9
+ * Add validation for payment_id argument
10
+ * Improve VT-Web example
11
+ * Add example for recurring (1 clck / 2 click)
12
+ * Add example for Indonesian validation messages
13
+ * Add Credit Card Points example
14
+ * Deploy example in heroku
15
+
1
16
  ### Version 2.0.4 (date: 30 Nov 2015)
2
17
 
3
18
  * Show warning when can not find section in veritrans.yml
data/Gemfile CHANGED
@@ -1,3 +1,13 @@
1
1
  source "https://rubygems.org"
2
2
 
3
+ gem 'rake'
4
+ gem 'rspec'
5
+
6
+ gem 'rails', '< 6'
7
+ # For example app
8
+ gem 'sinatra', github: 'sinatra/sinatra'
9
+ gem 'rack-protection', github: 'sinatra/rack-protection'
10
+ gem 'puma'
11
+ gem 'tilt'
12
+
3
13
  gemspec
@@ -1,138 +1,169 @@
1
+ GIT
2
+ remote: git://github.com/sinatra/rack-protection.git
3
+ revision: 7e723a74763bb83989d1249cdceb9cceb2ee6f01
4
+ specs:
5
+ rack-protection (2.0.0)
6
+ rack
7
+
8
+ GIT
9
+ remote: git://github.com/sinatra/sinatra.git
10
+ revision: 285275b42fa1bf096a5c9559b6cead2f31b65b66
11
+ specs:
12
+ sinatra (2.0.0.pre.alpha)
13
+ mustermann (~> 0.4)
14
+ rack (~> 2.0)
15
+ rack-protection (~> 2.0)
16
+ tilt (~> 2.0)
17
+
1
18
  PATH
2
19
  remote: .
3
20
  specs:
4
- veritrans (2.0.3)
21
+ veritrans (2.0.4)
5
22
  excon (~> 0.20)
6
23
 
7
24
  GEM
8
25
  remote: https://rubygems.org/
9
26
  specs:
10
- actionmailer (4.2.0)
11
- actionpack (= 4.2.0)
12
- actionview (= 4.2.0)
13
- activejob (= 4.2.0)
27
+ actioncable (5.0.0.1)
28
+ actionpack (= 5.0.0.1)
29
+ nio4r (~> 1.2)
30
+ websocket-driver (~> 0.6.1)
31
+ actionmailer (5.0.0.1)
32
+ actionpack (= 5.0.0.1)
33
+ actionview (= 5.0.0.1)
34
+ activejob (= 5.0.0.1)
14
35
  mail (~> 2.5, >= 2.5.4)
15
- rails-dom-testing (~> 1.0, >= 1.0.5)
16
- actionpack (4.2.0)
17
- actionview (= 4.2.0)
18
- activesupport (= 4.2.0)
19
- rack (~> 1.6.0)
20
- rack-test (~> 0.6.2)
21
- rails-dom-testing (~> 1.0, >= 1.0.5)
22
- rails-html-sanitizer (~> 1.0, >= 1.0.1)
23
- actionview (4.2.0)
24
- activesupport (= 4.2.0)
36
+ rails-dom-testing (~> 2.0)
37
+ actionpack (5.0.0.1)
38
+ actionview (= 5.0.0.1)
39
+ activesupport (= 5.0.0.1)
40
+ rack (~> 2.0)
41
+ rack-test (~> 0.6.3)
42
+ rails-dom-testing (~> 2.0)
43
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
44
+ actionview (5.0.0.1)
45
+ activesupport (= 5.0.0.1)
25
46
  builder (~> 3.1)
26
47
  erubis (~> 2.7.0)
27
- rails-dom-testing (~> 1.0, >= 1.0.5)
28
- rails-html-sanitizer (~> 1.0, >= 1.0.1)
29
- activejob (4.2.0)
30
- activesupport (= 4.2.0)
31
- globalid (>= 0.3.0)
32
- activemodel (4.2.0)
33
- activesupport (= 4.2.0)
34
- builder (~> 3.1)
35
- activerecord (4.2.0)
36
- activemodel (= 4.2.0)
37
- activesupport (= 4.2.0)
38
- arel (~> 6.0)
39
- activesupport (4.2.0)
48
+ rails-dom-testing (~> 2.0)
49
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
50
+ activejob (5.0.0.1)
51
+ activesupport (= 5.0.0.1)
52
+ globalid (>= 0.3.6)
53
+ activemodel (5.0.0.1)
54
+ activesupport (= 5.0.0.1)
55
+ activerecord (5.0.0.1)
56
+ activemodel (= 5.0.0.1)
57
+ activesupport (= 5.0.0.1)
58
+ arel (~> 7.0)
59
+ activesupport (5.0.0.1)
60
+ concurrent-ruby (~> 1.0, >= 1.0.2)
40
61
  i18n (~> 0.7)
41
- json (~> 1.7, >= 1.7.7)
42
62
  minitest (~> 5.1)
43
- thread_safe (~> 0.3, >= 0.3.4)
44
63
  tzinfo (~> 1.1)
45
- addressable (2.3.7)
46
- arel (6.0.0)
64
+ addressable (2.4.0)
65
+ arel (7.1.1)
47
66
  builder (3.2.2)
48
- capybara (2.4.4)
67
+ capybara (2.7.1)
68
+ addressable
49
69
  mime-types (>= 1.16)
50
70
  nokogiri (>= 1.3.3)
51
71
  rack (>= 1.0.0)
52
72
  rack-test (>= 0.5.4)
53
73
  xpath (~> 2.0)
54
74
  cliver (0.3.2)
55
- crack (0.4.2)
75
+ concurrent-ruby (1.0.2)
76
+ crack (0.4.3)
56
77
  safe_yaml (~> 1.0.0)
57
78
  diff-lcs (1.2.5)
58
79
  erubis (2.7.0)
59
- excon (0.45.3)
60
- globalid (0.3.3)
80
+ excon (0.51.0)
81
+ globalid (0.3.7)
61
82
  activesupport (>= 4.1.0)
62
- hike (1.2.3)
83
+ hashdiff (0.3.0)
63
84
  i18n (0.7.0)
64
- json (1.8.2)
65
- loofah (2.0.1)
85
+ loofah (2.0.3)
66
86
  nokogiri (>= 1.5.9)
67
- mail (2.6.3)
68
- mime-types (>= 1.16, < 3)
69
- mime-types (2.4.3)
70
- mini_portile (0.6.2)
71
- minitest (5.5.1)
72
- multi_json (1.10.1)
73
- nokogiri (1.6.6.2)
74
- mini_portile (~> 0.6.0)
75
- poltergeist (1.6.0)
87
+ mail (2.6.4)
88
+ mime-types (>= 1.16, < 4)
89
+ method_source (0.8.2)
90
+ mime-types (3.1)
91
+ mime-types-data (~> 3.2015)
92
+ mime-types-data (3.2016.0521)
93
+ mini_portile2 (2.1.0)
94
+ minitest (5.9.0)
95
+ mustermann (0.4.0)
96
+ tool (~> 0.2)
97
+ nio4r (1.2.1)
98
+ nokogiri (1.6.8)
99
+ mini_portile2 (~> 2.1.0)
100
+ pkg-config (~> 1.1.7)
101
+ pkg-config (1.1.7)
102
+ poltergeist (1.10.0)
76
103
  capybara (~> 2.1)
77
104
  cliver (~> 0.3.1)
78
- multi_json (~> 1.0)
79
105
  websocket-driver (>= 0.2.0)
80
- rack (1.6.0)
106
+ puma (3.6.0)
107
+ rack (2.0.1)
81
108
  rack-test (0.6.3)
82
109
  rack (>= 1.0)
83
- rails (4.2.0)
84
- actionmailer (= 4.2.0)
85
- actionpack (= 4.2.0)
86
- actionview (= 4.2.0)
87
- activejob (= 4.2.0)
88
- activemodel (= 4.2.0)
89
- activerecord (= 4.2.0)
90
- activesupport (= 4.2.0)
110
+ rails (5.0.0.1)
111
+ actioncable (= 5.0.0.1)
112
+ actionmailer (= 5.0.0.1)
113
+ actionpack (= 5.0.0.1)
114
+ actionview (= 5.0.0.1)
115
+ activejob (= 5.0.0.1)
116
+ activemodel (= 5.0.0.1)
117
+ activerecord (= 5.0.0.1)
118
+ activesupport (= 5.0.0.1)
91
119
  bundler (>= 1.3.0, < 2.0)
92
- railties (= 4.2.0)
93
- sprockets-rails
94
- rails-deprecated_sanitizer (1.0.3)
95
- activesupport (>= 4.2.0.alpha)
96
- rails-dom-testing (1.0.5)
97
- activesupport (>= 4.2.0.beta, < 5.0)
120
+ railties (= 5.0.0.1)
121
+ sprockets-rails (>= 2.0.0)
122
+ rails-dom-testing (2.0.1)
123
+ activesupport (>= 4.2.0, < 6.0)
98
124
  nokogiri (~> 1.6.0)
99
- rails-deprecated_sanitizer (>= 1.0.1)
100
- rails-html-sanitizer (1.0.1)
125
+ rails-html-sanitizer (1.0.3)
101
126
  loofah (~> 2.0)
102
- railties (4.2.0)
103
- actionpack (= 4.2.0)
104
- activesupport (= 4.2.0)
127
+ railties (5.0.0.1)
128
+ actionpack (= 5.0.0.1)
129
+ activesupport (= 5.0.0.1)
130
+ method_source
105
131
  rake (>= 0.8.7)
106
132
  thor (>= 0.18.1, < 2.0)
107
- rake (10.4.2)
108
- rspec (2.14.1)
109
- rspec-core (~> 2.14.0)
110
- rspec-expectations (~> 2.14.0)
111
- rspec-mocks (~> 2.14.0)
112
- rspec-core (2.14.8)
113
- rspec-expectations (2.14.5)
114
- diff-lcs (>= 1.1.3, < 2.0)
115
- rspec-mocks (2.14.6)
133
+ rake (11.2.2)
134
+ rspec (3.5.0)
135
+ rspec-core (~> 3.5.0)
136
+ rspec-expectations (~> 3.5.0)
137
+ rspec-mocks (~> 3.5.0)
138
+ rspec-core (3.5.2)
139
+ rspec-support (~> 3.5.0)
140
+ rspec-expectations (3.5.0)
141
+ diff-lcs (>= 1.2.0, < 2.0)
142
+ rspec-support (~> 3.5.0)
143
+ rspec-mocks (3.5.0)
144
+ diff-lcs (>= 1.2.0, < 2.0)
145
+ rspec-support (~> 3.5.0)
146
+ rspec-support (3.5.0)
116
147
  safe_yaml (1.0.4)
117
- sprockets (2.12.3)
118
- hike (~> 1.2)
119
- multi_json (~> 1.0)
120
- rack (~> 1.0)
121
- tilt (~> 1.1, != 1.3.0)
122
- sprockets-rails (2.2.4)
123
- actionpack (>= 3.0)
124
- activesupport (>= 3.0)
125
- sprockets (>= 2.8, < 4.0)
148
+ sprockets (3.7.0)
149
+ concurrent-ruby (~> 1.0)
150
+ rack (> 1, < 3)
151
+ sprockets-rails (3.1.1)
152
+ actionpack (>= 4.0)
153
+ activesupport (>= 4.0)
154
+ sprockets (>= 3.0.0)
126
155
  thor (0.19.1)
127
- thread_safe (0.3.4)
128
- tilt (1.4.1)
156
+ thread_safe (0.3.5)
157
+ tilt (2.0.5)
158
+ tool (0.2.3)
129
159
  tzinfo (1.2.2)
130
160
  thread_safe (~> 0.1)
131
- vcr (2.9.3)
132
- webmock (1.20.4)
161
+ vcr (3.0.3)
162
+ webmock (2.1.0)
133
163
  addressable (>= 2.3.6)
134
164
  crack (>= 0.3.2)
135
- websocket-driver (0.5.2)
165
+ hashdiff
166
+ websocket-driver (0.6.4)
136
167
  websocket-extensions (>= 0.1.0)
137
168
  websocket-extensions (0.1.2)
138
169
  xpath (2.0.0)
@@ -142,9 +173,17 @@ PLATFORMS
142
173
  ruby
143
174
 
144
175
  DEPENDENCIES
145
- poltergeist (~> 1.6)
146
- rails (~> 4.2)
147
- rspec (~> 2.14)
148
- vcr (~> 2.9)
176
+ poltergeist (~> 1.8)
177
+ puma
178
+ rack-protection!
179
+ rails (< 6)
180
+ rake
181
+ rspec
182
+ sinatra!
183
+ tilt
184
+ vcr (~> 3.0)
149
185
  veritrans!
150
- webmock (~> 1.20)
186
+ webmock (>= 1.20)
187
+
188
+ BUNDLED WITH
189
+ 1.12.5
@@ -0,0 +1 @@
1
+ web: bundle exec puma -p $PORT --dir example config.ru
data/README.md CHANGED
@@ -30,6 +30,9 @@ development:
30
30
  server_key: # your api client key
31
31
  ```
32
32
 
33
+ See out example sinatra application in [example](https://github.com/veritrans/veritrans-ruby/tree/master/example) folder or [online](https://veritrans-ruby-example.herokuapp.com/)
34
+
35
+
33
36
  ## STEP 1: Process credit cards
34
37
 
35
38
 
@@ -252,11 +255,15 @@ Veritrans.setup do
252
255
  config.client_key = "..."
253
256
 
254
257
  events.subscribe('payment.success') do |payment|
255
- Payment.find_by(order_id: payment.order_id).mark_paid!(payment.masked_card)
258
+ # payment variable is hash with params recieved from Veritrans
259
+ # assuming you have model Order in your project
260
+ Order.find_by(order_id: payment.order_id).mark_paid!(payment.masked_card)
256
261
  end
257
262
 
258
263
  events.subscribe('payment.failed', 'payment.challenge') do |payment|
259
- Payment.find_by(order_id: payment.order_id) ...
264
+ # payment variable is hash with params recieved from Veritrans
265
+ # assuming you have model Order in your project
266
+ Order.find_by(order_id: payment.order_id) ...
260
267
  end
261
268
  end
262
269
  ```
@@ -298,8 +305,8 @@ Testing http notification:
298
305
 
299
306
  #### Get help
300
307
 
301
- * [Veritrans gem reference](https://github.com/veritrans/veritrans-ruby/blob/new_api/api_reference.md)
302
- * [Veritrans sandbox login](https://my.sandbox.veritrans.co.id/login)
303
- * [Veritrans sandbox registration](https://my.sandbox.veritrans.co.id/register)
308
+ * [Veritrans gem reference](https://github.com/veritrans/veritrans-ruby/blob/master/api_reference.md)
309
+ * [Veritrans login](https://my.veritrans.co.id/login)
310
+ * [Veritrans registration](https://my.veritrans.co.id/register)
304
311
  * [Veritrans documentation](http://docs.veritrans.co.id)
305
312
  * Technical support [support@veritrans.co.id](mailto:support@veritrans.co.id)
data/Rakefile CHANGED
@@ -1,10 +1,12 @@
1
1
  require 'rubygems'
2
2
 
3
- task :default => :spec
4
-
5
- desc "Run Specs"
6
- require 'rspec/core/rake_task'
7
- RSpec::Core::RakeTask.new(:spec)
3
+ begin
4
+ desc "Run Specs"
5
+ require 'rspec/core/rake_task'
6
+ RSpec::Core::RakeTask.new(:spec)
7
+ rescue LoadError
8
+ puts "no rspec available"
9
+ end
8
10
 
9
11
  desc "Generate documentation with sdoc"
10
12
  task :doc do
@@ -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.htmlu)
4
+ please use our [documentation](http://docs.veritrans.co.id/en/api/introduction.html)
5
5
 
6
6
 
7
7
  <table>
@@ -240,3 +240,23 @@ In this situation you better expire previous transaction, and you can use same o
240
240
  q = Veritrans.expire("testing-0.2072-1415086078")
241
241
  q.success? # => true
242
242
  ```
243
+
244
+
245
+
246
+ ### `Veritrans::Result`
247
+
248
+ ```ruby
249
+ result = Veritrans.charge(...)
250
+
251
+ result.class # => Veritrans::Result
252
+ ```
253
+
254
+ * `Veritrans::Result#success?` - `boolean`, base on `status_code` field in json
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
257
+ * `Veritrans::Result#status_message` - `string`, e.g. "OK, success do VTWeb transaction, please go to redirect_url"
258
+ * `Veritrans::Result#redirect_url` - `string`, redirect URL for VT-Web and VT-Link
259
+ * `Veritrans::Result#body` - `string`, raw HTTP request body
260
+ * `Veritrans::Result#data` - `hash`, parsed json body as hash
261
+ * `Veritrans::Result#response` - `Excon::Response` instance
262
+ * `Veritrans::Result#method_mising` - acessing fields of `data`. E.g. `result.transction_status`, `result.masked_card`, `result.approval_code`