veritrans 2.1.2 → 2.4.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 (98) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +10 -1
  3. data/.idea/.gitignore +8 -0
  4. data/.rubocop.yml +35 -0
  5. data/.travis.yml +10 -5
  6. data/CHANGELOG.md +45 -0
  7. data/Gemfile +6 -7
  8. data/Gemfile.lock +134 -146
  9. data/Maintaining.MD +8 -0
  10. data/README.md +266 -226
  11. data/api_reference.md +534 -143
  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 +6 -0
  16. data/example/sinatra/index.erb +202 -0
  17. data/example/sinatra/response.erb +1 -0
  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 +146 -22
  31. data/lib/veritrans/client.rb +48 -12
  32. data/lib/veritrans/config.rb +31 -6
  33. data/lib/veritrans/events.rb +46 -35
  34. data/lib/veritrans/midtrans_error.rb +15 -0
  35. data/lib/veritrans/result.rb +66 -5
  36. data/lib/veritrans/version.rb +1 -1
  37. data/lib/veritrans.rb +121 -12
  38. data/veritrans.gemspec +2 -9
  39. metadata +30 -146
  40. data/.rspec +0 -2
  41. data/Procfile +0 -1
  42. data/Rakefile +0 -16
  43. data/bin/midtrans +0 -3
  44. data/bin/veritrans +0 -68
  45. data/example/README.md +0 -8
  46. data/example/config.ru +0 -6
  47. data/example/index.erb +0 -213
  48. data/example/localization.erb +0 -248
  49. data/example/points.erb +0 -187
  50. data/example/recurring.erb +0 -201
  51. data/example/response.erb +0 -37
  52. data/example/sinatra.rb +0 -188
  53. data/example/style.css +0 -126
  54. data/example/veritrans.yml +0 -11
  55. data/example/widget.erb +0 -51
  56. data/lib/generators/templates/assets/credit_card_form.js +0 -51
  57. data/lib/generators/templates/payments_controller.rb +0 -85
  58. data/lib/generators/templates/veritrans.rb +0 -46
  59. data/lib/generators/templates/veritrans.yml +0 -18
  60. data/lib/generators/templates/views/_credit_card_form.erb +0 -42
  61. data/lib/generators/templates/views/_veritrans_include.erb +0 -10
  62. data/lib/generators/templates/views/payments/create.erb +0 -15
  63. data/lib/generators/templates/views/payments/new.erb +0 -6
  64. data/lib/generators/veritrans/install_generator.rb +0 -32
  65. data/lib/generators/veritrans/payment_form_generator.rb +0 -45
  66. data/lib/veritrans/cli.rb +0 -155
  67. data/lib/veritrans/core_extensions.rb +0 -32
  68. data/spec/cli_spec.rb +0 -83
  69. data/spec/configs/real_key.yml +0 -4
  70. data/spec/configs/veritrans.yml +0 -7
  71. data/spec/configs/veritrans_flat.yml +0 -2
  72. data/spec/configs/veritrans_with_erb.yml +0 -2
  73. data/spec/fixtures/approve_failed.yml +0 -48
  74. data/spec/fixtures/cancel_failed.yml +0 -48
  75. data/spec/fixtures/cancel_success.yml +0 -106
  76. data/spec/fixtures/capture_failed.yml +0 -48
  77. data/spec/fixtures/charge.yml +0 -50
  78. data/spec/fixtures/charge_direct.yml +0 -56
  79. data/spec/fixtures/charge_vtweb.yml +0 -50
  80. data/spec/fixtures/cli_test_1111-not-exists.yml +0 -45
  81. data/spec/fixtures/cli_test_not_exists.yml +0 -45
  82. data/spec/fixtures/cli_test_real_txn.yml +0 -55
  83. data/spec/fixtures/cli_test_unauthorized.yml +0 -47
  84. data/spec/fixtures/events_test_real_txn.yml +0 -55
  85. data/spec/fixtures/expire_failed.yml +0 -50
  86. data/spec/fixtures/expire_success.yml +0 -56
  87. data/spec/fixtures/midtrans_status.yml +0 -117
  88. data/spec/fixtures/status_fail.yml +0 -46
  89. data/spec/fixtures/status_success.yml +0 -109
  90. data/spec/midtrans_rename_spec.rb +0 -27
  91. data/spec/rails_plugin_spec.rb +0 -281
  92. data/spec/spec_helper.rb +0 -61
  93. data/spec/veritrans_client_spec.rb +0 -184
  94. data/spec/veritrans_config_spec.rb +0 -70
  95. data/spec/veritrans_events_spec.rb +0 -72
  96. data/spec/veritrans_logger_spec.rb +0 -46
  97. data/spec/veritrans_snap_spec.rb +0 -39
  98. data/testing_webhooks.md +0 -78
