bitpay-sdk 2.1.1 → 2.2.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.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/features/step_definitions/invoice_steps.rb +1 -1
- data/features/step_definitions/keygen_steps.rb +3 -3
- data/features/step_definitions/step_helpers.rb +4 -6
- data/lib/bitpay/client.rb +145 -143
- data/lib/bitpay/key_utils.rb +1 -1
- data/lib/bitpay/version.rb +1 -1
- data/lib/{bitpay.rb → bitpay_sdk.rb} +1 -1
- data/spec/client_spec.rb +2 -2
- data/spec/features/pair_spec.rb +1 -1
- data/spec/features/pos_spec.rb +1 -1
- data/spec/features/verify_tokens_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -3
- metadata +3 -4
- data/lib/harness.rb +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05ceac9c5a451d327ccaca3d7d5df7b4b791612e
|
4
|
+
data.tar.gz: 8bd0c8fd5d09f22b9a90dfcb8dd80ea841b70b4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35f0005e156651cf165e3ae64bd42feecca410d7a9ac01dc0dcf3fd4c1e9596cbfe3d45de8c7a98214f95d0fe9ac8fca1a5e96707dbfd2064db9f5abd477353d
|
7
|
+
data.tar.gz: 431badf6d99383c1670af5f60599186a6c830e62953de356c93e913dedcc6d5738d588de75aadb1cdcc10e45a4edb31ea215845fc6d584d037012842a28f86bd
|
data/README.md
CHANGED
@@ -3,15 +3,15 @@ Powerful, flexible, lightweight interface to the BitPay Bitcoin Payment Gateway
|
|
3
3
|
|
4
4
|
## Installation
|
5
5
|
|
6
|
-
gem install bitpay
|
6
|
+
gem install bitpay-sdk
|
7
7
|
|
8
8
|
In your Gemfile:
|
9
9
|
|
10
|
-
gem 'bitpay', :require => '
|
10
|
+
gem 'bitpay-sdk', :require => 'bitpay_sdk'
|
11
11
|
|
12
12
|
Or directly:
|
13
13
|
|
14
|
-
require '
|
14
|
+
require 'bitpay_sdk'
|
15
15
|
|
16
16
|
## Configuration
|
17
17
|
|
@@ -20,7 +20,7 @@ Given(/^that a user knows an invoice id$/) do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
Then(/^they can retrieve that invoice$/) do
|
23
|
-
invoice = BitPay::Client.new(api_uri: ROOT_ADDRESS, insecure: true).get_public_invoice(id: @id)
|
23
|
+
invoice = BitPay::SDK::Client.new(api_uri: ROOT_ADDRESS, insecure: true).get_public_invoice(id: @id)
|
24
24
|
raise "That's the wrong invoice" unless invoice['id'] == @id
|
25
25
|
end
|
26
26
|
|
@@ -4,14 +4,14 @@
|
|
4
4
|
When(/^the user pairs with BitPay(?: with a valid pairing code|)$/) do
|
5
5
|
claim_code = get_claim_code_from_server
|
6
6
|
pem = BitPay::KeyUtils.generate_pem
|
7
|
-
@client = BitPay::Client.new(api_uri: ROOT_ADDRESS, pem: pem, insecure: true)
|
7
|
+
@client = BitPay::SDK::Client.new(api_uri: ROOT_ADDRESS, pem: pem, insecure: true)
|
8
8
|
@token = @client.pair_pos_client(claim_code)
|
9
9
|
end
|
10
10
|
|
11
11
|
When(/^the fails to pair with BitPay because of an incorrect port$/) do
|
12
12
|
pem = BitPay::KeyUtils.generate_pem
|
13
13
|
address = ROOT_ADDRESS.split(':').slice(0,2).join(':') + ":999"
|
14
|
-
client = BitPay::Client.new(api_uri: address, pem: pem, insecure: true)
|
14
|
+
client = BitPay::SDK::Client.new(api_uri: address, pem: pem, insecure: true)
|
15
15
|
begin
|
16
16
|
client.pair_pos_client("1ab2c34")
|
17
17
|
raise "pairing unexpectedly worked"
|
@@ -35,7 +35,7 @@ end
|
|
35
35
|
|
36
36
|
Then(/^the user fails to pair with a semantically (?:in|)valid code "(.*?)"$/) do |code|
|
37
37
|
pem = BitPay::KeyUtils.generate_pem
|
38
|
-
client = BitPay::Client.new(api_uri: ROOT_ADDRESS, pem: pem, insecure: true)
|
38
|
+
client = BitPay::SDK::Client.new(api_uri: ROOT_ADDRESS, pem: pem, insecure: true)
|
39
39
|
begin
|
40
40
|
client.pair_pos_client(code)
|
41
41
|
raise "pairing unexpectedly worked"
|
@@ -1,9 +1,7 @@
|
|
1
1
|
require 'capybara/poltergeist'
|
2
2
|
require 'pry'
|
3
3
|
|
4
|
-
require File.join File.dirname(__FILE__), '..', '..', 'lib', '
|
5
|
-
require File.join File.dirname(__FILE__), '..', '..', 'lib', 'bitpay', 'key_utils.rb'
|
6
|
-
require File.join File.dirname(__FILE__), '..', '..', 'lib', 'bitpay.rb'
|
4
|
+
require File.join File.dirname(__FILE__), '..', '..', 'lib', 'bitpay_sdk.rb'
|
7
5
|
require_relative '../../config/constants.rb'
|
8
6
|
require_relative '../../config/capybara.rb'
|
9
7
|
|
@@ -48,7 +46,7 @@ end
|
|
48
46
|
def new_paired_client
|
49
47
|
claim_code = get_claim_code_from_server
|
50
48
|
pem = BitPay::KeyUtils.generate_pem
|
51
|
-
client = BitPay::Client.new(api_uri: ROOT_ADDRESS, pem: pem, insecure: true)
|
49
|
+
client = BitPay::SDK::Client.new(api_uri: ROOT_ADDRESS, pem: pem, insecure: true)
|
52
50
|
client.pair_pos_client(claim_code)
|
53
51
|
client
|
54
52
|
end
|
@@ -57,11 +55,11 @@ def new_client_from_stored_values
|
|
57
55
|
if File.file?(BitPay::PRIVATE_KEY_PATH) && File.file?(BitPay::TOKEN_FILE_PATH)
|
58
56
|
token = get_token_from_file
|
59
57
|
pem = File.read(BitPay::PRIVATE_KEY_PATH)
|
60
|
-
BitPay::Client.new(pem: pem, tokens: token, insecure: true, api_uri: ROOT_ADDRESS )
|
58
|
+
BitPay::SDK::Client.new(pem: pem, tokens: token, insecure: true, api_uri: ROOT_ADDRESS )
|
61
59
|
else
|
62
60
|
claim_code = get_claim_code_from_server
|
63
61
|
pem = BitPay::KeyUtils.generate_pem
|
64
|
-
client = BitPay::Client.new(api_uri: ROOT_ADDRESS, pem: pem, insecure: true)
|
62
|
+
client = BitPay::SDK::Client.new(api_uri: ROOT_ADDRESS, pem: pem, insecure: true)
|
65
63
|
token = client.pair_pos_client(claim_code)
|
66
64
|
File.write(BitPay::PRIVATE_KEY_PATH, pem)
|
67
65
|
File.write(BitPay::TOKEN_FILE_PATH, JSON.generate(token))
|
data/lib/bitpay/client.rb
CHANGED
@@ -11,171 +11,173 @@ require_relative 'key_utils'
|
|
11
11
|
module BitPay
|
12
12
|
# This class is used to instantiate a BitPay Client object. It is expected to be thread safe.
|
13
13
|
#
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
# @return [Client]
|
18
|
-
# @example
|
19
|
-
# # Create a client with a pem file created by the bitpay client:
|
20
|
-
# client = BitPay::Client.new
|
21
|
-
def initialize(opts={})
|
22
|
-
@pem = opts[:pem] || ENV['BITPAY_PEM'] || KeyUtils.generate_pem
|
23
|
-
@key = KeyUtils.create_key @pem
|
24
|
-
@priv_key = KeyUtils.get_private_key @key
|
25
|
-
@pub_key = KeyUtils.get_public_key @key
|
26
|
-
@client_id = KeyUtils.generate_sin_from_pem @pem
|
27
|
-
@uri = URI.parse opts[:api_uri] || API_URI
|
28
|
-
@user_agent = opts[:user_agent] || USER_AGENT
|
29
|
-
@https = Net::HTTP.new @uri.host, @uri.port
|
30
|
-
@https.use_ssl = true
|
31
|
-
@https.ca_file = CA_FILE
|
32
|
-
@tokens = opts[:tokens] || {}
|
33
|
-
|
34
|
-
# Option to disable certificate validation in extraordinary circumstance. NOT recommended for production use
|
35
|
-
@https.verify_mode = opts[:insecure] == true ? OpenSSL::SSL::VERIFY_NONE : OpenSSL::SSL::VERIFY_PEER
|
14
|
+
module SDK
|
15
|
+
class Client
|
36
16
|
|
37
|
-
# Option to enable http request debugging
|
38
|
-
@https.set_debug_output($stdout) if opts[:debug] == true
|
39
17
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
def set_token
|
64
|
-
end
|
18
|
+
# @return [Client]
|
19
|
+
# @example
|
20
|
+
# # Create a client with a pem file created by the bitpay client:
|
21
|
+
# client = BitPay::Client.new
|
22
|
+
def initialize(opts={})
|
23
|
+
@pem = opts[:pem] || ENV['BITPAY_PEM'] || KeyUtils.generate_pem
|
24
|
+
@key = KeyUtils.create_key @pem
|
25
|
+
@priv_key = KeyUtils.get_private_key @key
|
26
|
+
@pub_key = KeyUtils.get_public_key @key
|
27
|
+
@client_id = KeyUtils.generate_sin_from_pem @pem
|
28
|
+
@uri = URI.parse opts[:api_uri] || API_URI
|
29
|
+
@user_agent = opts[:user_agent] || USER_AGENT
|
30
|
+
@https = Net::HTTP.new @uri.host, @uri.port
|
31
|
+
@https.use_ssl = true
|
32
|
+
@https.ca_file = CA_FILE
|
33
|
+
@tokens = opts[:tokens] || {}
|
34
|
+
|
35
|
+
# Option to disable certificate validation in extraordinary circumstance. NOT recommended for production use
|
36
|
+
@https.verify_mode = opts[:insecure] == true ? OpenSSL::SSL::VERIFY_NONE : OpenSSL::SSL::VERIFY_PEER
|
37
|
+
|
38
|
+
# Option to enable http request debugging
|
39
|
+
@https.set_debug_output($stdout) if opts[:debug] == true
|
65
40
|
|
66
|
-
def verify_token
|
67
|
-
server_tokens = load_tokens
|
68
|
-
@tokens.each{|key, value| return false if server_tokens[key] != value}
|
69
|
-
return true
|
70
|
-
end
|
71
|
-
## Generates REST request to api endpoint
|
72
|
-
|
73
|
-
def send_request(verb, path, facade: 'merchant', params: {}, token: nil)
|
74
|
-
token ||= get_token(facade)
|
75
|
-
|
76
|
-
# Verb-specific logic
|
77
|
-
case verb.upcase
|
78
|
-
when "GET"
|
79
|
-
urlpath = '/' + path + '?nonce=' + KeyUtils.nonce + '&token=' + token
|
80
|
-
request = Net::HTTP::Get.new urlpath
|
81
|
-
request['X-Signature'] = KeyUtils.sign(@uri.to_s + urlpath, @priv_key)
|
82
|
-
|
83
|
-
when "PUT"
|
84
|
-
|
85
|
-
when "POST" # Requires a GUID
|
86
|
-
|
87
|
-
urlpath = '/' + path
|
88
|
-
request = Net::HTTP::Post.new urlpath
|
89
|
-
params[:token] = token
|
90
|
-
params[:nonce] = KeyUtils.nonce
|
91
|
-
params[:guid] = SecureRandom.uuid
|
92
|
-
params[:id] = @client_id
|
93
|
-
request.body = params.to_json
|
94
|
-
request['X-Signature'] = KeyUtils.sign(@uri.to_s + urlpath + request.body, @priv_key)
|
95
|
-
|
96
|
-
when "DELETE"
|
97
|
-
|
98
|
-
raise(BitPayError, "Invalid HTTP verb: #{verb.upcase}")
|
99
41
|
end
|
100
42
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
##### PRIVATE METHODS #####
|
108
|
-
private
|
43
|
+
def pair_pos_client(claimCode)
|
44
|
+
raise BitPay::ArgumentError, "pairing code is not legal" unless verify_claim_code(claimCode)
|
45
|
+
response = set_pos_token(claimCode)
|
46
|
+
get_token 'pos'
|
47
|
+
response
|
48
|
+
end
|
109
49
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
50
|
+
def create_invoice(price:, currency:, facade: 'pos', params:{})
|
51
|
+
raise BitPay::ArgumentError, "Illegal Argument: Price must be formatted as a float" unless ( price.is_a?(Numeric) || /^[[:digit:]]+(\.[[:digit:]]{2})?$/.match(price) )
|
52
|
+
raise BitPay::ArgumentError, "Illegal Argument: Currency is invalid." unless /^[[:upper:]]{3}$/.match(currency)
|
53
|
+
params.merge!({price: price, currency: currency})
|
54
|
+
response = send_request("POST", "invoices", facade: facade, params: params)
|
55
|
+
response["data"]
|
56
|
+
end
|
114
57
|
|
115
|
-
|
116
|
-
|
117
|
-
|
58
|
+
def get_public_invoice(id:)
|
59
|
+
request = Net::HTTP::Get.new("/invoices/#{id}")
|
60
|
+
response = process_request(request)
|
61
|
+
response["data"]
|
62
|
+
end
|
63
|
+
|
64
|
+
def set_token
|
65
|
+
end
|
118
66
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
67
|
+
def verify_token
|
68
|
+
server_tokens = load_tokens
|
69
|
+
@tokens.each{|key, value| return false if server_tokens[key] != value}
|
70
|
+
return true
|
71
|
+
end
|
72
|
+
## Generates REST request to api endpoint
|
73
|
+
|
74
|
+
def send_request(verb, path, facade: 'merchant', params: {}, token: nil)
|
75
|
+
token ||= get_token(facade)
|
76
|
+
|
77
|
+
# Verb-specific logic
|
78
|
+
case verb.upcase
|
79
|
+
when "GET"
|
80
|
+
urlpath = '/' + path + '?nonce=' + KeyUtils.nonce + '&token=' + token
|
81
|
+
request = Net::HTTP::Get.new urlpath
|
82
|
+
request['X-Signature'] = KeyUtils.sign(@uri.to_s + urlpath, @priv_key)
|
83
|
+
|
84
|
+
when "PUT"
|
85
|
+
|
86
|
+
when "POST" # Requires a GUID
|
87
|
+
|
88
|
+
urlpath = '/' + path
|
89
|
+
request = Net::HTTP::Post.new urlpath
|
90
|
+
params[:token] = token
|
91
|
+
params[:nonce] = KeyUtils.nonce
|
92
|
+
params[:guid] = SecureRandom.uuid
|
93
|
+
params[:id] = @client_id
|
94
|
+
request.body = params.to_json
|
95
|
+
request['X-Signature'] = KeyUtils.sign(@uri.to_s + urlpath + request.body, @priv_key)
|
96
|
+
|
97
|
+
when "DELETE"
|
98
|
+
|
99
|
+
raise(BitPayError, "Invalid HTTP verb: #{verb.upcase}")
|
100
|
+
end
|
101
|
+
|
102
|
+
# Build request headers and submit
|
103
|
+
request['X-Identity'] = @pub_key
|
104
|
+
|
105
|
+
response = process_request(request)
|
123
106
|
end
|
124
107
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
108
|
+
##### PRIVATE METHODS #####
|
109
|
+
private
|
110
|
+
|
111
|
+
## Processes HTTP Request and returns parsed response
|
112
|
+
# Otherwise throws error
|
113
|
+
#
|
114
|
+
def process_request(request)
|
115
|
+
|
116
|
+
request['User-Agent'] = @user_agent
|
117
|
+
request['Content-Type'] = 'application/json'
|
118
|
+
request['X-BitPay-Plugin-Info'] = 'Rubylib' + VERSION
|
119
|
+
|
120
|
+
begin
|
121
|
+
response = @https.request request
|
122
|
+
rescue => error
|
123
|
+
raise BitPay::ConnectionError, "#{error.message}"
|
124
|
+
end
|
125
|
+
|
126
|
+
if response.kind_of? Net::HTTPSuccess
|
127
|
+
return JSON.parse(response.body)
|
128
|
+
elsif JSON.parse(response.body)["error"]
|
129
|
+
raise(BitPayError, "#{response.code}: #{JSON.parse(response.body)['error']}")
|
130
|
+
else
|
131
|
+
raise BitPayError, "#{response.code}: #{JSON.parse(response.body)}"
|
132
|
+
end
|
133
|
+
|
131
134
|
end
|
132
|
-
|
133
|
-
end
|
134
135
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
136
|
+
## Requests token by appending nonce and signing URL
|
137
|
+
# Returns a hash of available tokens
|
138
|
+
#
|
139
|
+
def load_tokens
|
139
140
|
|
140
|
-
|
141
|
+
urlpath = '/tokens?nonce=' + KeyUtils.nonce
|
141
142
|
|
142
|
-
|
143
|
-
|
144
|
-
|
143
|
+
request = Net::HTTP::Get.new(urlpath)
|
144
|
+
request['x-identity'] = @pub_key
|
145
|
+
request['x-signature'] = KeyUtils.sign(@uri.to_s + urlpath, @priv_key)
|
145
146
|
|
146
|
-
|
147
|
+
response = process_request(request)
|
147
148
|
|
148
|
-
|
149
|
+
token_array = response["data"] || {}
|
149
150
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
151
|
+
tokens = {}
|
152
|
+
token_array.each do |t|
|
153
|
+
tokens[t.keys.first] = t.values.first
|
154
|
+
end
|
154
155
|
|
155
|
-
|
156
|
-
|
156
|
+
@tokens = tokens
|
157
|
+
return tokens
|
157
158
|
|
158
|
-
|
159
|
+
end
|
159
160
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
161
|
+
## Retrieves specified token from hash, otherwise tries to refresh @tokens and retry
|
162
|
+
def set_pos_token(claim_code)
|
163
|
+
params = {pairingCode: claim_code}
|
164
|
+
urlpath = '/tokens'
|
165
|
+
request = Net::HTTP::Post.new urlpath
|
166
|
+
params[:guid] = SecureRandom.uuid
|
167
|
+
params[:id] = @client_id
|
168
|
+
request.body = params.to_json
|
169
|
+
process_request(request)
|
170
|
+
end
|
170
171
|
|
171
|
-
|
172
|
-
|
173
|
-
|
172
|
+
def get_token(facade)
|
173
|
+
token = @tokens[facade] || load_tokens[facade] || raise(BitPayError, "Not authorized for facade: #{facade}")
|
174
|
+
end
|
174
175
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
176
|
+
def verify_claim_code(claim_code)
|
177
|
+
regex = /^[[:alnum:]]{7}$/
|
178
|
+
matches = regex.match(claim_code)
|
179
|
+
!(matches.nil?)
|
180
|
+
end
|
179
181
|
end
|
180
182
|
end
|
181
183
|
end
|
data/lib/bitpay/key_utils.rb
CHANGED
data/lib/bitpay/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -9,8 +9,8 @@ def tokens
|
|
9
9
|
}
|
10
10
|
end
|
11
11
|
|
12
|
-
describe BitPay::Client do
|
13
|
-
let(:bitpay_client) { BitPay::Client.new({api_uri: BitPay::TEST_API_URI}) }
|
12
|
+
describe BitPay::SDK::Client do
|
13
|
+
let(:bitpay_client) { BitPay::SDK::Client.new({api_uri: BitPay::TEST_API_URI}) }
|
14
14
|
let(:claim_code) { "a12bc3d" }
|
15
15
|
|
16
16
|
before do
|
data/spec/features/pair_spec.rb
CHANGED
@@ -14,7 +14,7 @@ describe "pairing a token", javascript: true, type: :feature do
|
|
14
14
|
find(".token-claimcode", match: :first).text
|
15
15
|
end
|
16
16
|
let(:pem) { BitPay::KeyUtils.generate_pem }
|
17
|
-
let(:client) { BitPay::Client.new(api_uri: ROOT_ADDRESS, pem: pem, insecure: true) }
|
17
|
+
let(:client) { BitPay::SDK::Client.new(api_uri: ROOT_ADDRESS, pem: pem, insecure: true) }
|
18
18
|
|
19
19
|
context "pairing an unpaired client" do
|
20
20
|
it "should have no tokens before pairing" do
|
data/spec/features/pos_spec.rb
CHANGED
@@ -16,7 +16,7 @@ describe "create an invoice", javascript: true, type: :feature do
|
|
16
16
|
find(".token-claimcode", match: :first).text
|
17
17
|
}
|
18
18
|
set_client = -> {
|
19
|
-
client = BitPay::Client.new(api_uri: ROOT_ADDRESS, pem: PEM, insecure: true)
|
19
|
+
client = BitPay::SDK::Client.new(api_uri: ROOT_ADDRESS, pem: PEM, insecure: true)
|
20
20
|
client.pair_pos_client(get_claim_code.call)
|
21
21
|
client
|
22
22
|
}
|
@@ -21,7 +21,7 @@ describe "create an invoice", javascript: true, type: :feature do
|
|
21
21
|
find(".token-claimcode", match: :first).text
|
22
22
|
}
|
23
23
|
set_client = -> {
|
24
|
-
client = BitPay::Client.new(api_uri: ROOT_ADDRESS, pem: PEM, insecure: true)
|
24
|
+
client = BitPay::SDK::Client.new(api_uri: ROOT_ADDRESS, pem: PEM, insecure: true)
|
25
25
|
client.pair_pos_client(get_claim_code.call)
|
26
26
|
client
|
27
27
|
}
|
data/spec/spec_helper.rb
CHANGED
@@ -3,9 +3,7 @@ require 'pry'
|
|
3
3
|
require 'capybara/rspec'
|
4
4
|
require 'capybara/poltergeist'
|
5
5
|
|
6
|
-
require File.join File.dirname(__FILE__), '..', 'lib', '
|
7
|
-
require File.join File.dirname(__FILE__), '..', 'lib', 'bitpay', 'key_utils.rb'
|
8
|
-
require File.join File.dirname(__FILE__), '..', 'lib', 'bitpay.rb'
|
6
|
+
require File.join File.dirname(__FILE__), '..', 'lib', 'bitpay_sdk.rb'
|
9
7
|
require_relative '../config/constants.rb'
|
10
8
|
require_relative '../config/capybara.rb'
|
11
9
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitpay-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bitpay, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -228,12 +228,11 @@ files:
|
|
228
228
|
- features/step_definitions/invoice_steps.rb
|
229
229
|
- features/step_definitions/keygen_steps.rb
|
230
230
|
- features/step_definitions/step_helpers.rb
|
231
|
-
- lib/bitpay.rb
|
232
231
|
- lib/bitpay/cacert.pem
|
233
232
|
- lib/bitpay/client.rb
|
234
233
|
- lib/bitpay/key_utils.rb
|
235
234
|
- lib/bitpay/version.rb
|
236
|
-
- lib/
|
235
|
+
- lib/bitpay_sdk.rb
|
237
236
|
- spec/client_spec.rb
|
238
237
|
- spec/features/pair_spec.rb
|
239
238
|
- spec/features/pos_spec.rb
|
data/lib/harness.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# license Copyright 2011-2014 BitPay, Inc., MIT License
|
2
|
-
# see http://opensource.org/licenses/MIT
|
3
|
-
# or https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
4
|
-
|
5
|
-
require_relative 'bitpay.rb'
|
6
|
-
require_relative 'bitpay/key_utils.rb'
|
7
|
-
|
8
|
-
# Test SIN Generation class methods
|
9
|
-
|
10
|
-
# Generate SIN
|
11
|
-
ENV["PRIV_KEY"] = "16d7c3508ec59773e71ae728d29f41fcf5d1f380c379b99d68fa9f552ce3ebc3"
|
12
|
-
puts "privkey: #{ENV['PRIV_KEY']}"
|
13
|
-
puts "target SIN: TfFVQhy2hQvchv4VVG4c7j4XPa2viJ9HrR8"
|
14
|
-
puts "Derived SIN: #{BitPay::KeyUtils.get_client_id}"
|
15
|
-
|
16
|
-
puts "\n\n------------------\n\n"
|
17
|
-
|
18
|
-
uri = "https://localhost:8088"
|
19
|
-
#name = "Ridonculous.label That shouldn't work really"
|
20
|
-
name = "somethinginnocuous"
|
21
|
-
facade = "pos"
|
22
|
-
client_id = BitPay::KeyUtils.get_client_id
|
23
|
-
|
24
|
-
BitPay::KeyUtils.generate_registration_url(uri,name,facade,client_id)
|
25
|
-
|
26
|
-
puts "\n\n------------------\n\n"
|
27
|
-
|
28
|
-
#### Test Invoice Creation using directly assigned keys
|
29
|
-
## (Ultimately pubkey and SIN should be derived)
|
30
|
-
|
31
|
-
ENV["PRIV_KEY"] = "16d7c3508ec59773e71ae728d29f41fcf5d1f380c379b99d68fa9f552ce3ebc3"
|
32
|
-
#ENV["pub_key"] = "0353a036fb495c5846f26a3727a28198da8336ae4f5aaa09e24c14a4126b5d969d"
|
33
|
-
#ENV['SIN'] = "TfFVQhy2hQvchv4VVG4c7j4XPa2viJ9HrR8"
|
34
|
-
|
35
|
-
client = BitPay::Client.new({insecure: true, debug: false})
|
36
|
-
|
37
|
-
invoice = client.post 'invoices', {:price => 10.00, :currency => 'USD'}
|
38
|
-
|
39
|
-
puts "Here's the invoice: \n" + JSON.pretty_generate(invoice)
|
40
|
-
|