veritrans 1.2.6 → 2.0.0beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +13 -5
  2. data/.gitignore +4 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +5 -0
  5. data/Gemfile.lock +111 -0
  6. data/README.md +258 -0
  7. data/Rakefile +7 -0
  8. data/api_reference.md +219 -0
  9. data/bin/veritrans +59 -48
  10. data/example/index.erb +118 -0
  11. data/example/response.erb +28 -0
  12. data/example/sinatra.rb +76 -0
  13. data/example/style.css +45 -0
  14. data/example/veritrans.yml +12 -0
  15. data/lib/generators/templates/assets/credit_card_form.js +50 -0
  16. data/lib/generators/templates/payments_controller.rb +81 -0
  17. data/lib/generators/templates/veritrans.rb +43 -0
  18. data/lib/generators/templates/veritrans.yml +13 -0
  19. data/lib/generators/templates/views/_credit_card_form.erb +42 -0
  20. data/lib/generators/templates/views/_veritrans_include.erb +10 -0
  21. data/lib/generators/templates/views/payments/create.erb +15 -0
  22. data/lib/generators/templates/views/payments/new.erb +6 -0
  23. data/lib/generators/veritrans/install_generator.rb +32 -0
  24. data/lib/generators/veritrans/payment_form_generator.rb +45 -0
  25. data/lib/veritrans/api.rb +90 -0
  26. data/lib/veritrans/cli.rb +166 -0
  27. data/lib/veritrans/client.rb +77 -209
  28. data/lib/veritrans/config.rb +48 -62
  29. data/lib/veritrans/events.rb +125 -0
  30. data/lib/veritrans/result.rb +81 -0
  31. data/lib/veritrans/version.rb +1 -41
  32. data/lib/veritrans.rb +79 -15
  33. data/license.txt +202 -0
  34. data/spec/cli_spec.rb +86 -0
  35. data/spec/configs/veritrans.yml +7 -0
  36. data/spec/configs/veritrans_flat.yml +2 -0
  37. data/spec/fixtures/approve_failed.yml +48 -0
  38. data/spec/fixtures/cancel_failed.yml +48 -0
  39. data/spec/fixtures/cancel_success.yml +106 -0
  40. data/spec/fixtures/capture_failed.yml +48 -0
  41. data/spec/fixtures/charge.yml +50 -0
  42. data/spec/fixtures/charge_direct.yml +56 -0
  43. data/spec/fixtures/charge_vtweb.yml +50 -0
  44. data/spec/fixtures/cli_test_1111-not-exists.yml +45 -0
  45. data/spec/fixtures/cli_test_not_exists.yml +45 -0
  46. data/spec/fixtures/cli_test_real_txn.yml +55 -0
  47. data/spec/fixtures/cli_test_unauthorized.yml +47 -0
  48. data/spec/fixtures/events_test_real_txn.yml +55 -0
  49. data/spec/fixtures/status_fail.yml +46 -0
  50. data/spec/fixtures/status_success.yml +109 -0
  51. data/spec/spec_helper.rb +29 -0
  52. data/spec/veritrans_client_spec.rb +83 -0
  53. data/spec/veritrans_config_spec.rb +48 -0
  54. data/spec/veritrans_events_spec.rb +70 -0
  55. data/spec/veritrans_logger_spec.rb +46 -0
  56. data/testing_webhooks.md +80 -0
  57. data/veritrans.gemspec +23 -0
  58. metadata +82 -31
  59. data/config/veritrans.yml +0 -24
  60. data/lib/generators/install_generator.rb +0 -78
  61. data/lib/generators/templates/app/controllers/vtlink/merchant_controller.rb +0 -7
  62. data/lib/generators/templates/app/controllers/vtlink/veritrans_controller.rb +0 -112
  63. data/lib/generators/templates/app/views/layouts/layout_auto_post.html.erb +0 -15
  64. data/lib/generators/templates/app/views/vtlink/merchant/checkout.html.erb +0 -43
  65. data/lib/generators/templates/app/views/vtlink/veritrans/cancel.html.erb +0 -2
  66. data/lib/generators/templates/app/views/vtlink/veritrans/confirm.html.erb +0 -13
  67. data/lib/generators/templates/app/views/vtlink/veritrans/error.html.erb +0 -2
  68. data/lib/generators/templates/app/views/vtlink/veritrans/finish.html.erb +0 -2
  69. data/lib/generators/templates/app/views/vtlink/veritrans/pay.html.erb +0 -2
  70. data/lib/generators/templates/config/veritrans.yml +0 -13
  71. data/lib/veritrans/hash_generator.rb +0 -19
  72. data/lib/veritrans/post_data.rb +0 -163
  73. data/lib/veritrans/v_t_direct.rb +0 -145
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
- metadata.gz: 4a017d4aab2833fbc4ba25a649fe9a00d93eec35
4
- data.tar.gz: bafcedb6c0a86d539747f90596e51a11766bb431
5
- !binary "U0hBNTEy":
6
- metadata.gz: f4e0013cacbaabe14522d6e111982c6171d4955e7c25fe8b281a79096f0998f660fa20fc257d02dd626bf68837373df3daf021f382dce58ccc2477d54d90c6b5
7
- data.tar.gz: 75430bc2305e45fb21c423d7ac8017456b54214bc305b83f9dd397180389e2aafcb59f5b4f236f9836879b3284584a5edd89abaf2149e90f6cb6910f59e7a476
3
+ metadata.gz: !binary |-
4
+ MWMwMzlhMDNjOWVkYzFlYjI3YzgzODc5NzIxYzEwY2NlZTg0MGY3OQ==
5
+ data.tar.gz: !binary |-
6
+ MDFhZDNiNDI5ZTRhMDc2N2MzNzY1ODJhMGIwNTcyMDcyOGFiMDYwYQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ Zjg4MTAzMDcyNjdjMzI5MGY1MDA4ZDFkNzkyNWFjY2NkYmE4MDEzYWNmMzE1
10
+ MjY0ODYwYWE4MjhkNDAwZjJkNTg3ZjcwNGE5ODI3YWRjOGQ5YTA5ZGZkMzM4
11
+ M2Y4MmJmZGZkNDgwOWE5NmQ4NmJkZDU3NzNjODczZDkyZGEzMzE=
12
+ data.tar.gz: !binary |-
13
+ ODMyNTRiN2JjYjg0MWE3Njk2ODI0MzI1M2VjZGRiNWQ4NDljMjE0ZWIxNTll
14
+ MjQ1MTM2YWU5ZmE2M2E0NmRmZTFjNzllZTU4YWEwMGMxNTIzY2U2ZTJmNjlh
15
+ YzI5ODc4ODM2N2M4OGJjODFkOGQzOTlkZTllZWEzYmM2ZWU2ZGY=
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ coverage
2
+ rails_example*
3
+ .DS_Store
4
+
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'vcr'
data/Gemfile.lock ADDED
@@ -0,0 +1,111 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ veritrans (2.0.0beta)
5
+ excon (~> 0.20)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (4.1.6)
11
+ actionpack (= 4.1.6)
12
+ actionview (= 4.1.6)
13
+ mail (~> 2.5, >= 2.5.4)
14
+ actionpack (4.1.6)
15
+ actionview (= 4.1.6)
16
+ activesupport (= 4.1.6)
17
+ rack (~> 1.5.2)
18
+ rack-test (~> 0.6.2)
19
+ actionview (4.1.6)
20
+ activesupport (= 4.1.6)
21
+ builder (~> 3.1)
22
+ erubis (~> 2.7.0)
23
+ activemodel (4.1.6)
24
+ activesupport (= 4.1.6)
25
+ builder (~> 3.1)
26
+ activerecord (4.1.6)
27
+ activemodel (= 4.1.6)
28
+ activesupport (= 4.1.6)
29
+ arel (~> 5.0.0)
30
+ activesupport (4.1.6)
31
+ i18n (~> 0.6, >= 0.6.9)
32
+ json (~> 1.7, >= 1.7.7)
33
+ minitest (~> 5.1)
34
+ thread_safe (~> 0.1)
35
+ tzinfo (~> 1.1)
36
+ addressable (2.3.6)
37
+ arel (5.0.1.20140414130214)
38
+ builder (3.2.2)
39
+ crack (0.4.2)
40
+ safe_yaml (~> 1.0.0)
41
+ diff-lcs (1.2.5)
42
+ erubis (2.7.0)
43
+ excon (0.40.0)
44
+ hike (1.2.3)
45
+ i18n (0.6.11)
46
+ json (1.8.1)
47
+ mail (2.6.1)
48
+ mime-types (>= 1.16, < 3)
49
+ mime-types (2.4.3)
50
+ minitest (5.4.2)
51
+ multi_json (1.10.1)
52
+ rack (1.5.2)
53
+ rack-test (0.6.2)
54
+ rack (>= 1.0)
55
+ rails (4.1.6)
56
+ actionmailer (= 4.1.6)
57
+ actionpack (= 4.1.6)
58
+ actionview (= 4.1.6)
59
+ activemodel (= 4.1.6)
60
+ activerecord (= 4.1.6)
61
+ activesupport (= 4.1.6)
62
+ bundler (>= 1.3.0, < 2.0)
63
+ railties (= 4.1.6)
64
+ sprockets-rails (~> 2.0)
65
+ railties (4.1.6)
66
+ actionpack (= 4.1.6)
67
+ activesupport (= 4.1.6)
68
+ rake (>= 0.8.7)
69
+ thor (>= 0.18.1, < 2.0)
70
+ rake (10.3.2)
71
+ rspec (3.1.0)
72
+ rspec-core (~> 3.1.0)
73
+ rspec-expectations (~> 3.1.0)
74
+ rspec-mocks (~> 3.1.0)
75
+ rspec-core (3.1.7)
76
+ rspec-support (~> 3.1.0)
77
+ rspec-expectations (3.1.2)
78
+ diff-lcs (>= 1.2.0, < 2.0)
79
+ rspec-support (~> 3.1.0)
80
+ rspec-mocks (3.1.3)
81
+ rspec-support (~> 3.1.0)
82
+ rspec-support (3.1.2)
83
+ safe_yaml (1.0.4)
84
+ sprockets (2.11.3)
85
+ hike (~> 1.2)
86
+ multi_json (~> 1.0)
87
+ rack (~> 1.0)
88
+ tilt (~> 1.1, != 1.3.0)
89
+ sprockets-rails (2.2.0)
90
+ actionpack (>= 3.0)
91
+ activesupport (>= 3.0)
92
+ sprockets (>= 2.8, < 4.0)
93
+ thor (0.19.1)
94
+ thread_safe (0.3.4)
95
+ tilt (1.4.1)
96
+ tzinfo (1.2.2)
97
+ thread_safe (~> 0.1)
98
+ vcr (2.9.3)
99
+ webmock (1.20.2)
100
+ addressable (>= 2.3.6)
101
+ crack (>= 0.3.2)
102
+
103
+ PLATFORMS
104
+ ruby
105
+
106
+ DEPENDENCIES
107
+ rails
108
+ rspec (>= 2.9.0)
109
+ vcr
110
+ veritrans!
111
+ webmock
data/README.md ADDED
@@ -0,0 +1,258 @@
1
+ # Veritrans ruby library
2
+
3
+ ## Installation
4
+
5
+ $ gem install veritrans
6
+
7
+ ## How to use (Rails)
8
+
9
+ ### Add veritrans to Gemfile
10
+
11
+ ```ruby
12
+ gem 'veritrans'
13
+ ```
14
+
15
+ bundle install
16
+
17
+ ### Generate veritrans.yml
18
+
19
+ rails g veritrans:install
20
+
21
+ ### Create simple payment form (optional)
22
+
23
+ rails g veritrans:payment_form
24
+
25
+ ### Edit api keys in config/veritrans.yml
26
+
27
+ ```yml
28
+ # config/veritrans.yml
29
+ development:
30
+ client_key: # your api client key
31
+ server_key: # your api client key
32
+ ```
33
+
34
+ ## STEP 1: Process credit cards
35
+
36
+
37
+ #### VT-Web
38
+
39
+ *If you want to use VT-Web, add `payment_type: "VTWEB"`*
40
+
41
+ ```ruby
42
+ @result = Veritrans.charge(
43
+ payment_type: "VTWEB",
44
+ transaction_details: {
45
+ order_id: "my-unique-order-id",
46
+ gross_amount: 100_000
47
+ }
48
+ )
49
+
50
+ redirect_to @result.redirect_url
51
+ ```
52
+
53
+ #### VT-Direct
54
+
55
+ It's little more complicated, because credit_card is sensitive data,
56
+ you need put credit card number in our safe storage first using `veritrans.js` library, then send received token to with other payment details.
57
+
58
+ We don't want you to send credit card number to your server, especially for websites not using https.
59
+
60
+ File: "app/views/shared/_veritrans_include.erb"
61
+
62
+ ```html
63
+ <script src="//api.sandbox.veritrans.co.id/v2/assets/veritrans.js"></script>
64
+
65
+ <script type="text/javascript">
66
+ Veritrans.url = "<%= Veritrans.config.api_host %>/v2/token";
67
+ Veritrans.client_key = "<%= Veritrans.config.client_key %>";
68
+ </script>
69
+ ```
70
+
71
+ Payment form:
72
+ ```html
73
+ <form action="/charge_vtdirect" method="post" id="card_form">
74
+ <input type="hidden" name="token_id" id="card_token">
75
+ <input type="hidden" id="gross_amount" value="30000">
76
+ <p>
77
+ <label for="card_number">Card number</label>
78
+ <input type="text" id="card_number" style="width: 150px" value="4811 1111 1111 1114">
79
+ </p>
80
+ <p>
81
+ <label for="card_cvc">Security Code</label>
82
+ <input type="text" id="card_cvc" style="width: 30px" placeholder="cvc" value="123">
83
+ </p>
84
+ <p>
85
+ <label for="card_exp">Expiration date</label>
86
+ <input type="text" id="card_exp" placeholder="MM / YY" value="12 / 16">
87
+ </p>
88
+ <input id="submit_btn" type="submit">
89
+ </form>
90
+ <iframe id="3d-secure-iframe" style="display: none; width: 500px; height: 600px"></iframe>
91
+ ```
92
+
93
+ Sending "get-token" request:
94
+
95
+ ```js
96
+ $(document).ready(function () {
97
+ // function to prepare our credit card data before send
98
+ function createTokenData() {
99
+ return {
100
+ card_number: $('#card_number').val(),
101
+ card_cvv: $('#card_cvc').val(),
102
+ card_exp_month: $('#card_exp').val().match(/(\d+) \//)[1],
103
+ card_exp_year: '20' + $('#card_exp').val().match(/\/ (\d+)/)[1],
104
+ gross_amount: $('#gross_amount').val(),
105
+ secure: true
106
+ };
107
+ }
108
+ // Add custom event for form submition
109
+ $('#card_form').on('submit', function (event) {
110
+ var form = this;
111
+ event.preventDefault();
112
+
113
+ Veritrans.token(createTokenData, function (data) {
114
+ console.log('Token data:', data);
115
+ // when you making 3D-secure transaction,
116
+ // this callback function will be called again after user confirm 3d-secure
117
+ // but you can also redirect on server side
118
+ if (data.redirect_url) {
119
+ // if we get url then it's 3d-secure transaction
120
+ // so we need to open that page
121
+ $('#3d-secure-iframe').attr('src', data.redirect_url).show();
122
+ // if no redirect_url and we have token_id then just make charge request
123
+ } else if (data.token_id) {
124
+ $('#card_token').val(data.token_id);
125
+ form.submit();
126
+ // if no redirect_url and no token_id, then it should be error
127
+ } else {
128
+ alert(data.validation_messages ? data.validation_messages.join("\n") : data.status_message);
129
+ }
130
+ });
131
+ });
132
+ });
133
+ ```
134
+
135
+ On a server side:
136
+
137
+ ```ruby
138
+ @result = Veritrans.charge(
139
+ payment_type: "credit_card",
140
+ credit_card: { token_id: params[:token_id] },
141
+ transaction_details: {
142
+ order_id: @payment.order_id,
143
+ gross_amount: @payment.amount
144
+ }
145
+ )
146
+ if @result.success?
147
+ puts "Success"
148
+ end
149
+ ```
150
+
151
+ ## STEP 2: Process not credit cards
152
+
153
+ We provide many payment channels to receive money, but API is almost same.
154
+
155
+ For VT-Web in only one request, and payment page will have all available payment options.
156
+
157
+ For VT-Direct you have to specify payment method (token required only for credit card transactions).
158
+
159
+ ```ruby
160
+ @result = Veritrans.charge(
161
+ payment_type: "bank_transfer",
162
+ bank_transfer: { bank: 'permata' },
163
+ transaction_details: {
164
+ order_id: @payment.order_id,
165
+ gross_amount: @payment.amount
166
+ }
167
+ )
168
+ puts "Please send money to account no. #{@result.permata_va_number} in bank Permata"
169
+ ```
170
+
171
+ See [our documentation](http://docs.veritrans.co.id/sandbox/charge.html) for other available options.
172
+
173
+
174
+ ## STEP 3: Receive notification callback
175
+
176
+ For every transaction success and failed we will send you HTTP POST notification (aka webhook)
177
+
178
+ First you should set callback url in our dashboard https://my.sandbox.veritrans.co.id/settings/vtweb_configuration
179
+
180
+ In development mode please read our [Testing webhooks tutorial](https://github.com/Paxa/veritrans-ruby/blob/new_api/testing_webhooks.md)
181
+
182
+
183
+ For rails:
184
+
185
+ ```ruby
186
+ # config/routes.rb
187
+ match "/payments/receive_webhook" => "payments#receive_webhook", via: [:post]
188
+
189
+ # app/controllers/payments_controller.rb
190
+ def receive_webhook
191
+ verified_data = Veritrans.status(params[:transaction_id])
192
+
193
+ if verified_data.status_code != 404
194
+ puts "--- Transaction callback ---"
195
+ puts "Payment: #{verified_data.data[:order_id]}"
196
+ puts "Payment type: #{verified_data.data[:payment_type]}"
197
+ puts "Payment status: #{verified_data.data[:transaction_status]}"
198
+ puts "Fraud status: #{verified_data.data[:fraud_status]}" if verified_data.data[:fraud_status]
199
+ puts "Payment amount: #{verified_data.data[:gross_amount]}"
200
+ puts "--- Transaction callback ---"
201
+
202
+ render text: "ok"
203
+ else
204
+ render text: "ok", :status => :not_found
205
+ end
206
+ end
207
+ ```
208
+
209
+ #### Veritrans::Events
210
+
211
+ Other option to handle callbacks is our rack-based handler
212
+
213
+ ```ruby
214
+ # config/routes.rb
215
+ mount Veritrans::Events.new => '/vt_events'
216
+
217
+ # config/initalizers/veritrans.rb
218
+ Veritrans.setup do
219
+ config.server_key = "..."
220
+ config.client_key = "..."
221
+
222
+ events.subscribe('payment.success') do |payment|
223
+ Payment.find_by(order_id: payment.order_id).mark_paid!(payment.masked_card)
224
+ end
225
+
226
+ events.subscribe('payment.failed', 'payment.challenge') do |payment|
227
+ Payment.find_by(order_id: payment.order_id) ...
228
+ end
229
+ end
230
+ ```
231
+
232
+ #### Logging
233
+
234
+ By default gem veritrans will show information via rails' logger. And in addition save important information to `RAILS_APP/config/veritrans.log`
235
+
236
+ It's configurable.
237
+
238
+ ```ruby
239
+ Veritrans.logger = Logger.new("/my/logs/veritrans.log")
240
+ Veritrans.file_logger = Logger.new("/my/important_logs/veritrans.log")
241
+ ```
242
+
243
+ `Veritrans.file_logger` save information about:
244
+
245
+ * "charge", "cancel", "approve" api calls
246
+ * Validation errors for "charge", "cancel", "approve"
247
+ * Received http notifications
248
+ * Errors and exception while processing http notifications
249
+
250
+
251
+ #### Get help
252
+
253
+ * [Veritrans gem reference](https://github.com/Paxa/veritrans-ruby/blob/new_api/api_reference.md)
254
+ * [Veritrans sandbox login](https://my.sandbox.veritrans.co.id/register)
255
+ * [Veritrans sandbox registration](https://my.sandbox.veritrans.co.id/register)
256
+ * [Veritrans registration](https://my.veritrans.co.id/register)
257
+ * [Veritrans documentation](http://docs.veritrans.co.id)
258
+ * Technical support [support@veritrans.co.id](mailto:support@veritrans.co.id)
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+
3
+ task :default => :spec
4
+
5
+ desc "Run Specs"
6
+ require 'rspec/core/rake_task'
7
+ RSpec::Core::RakeTask.new(:spec)
data/api_reference.md ADDED
@@ -0,0 +1,219 @@
1
+ # API Reference
2
+
3
+ Here is only reference for API of this gem, to see complete information
4
+ please use our [documentation](http://docs.veritrans.co.id/sandbox/introduction.html)
5
+
6
+
7
+ <table>
8
+ <thead>
9
+ <tr>
10
+ <th>Method</th>
11
+ <th>Descripion</th>
12
+ <th>Http Method</th>
13
+ <th>URL</th>
14
+ </tr>
15
+ </thead>
16
+
17
+ <tbody>
18
+ <tr>
19
+ <td><a href="#charge">Veritrans.charge(data)</a></td>
20
+ <td>Charge Transaction</td>
21
+ <td>POST</td>
22
+ <td>api.veritrans.co.id/v2/charge</td>
23
+ </tr>
24
+ <tr>
25
+ <td><a href="#status">Veritrans.status(id)</a></td>
26
+ <td>Get Last Status</td>
27
+ <td>GET</td>
28
+ <td>api.veritrans.co.id/v2/{id}/status</td>
29
+ </tr>
30
+ <tr>
31
+ <td><a href="#cancel">Veritrans.cancel(id)</a></td>
32
+ <td>Cancel Transaction</td>
33
+ <td>POST</td>
34
+ <td>api.veritrans.co.id/v2/{id}/cancel</td>
35
+ </tr>
36
+ <tr>
37
+ <td><a href="#approve">Veritrans.approve(id)</a></td>
38
+ <td>Approve Challenge Transaction</td>
39
+ <td>POST</td>
40
+ <td>api.veritrans.co.id/v2/{id}/approve</td>
41
+ </tr>
42
+ <tr>
43
+ <td><a href="#capture">Veritrans.capture(id)</a></td>
44
+ <td>Capture Authorise Transaction</td>
45
+ <td>POST</td>
46
+ <td>api.veritrans.co.id/v2/{id}/capture</td>
47
+ </tr>
48
+ </tbody>
49
+ </table>
50
+
51
+
52
+ ### <a name="charge"></a> Charge
53
+
54
+ Actually make transaction. But for vt-web create a redirect url, and for vt-link creates payment page
55
+
56
+ **For VT-Web:**
57
+
58
+ ```ruby
59
+ q = Veritrans.charge({
60
+ payment_type: "VTWEB",
61
+ transaction_details: {
62
+ order_id: "order-1",
63
+ gross_amount: 100_000
64
+ }
65
+ })
66
+
67
+ q.class # => Veritrans::Result
68
+ q.data == {
69
+ status_code: "201",
70
+ status_message: "OK, success do VTWeb transaction, please go to redirect_url",
71
+ redirect_url: "https://vtweb.sandbox.veritrans.co.id/v2/vtweb/b27d421f-90ff-4427-83d2-fbe8acbbce89"
72
+ }
73
+ ```
74
+
75
+ **For VT-Direct:**
76
+
77
+ ```ruby
78
+ q = Veritrans.charge({
79
+ # *required
80
+ payment_type: "credit_card",
81
+ # *required
82
+ transaction_details: {
83
+ order_id: "order-2",
84
+ gross_amount: 100_000
85
+ },
86
+ # *required (but different for different payment type)
87
+ credit_card: {
88
+ token_id: "dcd6cd71-bc4c-4f4b-8752-49cb0a3f204c",
89
+ bank: "cimb"
90
+ },
91
+ # optional
92
+ item_details: [
93
+ {
94
+ id: "ITEM1",
95
+ price: 100_000,
96
+ quantity: 1,
97
+ name: "T-Short Infinity"
98
+ }
99
+ ],
100
+ # optional
101
+ customer_details: {
102
+ first_name: "Nadia",
103
+ last_name: "Modjo",
104
+ email: "noreply@veritrans.co.id",
105
+ phone: "+6281 123 12345",
106
+ billing_address: {
107
+ address: "Jalan Raya Kalijati",
108
+ city: "Subang",
109
+ postal_code: "41271",
110
+ },
111
+ },
112
+ # optional
113
+ custom_field1: "age: 25",
114
+ custom_field2: "new_year_promo",
115
+ custom_field3: "submerchant_id: 23"
116
+ });
117
+
118
+ q.class # => Veritrans::Result
119
+ q.data == {
120
+ status_code: "200",
121
+ status_message: "Success, Credit Card transaction is successful",
122
+ transaction_id: "20bcc3dd-6fa5-4a9a-a9ad-615af992aa3d",
123
+ masked_card: "481111-1114",
124
+ order_id: "order-2",
125
+ payment_type: "credit_card",
126
+ transaction_time: "2014-11-03 16:22:52",
127
+ transaction_status: "capture",
128
+ fraud_status: "accept",
129
+ approval_code: "1415006572598",
130
+ gross_amount: "100000.00"
131
+ }
132
+
133
+ q.success? # => true
134
+ ```
135
+
136
+
137
+ ### <a name="status"></a> Status
138
+
139
+ Return current status of transaction.
140
+
141
+ ```ruby
142
+ q = Veritrans.status("order-2")
143
+
144
+ q.data == {
145
+ status_code: "200",
146
+ status_message: "Success, transaction found",
147
+ transaction_id: "20bcc3dd-6fa5-4a9a-a9ad-615af992aa3d",
148
+ masked_card: "481111-1114",
149
+ order_id: "order-2",
150
+ payment_type: "credit_card",
151
+ transaction_time: "2014-11-03 16:22:52",
152
+ transaction_status: "settlement",
153
+ fraud_status: "accept",
154
+ signature_key: "639af8e985f68526839e6ed04c1...",
155
+ bank: "bni",
156
+ gross_amount: "100000.00"
157
+ }
158
+ ```
159
+
160
+
161
+ ### <a name="cancel"></a> Cancel
162
+
163
+ Cancel transaction, before it was settled. For credit card payments you can cancel it before we trigger settlement in bank.
164
+ Usually we do settlement next day after payment happen, about 4pm.
165
+
166
+ For internet banking, bank transfer, mobile payments, convenient store payments if user already made payment,
167
+ you can't cancel it as simple as credit card, but before user sent money you can cancel pending transactions.
168
+
169
+ ```ruby
170
+ q = Veritrans.cancel("testing-0.2072-1415086078")
171
+
172
+ q.data == {
173
+ status_code: "200",
174
+ status_message: "Success, transaction is canceled",
175
+ transaction_id: "b38f598a-59ab-4850-b311-2aa14c78bc45",
176
+ masked_card: "481111-1114",
177
+ order_id: "testing-0.2072-1415086078",
178
+ payment_type: "credit_card",
179
+ transaction_time: "2014-11-04 14:29:47",
180
+ transaction_status: "cancel",
181
+ fraud_status: "accept",
182
+ bank: "bni",
183
+ gross_amount: "100000.00"
184
+ }
185
+ ```
186
+
187
+
188
+ ### <a name="approve"></a> Approve
189
+
190
+ Some transactions marked as challenge. If challenge you can approve it or cancel it. Usual way is to use our dashboard web interface,
191
+ but you also can do it programatically, via API
192
+
193
+ ```ruby
194
+ q = Veritrans.cancel("testing-0.2072-1415086078")
195
+
196
+ q.data == {
197
+ status_code: "200",
198
+ status_message: "Success, transaction is approved",
199
+ transaction_id: "8492c240-1600-465a-9bf1-808863410b0e",
200
+ masked_card: "451111-1117",
201
+ order_id: "testing-0.0501-1415086808",
202
+ payment_type: "credit_card",
203
+ transaction_time: "2014-11-04 14:41:58",
204
+ transaction_status: "capture",
205
+ fraud_status: "accept",
206
+ bank: "bni",
207
+ gross_amount: "100000.00"
208
+ }
209
+ ```
210
+
211
+
212
+ ### <a name="capture"></a> Capture
213
+
214
+ This API method is only for merchants who have pre-authorise feature (can be requested) and have pre-authorise payments.
215
+
216
+ ```ruby
217
+ q = Veritrans.capture("testing-0.2072-1415086078", 101_000)
218
+ q.success? # => true
219
+ ```