@@ -1,46 +0,0 @@
1
- describe Veritrans do
2
-
3
- after do
4
- Veritrans.logger = nil
5
- Veritrans.file_logger = nil
6
- end
7
-
8
- it "should set logger" do
9
- Veritrans.logger = :nothing
10
- Veritrans.logger.should == :nothing
11
-
12
- Veritrans.file_logger = :nothing2
13
- Veritrans.file_logger.should == :nothing2
14
- end
15
-
16
- describe "widthout rails" do
17
- before do
18
- hide_const("Rails")
19
- end
20
-
21
- it "should log to stdout when there is no rails" do
22
- Veritrans.logger.instance_variable_get(:@logdev).dev.should == $stdout
23
- end
24
-
25
- it "should set file_logger" do
26
- Veritrans.file_logger.instance_variable_get(:@logdev).filename.should == "/dev/null"
27
- end
28
-
29
- end
30
-
31
- describe "width rails" do
32
- before do
33
- FileUtils.mkdir_p("/tmp/log")
34
- allow(Rails).to receive(:logger).and_return(Logger.new(STDERR))
35
- allow(Rails).to receive(:root).and_return(Pathname.new("/tmp"))
36
- end
37
-
38
- it "should use rails logger" do
39
- Veritrans.logger.should == Rails.logger
40
- end
41
-
42
- it "should set file_logger" do
43
- Veritrans.file_logger.instance_variable_get(:@logdev).filename.should == "/tmp/log/veritrans.log"
44
- end
45
- end
46
- end
@@ -1,39 +0,0 @@
1
- describe Veritrans::Config do
2
-
3
- before do
4
- hide_const("Rails")
5
- Veritrans.logger = Logger.new("/dev/null")
6
- Veritrans.setup do
7
- config.load_config "./spec/configs/real_key.yml"
8
- end
9
-
10
- VCR.configure do |c|
11
- c.allow_http_connections_when_no_cassette = true
12
- end
13
- end
14
-
15
- after do
16
- VCR.configure do |c|
17
- c.allow_http_connections_when_no_cassette = false
18
- end
19
- end
20
-
21
- def generate_order_id
22
- "testing-#{rand.round(4)}-#{Time.now.to_i}"
23
- end
24
-
25
- it "should create widget token" do
26
- response = Veritrans.create_snap_token(
27
- transaction_details: {
28
- order_id: generate_order_id,
29
- gross_amount: 30_000
30
- }
31
- )
32
-
33
- response.should be_a(Veritrans::SnapResult)
34
- response.success?.should be_truthy
35
- response.token_id.should be_present
36
- response.token_id.should == response.data[:token_id]
37
- response.inspect.should =~ /#<Veritrans::SnapResult:\d+ \^\^ status: 200 time: \d+ms \^\^ data: \{token_id: "[\da-f\-]+"\}>/
38
- end
39
- end
data/testing_webhooks.md DELETED
@@ -1,78 +0,0 @@
1
- # Webhooks
2
-
3
- For better security we recommend to use webhooks and check status of transaction via api.
4
-
5
- Webhook is http post request that veritrans send to merchant's server when any transaction change status.
6
- It can be success transaction, can be failed transaction, and when transaction settled.
7
-
8
- Now you can set webhook url at https://my.sandbox.veritrans.co.id/settings/vtweb_configuration
9
-
10
- ## Veritrans command line tool
11
-
12
- You can send testing request from command line:
13
-
14
- ```bash
15
- gem install veritrans
16
-
17
- # Send default data, payment which not exists
18
- veritrans testhook http://localhost:3000/vt_events
19
-
20
- # Get fetch real payment information and send
21
- veritrans testhook -o my-order-1 -c ~/path/to/veritrans.yml http://localhost:3000/vt_events
22
- ```
23
-
24
- ## Test locally
25
-
26
- Most of computers don't have public ip address, in that case you can't simply receive http requests on your computer.
27
- If you're using wi-fi router you need to change router settings to make a route from router to your local computer.
28
- To check if your ip is public, you can open http://www.whatismyip.com/, make some local http server and try to open it.
29
- For example if your IP address is `117.102.113.10` and you started rails on port 3000, try to open http://117.102.113.10:3000 in your browser;
30
- if you able to see your application, then your IP is public.
31
-
32
- There are several tools to accept http requests if you can't do it directly.
33
-
34
- * npm localtunnel
35
- * https://ngrok.com/
36
- * gem [ultrahook](http://www.ultrahook.com/)
37
- * gem [forward](https://forwardhq.com/)
38
-
39
- Or you can make ssh tunnel to your globally accessible server (if you have one)
40
-
41
- ssh -N -R 127.0.0.1:13000:localhost:3000 remoteuser@remote-host.com
42
- # 3000 - port on your local computer
43
- # 13000 - port witch will be accessible on remote computer
44
- # remoteuser@remote-host.com - your user and host
45
-
46
- Also you can collect requests online for further inspection.
47
-
48
- * http://requestb.in/
49
- * http://httpi.pe/
50
-
51
-
52
- ## Trigger callback
53
-
54
- To receive http notification from veritrans you can try to make transaction or use callback tester in merchant portal
55
-
56
- https://my.sandbox.veritrans.co.id/settings/vtweb_configuration/test_callback
57
-
58
-
59
- ## Format
60
-
61
- Veritrans will try to send message in JSON format:
62
-
63
- ```js
64
- // Content-Type: application/json
65
- {
66
- "status_code": "200",
67
- "status_message": "Veritrans payment notification",
68
- "transaction_id": "826acc53-14e0-4ae7-95e2-845bf0311579",
69
- "order_id": "2014040745",
70
- "payment_type": "credit_card",
71
- "transaction_time": "2014-04-07 16:22:36",
72
- "transaction_status": "capture",
73
- "fraud_status": "accept",
74
- "masked_card": "411111-1111",
75
- "gross_amount": "2700"
76
- }
77
-
78
- ```