blockchyp 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/Makefile +71 -0
  3. data/README.md +997 -0
  4. data/Rakefile +39 -0
  5. data/lib/blockchyp.rb +190 -0
  6. data/lib/blockchyp/version.rb +5 -0
  7. data/lib/blockchyp_client.rb +346 -0
  8. data/lib/crypto_utils.rb +25 -0
  9. data/test/boolean_prompt_test.rb +43 -0
  10. data/test/capture_signature_test.rb +40 -0
  11. data/test/gateway_timeout_test.rb +40 -0
  12. data/test/heartbeat_test.rb +27 -0
  13. data/test/new_transaction_display_test.rb +78 -0
  14. data/test/pan_charge_test.rb +53 -0
  15. data/test/pan_enroll_test.rb +51 -0
  16. data/test/pan_preauth_test.rb +52 -0
  17. data/test/simple_batch_close_test.rb +48 -0
  18. data/test/simple_capture_test.rb +47 -0
  19. data/test/simple_gift_activate_test.rb +42 -0
  20. data/test/simple_message_test.rb +40 -0
  21. data/test/simple_ping_test.rb +39 -0
  22. data/test/simple_refund_test.rb +48 -0
  23. data/test/simple_reversal_test.rb +48 -0
  24. data/test/simple_void_test.rb +48 -0
  25. data/test/terminal_charge_test.rb +51 -0
  26. data/test/terminal_clear_test.rb +39 -0
  27. data/test/terminal_ebt_balance_test.rb +41 -0
  28. data/test/terminal_ebt_charge_test.rb +53 -0
  29. data/test/terminal_enroll_test.rb +50 -0
  30. data/test/terminal_gift_card_balance_test.rb +40 -0
  31. data/test/terminal_keyed_charge_test.rb +52 -0
  32. data/test/terminal_manual_ebt_charge_test.rb +54 -0
  33. data/test/terminal_preauth_test.rb +51 -0
  34. data/test/terminal_status_test.rb +39 -0
  35. data/test/terminal_timeout_test.rb +39 -0
  36. data/test/terms_and_conditions_test.rb +44 -0
  37. data/test/test_helper.rb +65 -0
  38. data/test/text_prompt_test.rb +41 -0
  39. data/test/update_transaction_display_test.rb +78 -0
  40. metadata +81 -0
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 BlockChyp, Inc. All rights reserved. Use of this code is
4
+ # governed by a license that can be found in the LICENSE file.
5
+ #
6
+ # This file was generated automatically. Changes to this file will be lost
7
+ # every time the code is regenerated.
8
+
9
+ require ::File.expand_path('test_helper', __dir__)
10
+
11
+ module BlockChyp
12
+ class TerminalEBTChargeTest < TestCase
13
+ def test_terminal_ebt_charge
14
+ config = load_test_config
15
+
16
+ blockchyp = BlockChyp.new(
17
+ config['apiKey'],
18
+ config['bearerToken'],
19
+ config['signingKey']
20
+ )
21
+ blockchyp.gateway_host = config['gatewayHost']
22
+ blockchyp.test_gateway_host = config['testGatewayHost']
23
+
24
+ test_delay(blockchyp, 'terminal_ebt_charge_test')
25
+
26
+ # setup request object
27
+ request = {}
28
+ request['terminalName'] = 'Test Terminal'
29
+ request['amount'] = '25.00'
30
+ request['test'] = true
31
+ request['cardType'] = CardType::EBT
32
+
33
+ response = blockchyp.charge(request)
34
+
35
+ assert_not_nil(response)
36
+ # response assertions
37
+ assert(response['success'])
38
+ assert(response['approved'])
39
+ assert(response['test'])
40
+ assert_equal(response['authCode'].length, 6)
41
+ assert(!response['transactionId'].empty?)
42
+ assert(!response['timestamp'].empty?)
43
+ assert(!response['tickBlock'].empty?)
44
+ assert_equal('Approved', response['responseDescription'])
45
+ assert(!response['paymentType'].empty?)
46
+ assert(!response['maskedPan'].empty?)
47
+ assert(!response['entryMethod'].empty?)
48
+ assert_equal('25.00', response['authorizedAmount'])
49
+ assert_equal('75.00', response['remainingBalance'])
50
+ end
51
+
52
+ end
53
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 BlockChyp, Inc. All rights reserved. Use of this code is
4
+ # governed by a license that can be found in the LICENSE file.
5
+ #
6
+ # This file was generated automatically. Changes to this file will be lost
7
+ # every time the code is regenerated.
8
+
9
+ require ::File.expand_path('test_helper', __dir__)
10
+
11
+ module BlockChyp
12
+ class TerminalEnrollTest < TestCase
13
+ def test_terminal_enroll
14
+ config = load_test_config
15
+
16
+ blockchyp = BlockChyp.new(
17
+ config['apiKey'],
18
+ config['bearerToken'],
19
+ config['signingKey']
20
+ )
21
+ blockchyp.gateway_host = config['gatewayHost']
22
+ blockchyp.test_gateway_host = config['testGatewayHost']
23
+
24
+ test_delay(blockchyp, 'terminal_enroll_test')
25
+
26
+ # setup request object
27
+ request = {}
28
+ request['terminalName'] = 'Test Terminal'
29
+ request['test'] = true
30
+
31
+ response = blockchyp.enroll(request)
32
+
33
+ assert_not_nil(response)
34
+ # response assertions
35
+ assert(response['success'])
36
+ assert(response['approved'])
37
+ assert(response['test'])
38
+ assert_equal(response['authCode'].length, 6)
39
+ assert(!response['transactionId'].empty?)
40
+ assert(!response['timestamp'].empty?)
41
+ assert(!response['tickBlock'].empty?)
42
+ assert_equal('Approved', response['responseDescription'])
43
+ assert(!response['paymentType'].empty?)
44
+ assert(!response['maskedPan'].empty?)
45
+ assert(!response['entryMethod'].empty?)
46
+ assert(!response['token'].empty?)
47
+ end
48
+
49
+ end
50
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 BlockChyp, Inc. All rights reserved. Use of this code is
4
+ # governed by a license that can be found in the LICENSE file.
5
+ #
6
+ # This file was generated automatically. Changes to this file will be lost
7
+ # every time the code is regenerated.
8
+
9
+ require ::File.expand_path('test_helper', __dir__)
10
+
11
+ module BlockChyp
12
+ class TerminalGiftCardBalanceTest < TestCase
13
+ def test_terminal_gift_card_balance
14
+ config = load_test_config
15
+
16
+ blockchyp = BlockChyp.new(
17
+ config['apiKey'],
18
+ config['bearerToken'],
19
+ config['signingKey']
20
+ )
21
+ blockchyp.gateway_host = config['gatewayHost']
22
+ blockchyp.test_gateway_host = config['testGatewayHost']
23
+
24
+ test_delay(blockchyp, 'terminal_gift_card_balance_test')
25
+
26
+ # setup request object
27
+ request = {}
28
+ request['test'] = true
29
+ request['terminalName'] = 'Test Terminal'
30
+
31
+ response = blockchyp.balance(request)
32
+
33
+ assert_not_nil(response)
34
+ # response assertions
35
+ assert(response['success'])
36
+ assert(!response['remainingBalance'].empty?)
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 BlockChyp, Inc. All rights reserved. Use of this code is
4
+ # governed by a license that can be found in the LICENSE file.
5
+ #
6
+ # This file was generated automatically. Changes to this file will be lost
7
+ # every time the code is regenerated.
8
+
9
+ require ::File.expand_path('test_helper', __dir__)
10
+
11
+ module BlockChyp
12
+ class TerminalKeyedChargeTest < TestCase
13
+ def test_terminal_keyed_charge
14
+ config = load_test_config
15
+
16
+ blockchyp = BlockChyp.new(
17
+ config['apiKey'],
18
+ config['bearerToken'],
19
+ config['signingKey']
20
+ )
21
+ blockchyp.gateway_host = config['gatewayHost']
22
+ blockchyp.test_gateway_host = config['testGatewayHost']
23
+
24
+ test_delay(blockchyp, 'terminal_keyed_charge_test')
25
+
26
+ # setup request object
27
+ request = {}
28
+ request['terminalName'] = 'Test Terminal'
29
+ request['amount'] = '11.11'
30
+ request['manualEntry'] = true
31
+ request['test'] = true
32
+
33
+ response = blockchyp.charge(request)
34
+
35
+ assert_not_nil(response)
36
+ # response assertions
37
+ assert(response['success'])
38
+ assert(response['approved'])
39
+ assert(response['test'])
40
+ assert_equal(response['authCode'].length, 6)
41
+ assert(!response['transactionId'].empty?)
42
+ assert(!response['timestamp'].empty?)
43
+ assert(!response['tickBlock'].empty?)
44
+ assert_equal('Approved', response['responseDescription'])
45
+ assert(!response['paymentType'].empty?)
46
+ assert(!response['maskedPan'].empty?)
47
+ assert(!response['entryMethod'].empty?)
48
+ assert_equal('11.11', response['authorizedAmount'])
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 BlockChyp, Inc. All rights reserved. Use of this code is
4
+ # governed by a license that can be found in the LICENSE file.
5
+ #
6
+ # This file was generated automatically. Changes to this file will be lost
7
+ # every time the code is regenerated.
8
+
9
+ require ::File.expand_path('test_helper', __dir__)
10
+
11
+ module BlockChyp
12
+ class TerminalManualEBTChargeTest < TestCase
13
+ def test_terminal_manual_ebt_charge
14
+ config = load_test_config
15
+
16
+ blockchyp = BlockChyp.new(
17
+ config['apiKey'],
18
+ config['bearerToken'],
19
+ config['signingKey']
20
+ )
21
+ blockchyp.gateway_host = config['gatewayHost']
22
+ blockchyp.test_gateway_host = config['testGatewayHost']
23
+
24
+ test_delay(blockchyp, 'terminal_manual_ebt_charge_test')
25
+
26
+ # setup request object
27
+ request = {}
28
+ request['terminalName'] = 'Test Terminal'
29
+ request['amount'] = '27.00'
30
+ request['test'] = true
31
+ request['cardType'] = CardType::EBT
32
+ request['manualEntry'] = true
33
+
34
+ response = blockchyp.charge(request)
35
+
36
+ assert_not_nil(response)
37
+ # response assertions
38
+ assert(response['success'])
39
+ assert(response['approved'])
40
+ assert(response['test'])
41
+ assert_equal(response['authCode'].length, 6)
42
+ assert(!response['transactionId'].empty?)
43
+ assert(!response['timestamp'].empty?)
44
+ assert(!response['tickBlock'].empty?)
45
+ assert_equal('Approved', response['responseDescription'])
46
+ assert(!response['paymentType'].empty?)
47
+ assert(!response['maskedPan'].empty?)
48
+ assert(!response['entryMethod'].empty?)
49
+ assert_equal('27.00', response['authorizedAmount'])
50
+ assert_equal('73.00', response['remainingBalance'])
51
+ end
52
+
53
+ end
54
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 BlockChyp, Inc. All rights reserved. Use of this code is
4
+ # governed by a license that can be found in the LICENSE file.
5
+ #
6
+ # This file was generated automatically. Changes to this file will be lost
7
+ # every time the code is regenerated.
8
+
9
+ require ::File.expand_path('test_helper', __dir__)
10
+
11
+ module BlockChyp
12
+ class TerminalPreauthTest < TestCase
13
+ def test_terminal_preauth
14
+ config = load_test_config
15
+
16
+ blockchyp = BlockChyp.new(
17
+ config['apiKey'],
18
+ config['bearerToken'],
19
+ config['signingKey']
20
+ )
21
+ blockchyp.gateway_host = config['gatewayHost']
22
+ blockchyp.test_gateway_host = config['testGatewayHost']
23
+
24
+ test_delay(blockchyp, 'terminal_preauth_test')
25
+
26
+ # setup request object
27
+ request = {}
28
+ request['terminalName'] = 'Test Terminal'
29
+ request['amount'] = '15.15'
30
+ request['test'] = true
31
+
32
+ response = blockchyp.preauth(request)
33
+
34
+ assert_not_nil(response)
35
+ # response assertions
36
+ assert(response['success'])
37
+ assert(response['approved'])
38
+ assert(response['test'])
39
+ assert_equal(response['authCode'].length, 6)
40
+ assert(!response['transactionId'].empty?)
41
+ assert(!response['timestamp'].empty?)
42
+ assert(!response['tickBlock'].empty?)
43
+ assert_equal('Approved', response['responseDescription'])
44
+ assert(!response['paymentType'].empty?)
45
+ assert(!response['maskedPan'].empty?)
46
+ assert(!response['entryMethod'].empty?)
47
+ assert_equal('15.15', response['authorizedAmount'])
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 BlockChyp, Inc. All rights reserved. Use of this code is
4
+ # governed by a license that can be found in the LICENSE file.
5
+ #
6
+ # This file was generated automatically. Changes to this file will be lost
7
+ # every time the code is regenerated.
8
+
9
+ require ::File.expand_path('test_helper', __dir__)
10
+
11
+ module BlockChyp
12
+ class TerminalStatusTest < TestCase
13
+ def test_terminal_status
14
+ config = load_test_config
15
+
16
+ blockchyp = BlockChyp.new(
17
+ config['apiKey'],
18
+ config['bearerToken'],
19
+ config['signingKey']
20
+ )
21
+ blockchyp.gateway_host = config['gatewayHost']
22
+ blockchyp.test_gateway_host = config['testGatewayHost']
23
+
24
+ test_delay(blockchyp, 'terminal_status_test')
25
+
26
+ # setup request object
27
+ request = {}
28
+ request['terminalName'] = 'Test Terminal'
29
+
30
+ response = blockchyp.terminal_status(request)
31
+
32
+ assert_not_nil(response)
33
+ # response assertions
34
+ assert(response['success'])
35
+ assert(response['idle'])
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 BlockChyp, Inc. All rights reserved. Use of this code is
4
+ # governed by a license that can be found in the LICENSE file.
5
+ #
6
+ # This file was generated automatically. Changes to this file will be lost
7
+ # every time the code is regenerated.
8
+
9
+ require ::File.expand_path('test_helper', __dir__)
10
+
11
+ module BlockChyp
12
+ class TerminalTimeoutTest < TestCase
13
+ def test_terminal_timeout
14
+ config = load_test_config
15
+
16
+ blockchyp = BlockChyp.new(
17
+ config['apiKey'],
18
+ config['bearerToken'],
19
+ config['signingKey']
20
+ )
21
+ blockchyp.gateway_host = config['gatewayHost']
22
+ blockchyp.test_gateway_host = config['testGatewayHost']
23
+
24
+ test_delay(blockchyp, 'terminal_timeout_test')
25
+
26
+ # setup request object
27
+ request = {}
28
+ request['timeout'] = 1
29
+ request['terminalName'] = 'Test Terminal'
30
+ request['amount'] = '25.15'
31
+ request['test'] = true
32
+
33
+ assert_raise Net::ReadTimeout do
34
+ blockchyp.charge(request)
35
+ end
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 BlockChyp, Inc. All rights reserved. Use of this code is
4
+ # governed by a license that can be found in the LICENSE file.
5
+ #
6
+ # This file was generated automatically. Changes to this file will be lost
7
+ # every time the code is regenerated.
8
+
9
+ require ::File.expand_path('test_helper', __dir__)
10
+
11
+ module BlockChyp
12
+ class TermsAndConditionsTest < TestCase
13
+ def test_terms_and_conditions
14
+ config = load_test_config
15
+
16
+ blockchyp = BlockChyp.new(
17
+ config['apiKey'],
18
+ config['bearerToken'],
19
+ config['signingKey']
20
+ )
21
+ blockchyp.gateway_host = config['gatewayHost']
22
+ blockchyp.test_gateway_host = config['testGatewayHost']
23
+
24
+ test_delay(blockchyp, 'terms_and_conditions_test')
25
+
26
+ # setup request object
27
+ request = {}
28
+ request['test'] = true
29
+ request['terminalName'] = 'Test Terminal'
30
+ request['tcName'] = 'HIPPA Disclosure'
31
+ request['tcContent'] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ullamcorper id urna quis pulvinar. Pellentesque vestibulum justo ac nulla consectetur tristique. Suspendisse arcu arcu, viverra vel luctus non, dapibus vitae augue. Aenean ac volutpat purus. Curabitur in lacus nisi. Nam vel sagittis eros. Curabitur faucibus ut nisl in pulvinar. Nunc egestas, orci ut porttitor tempus, ante mauris pellentesque ex, nec feugiat purus arcu ac metus. Cras sodales ornare lobortis. Aenean lacinia ultricies purus quis pharetra. Cras vestibulum nulla et magna eleifend eleifend. Nunc nibh dolor, malesuada ut suscipit vitae, bibendum quis dolor. Phasellus ultricies ex vitae dolor malesuada, vel dignissim neque accumsan.'
32
+ request['sigFormat'] = SignatureFormat::PNG
33
+ request['sigWidth'] = 200
34
+ request['sigRequired'] = true
35
+
36
+ response = blockchyp.terms_and_conditions(request)
37
+
38
+ assert_not_nil(response)
39
+ # response assertions
40
+ assert(response['success'])
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'etc'
4
+ require 'json'
5
+ require 'securerandom'
6
+
7
+ require 'test/unit'
8
+
9
+ require ::File.expand_path('../lib/blockchyp', __dir__)
10
+
11
+ module BlockChyp
12
+ class TestCase < Test::Unit::TestCase
13
+ def load_test_config
14
+ config_home = ''
15
+ if windows?
16
+ config_home = ENV['userprofile']
17
+ else
18
+ config_home = ENV['XDG_CONFIG_HOME']
19
+ if config_home.nil?
20
+ config_home = ENV['HOME']
21
+ end
22
+ config_home = File.join(config_home, '.config')
23
+ end
24
+
25
+ file_name = File.join(config_home, 'blockchyp', 'sdk-itest-config.json')
26
+
27
+ puts 'load config: ' + file_name
28
+
29
+ raise 'file not found: ' + file_name unless File.file?(file_name)
30
+
31
+ config_file = File.open(file_name)
32
+ content = config_file.read
33
+
34
+ JSON.parse(content)
35
+ end
36
+
37
+ def test_delay(client, test_name)
38
+ test_delay = ENV['BC_TEST_DELAY']
39
+
40
+ if test_delay
41
+ test_delay_int = Integer(test_delay)
42
+ if test_delay_int.positive?
43
+ request = {}
44
+ request['test'] = true
45
+ request['terminalName'] = 'Test Terminal'
46
+ request['message'] = "Running #{test_name} in #{test_delay} seconds.."
47
+ response = client.message(request)
48
+
49
+ assert_not_nil(response)
50
+ # response assertions
51
+ assert(response['success'])
52
+ sleep test_delay_int
53
+ end
54
+ end
55
+ end
56
+
57
+ def uuid
58
+ SecureRandom.uuid
59
+ end
60
+
61
+ def windows?
62
+ !(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM).nil?
63
+ end
64
+ end
65
+ end