blockchyp 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Makefile +71 -0
- data/README.md +997 -0
- data/Rakefile +39 -0
- data/lib/blockchyp.rb +190 -0
- data/lib/blockchyp/version.rb +5 -0
- data/lib/blockchyp_client.rb +346 -0
- data/lib/crypto_utils.rb +25 -0
- data/test/boolean_prompt_test.rb +43 -0
- data/test/capture_signature_test.rb +40 -0
- data/test/gateway_timeout_test.rb +40 -0
- data/test/heartbeat_test.rb +27 -0
- data/test/new_transaction_display_test.rb +78 -0
- data/test/pan_charge_test.rb +53 -0
- data/test/pan_enroll_test.rb +51 -0
- data/test/pan_preauth_test.rb +52 -0
- data/test/simple_batch_close_test.rb +48 -0
- data/test/simple_capture_test.rb +47 -0
- data/test/simple_gift_activate_test.rb +42 -0
- data/test/simple_message_test.rb +40 -0
- data/test/simple_ping_test.rb +39 -0
- data/test/simple_refund_test.rb +48 -0
- data/test/simple_reversal_test.rb +48 -0
- data/test/simple_void_test.rb +48 -0
- data/test/terminal_charge_test.rb +51 -0
- data/test/terminal_clear_test.rb +39 -0
- data/test/terminal_ebt_balance_test.rb +41 -0
- data/test/terminal_ebt_charge_test.rb +53 -0
- data/test/terminal_enroll_test.rb +50 -0
- data/test/terminal_gift_card_balance_test.rb +40 -0
- data/test/terminal_keyed_charge_test.rb +52 -0
- data/test/terminal_manual_ebt_charge_test.rb +54 -0
- data/test/terminal_preauth_test.rb +51 -0
- data/test/terminal_status_test.rb +39 -0
- data/test/terminal_timeout_test.rb +39 -0
- data/test/terms_and_conditions_test.rb +44 -0
- data/test/test_helper.rb +65 -0
- data/test/text_prompt_test.rb +41 -0
- data/test/update_transaction_display_test.rb +78 -0
- metadata +81 -0
data/lib/crypto_utils.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'securerandom'
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
module BlockChyp
|
7
|
+
# crypto and encoding utilities
|
8
|
+
class CryptoUtils
|
9
|
+
def self.generate_nonce
|
10
|
+
bin2hex(SecureRandom.bytes(32))
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.timestamp
|
14
|
+
Time.now.utc.to_datetime.rfc3339
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.bin2hex(val)
|
18
|
+
val.each_byte.map { |b| b.to_s(16) }.join
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.hex2bin(val)
|
22
|
+
val.scan(/../).map { |x| x.hex.chr }.join
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,43 @@
|
|
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 BooleanPromptTest < TestCase
|
13
|
+
def test_boolean_prompt
|
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, 'boolean_prompt_test')
|
25
|
+
|
26
|
+
# setup request object
|
27
|
+
request = {}
|
28
|
+
request['test'] = true
|
29
|
+
request['terminalName'] = 'Test Terminal'
|
30
|
+
request['prompt'] = 'Would you like to become a member?'
|
31
|
+
request['yesCaption'] = 'Yes'
|
32
|
+
request['noCaption'] = 'No'
|
33
|
+
|
34
|
+
response = blockchyp.boolean_prompt(request)
|
35
|
+
|
36
|
+
assert_not_nil(response)
|
37
|
+
# response assertions
|
38
|
+
assert(response['success'])
|
39
|
+
assert(response['response'])
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
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 CaptureSignatureTest < TestCase
|
13
|
+
def test_capture_signature
|
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, 'capture_signature_test')
|
25
|
+
|
26
|
+
# setup request object
|
27
|
+
request = {}
|
28
|
+
request['terminalName'] = 'Test Terminal'
|
29
|
+
request['sigFormat'] = SignatureFormat::PNG
|
30
|
+
request['sigWidth'] = 200
|
31
|
+
|
32
|
+
response = blockchyp.capture_signature(request)
|
33
|
+
|
34
|
+
assert_not_nil(response)
|
35
|
+
# response assertions
|
36
|
+
assert(response['success'])
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
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 GatewayTimeoutTest < TestCase
|
13
|
+
def test_gateway_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, 'gateway_timeout_test')
|
25
|
+
|
26
|
+
# setup request object
|
27
|
+
request = {}
|
28
|
+
request['timeout'] = 1
|
29
|
+
request['pan'] = '5555555555554444'
|
30
|
+
request['amount'] = '25.55'
|
31
|
+
request['test'] = true
|
32
|
+
request['transactionRef'] = uuid
|
33
|
+
|
34
|
+
assert_raise Net::ReadTimeout do
|
35
|
+
blockchyp.charge(request)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require ::File.expand_path('test_helper', __dir__)
|
4
|
+
|
5
|
+
module BlockChyp
|
6
|
+
class HeartbeatTest < TestCase
|
7
|
+
def test_heartbeat
|
8
|
+
config = load_test_config
|
9
|
+
|
10
|
+
blockchyp = BlockChyp.new(
|
11
|
+
config['apiKey'],
|
12
|
+
config['bearerToken'],
|
13
|
+
config['signingKey']
|
14
|
+
)
|
15
|
+
blockchyp.gateway_host = config['gatewayHost']
|
16
|
+
blockchyp.test_gateway_host = config['testGatewayHost']
|
17
|
+
|
18
|
+
response = blockchyp.heartbeat(true)
|
19
|
+
assert_not_nil(response)
|
20
|
+
assert(response['success'])
|
21
|
+
assert(!response['timestamp'].empty?)
|
22
|
+
assert(!response['clockchain'].empty?)
|
23
|
+
assert(!response['latestTick'].empty?)
|
24
|
+
assert(!response['merchantPk'].empty?)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,78 @@
|
|
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 NewTransactionDisplayTest < TestCase
|
13
|
+
def test_new_transaction_display
|
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, 'new_transaction_display_test')
|
25
|
+
|
26
|
+
# setup request object
|
27
|
+
request = {}
|
28
|
+
request['test'] = true
|
29
|
+
request['terminalName'] = 'Test Terminal'
|
30
|
+
request['transaction'] = new_transaction_display_transaction
|
31
|
+
|
32
|
+
response = blockchyp.new_transaction_display(request)
|
33
|
+
|
34
|
+
assert_not_nil(response)
|
35
|
+
# response assertions
|
36
|
+
assert(response['success'])
|
37
|
+
end
|
38
|
+
|
39
|
+
def new_transaction_display_transaction
|
40
|
+
val = {}
|
41
|
+
val['subtotal'] = '35.00'
|
42
|
+
val['tax'] = '5.00'
|
43
|
+
val['total'] = '70.00'
|
44
|
+
val['items'] = new_transaction_display_items
|
45
|
+
val
|
46
|
+
end
|
47
|
+
|
48
|
+
def new_transaction_display_items
|
49
|
+
val = []
|
50
|
+
val.push(new_transaction_display_item_2)
|
51
|
+
val
|
52
|
+
end
|
53
|
+
|
54
|
+
def new_transaction_display_item_2
|
55
|
+
val = {}
|
56
|
+
val['description'] = 'Leki Trekking Poles'
|
57
|
+
val['price'] = '35.00'
|
58
|
+
val['quantity'] = 2
|
59
|
+
val['extended'] = '70.00'
|
60
|
+
val['discounts'] = new_transaction_display_discounts
|
61
|
+
val
|
62
|
+
end
|
63
|
+
|
64
|
+
def new_transaction_display_discounts
|
65
|
+
val = []
|
66
|
+
val.push(new_transaction_display_discount_2)
|
67
|
+
val
|
68
|
+
end
|
69
|
+
|
70
|
+
def new_transaction_display_discount_2
|
71
|
+
val = {}
|
72
|
+
val['description'] = 'memberDiscount'
|
73
|
+
val['amount'] = '10.00'
|
74
|
+
val
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
@@ -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 PANChargeTest < TestCase
|
13
|
+
def test_pan_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, 'pan_charge_test')
|
25
|
+
|
26
|
+
# setup request object
|
27
|
+
request = {}
|
28
|
+
request['pan'] = '4111111111111111'
|
29
|
+
request['amount'] = '25.55'
|
30
|
+
request['test'] = true
|
31
|
+
request['transactionRef'] = uuid
|
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.55', response['authorizedAmount'])
|
49
|
+
assert_equal('KEYED', response['entryMethod'])
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
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 PANEnrollTest < TestCase
|
13
|
+
def test_pan_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, 'pan_enroll_test')
|
25
|
+
|
26
|
+
# setup request object
|
27
|
+
request = {}
|
28
|
+
request['pan'] = '4111111111111111'
|
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_equal('KEYED', response['entryMethod'])
|
47
|
+
assert(!response['token'].empty?)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
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 PANPreauthTest < TestCase
|
13
|
+
def test_pan_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, 'pan_preauth_test')
|
25
|
+
|
26
|
+
# setup request object
|
27
|
+
request = {}
|
28
|
+
request['pan'] = '4111111111111111'
|
29
|
+
request['amount'] = '25.55'
|
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('25.55', response['authorizedAmount'])
|
48
|
+
assert_equal('KEYED', response['entryMethod'])
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,48 @@
|
|
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 SimpleBatchCloseTest < TestCase
|
13
|
+
def test_simple_batch_close
|
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, 'simple_batch_close_test')
|
25
|
+
# setup request object
|
26
|
+
request = {}
|
27
|
+
request['pan'] = '4111111111111111'
|
28
|
+
request['amount'] = '25.55'
|
29
|
+
request['test'] = true
|
30
|
+
request['transactionRef'] = uuid
|
31
|
+
response = blockchyp.charge(request)
|
32
|
+
|
33
|
+
|
34
|
+
# setup request object
|
35
|
+
request = {}
|
36
|
+
request['test'] = true
|
37
|
+
|
38
|
+
response = blockchyp.close_batch(request)
|
39
|
+
|
40
|
+
assert_not_nil(response)
|
41
|
+
# response assertions
|
42
|
+
assert(response['success'])
|
43
|
+
assert(!response['capturedTotal'].empty?)
|
44
|
+
assert(!response['openPreauths'].empty?)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|