coinpayments 0.0.3 → 0.0.4
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 +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +2 -2
- data/README.md +8 -0
- data/coinpayments.gemspec +2 -2
- data/lib/coinpayments.rb +8 -0
- data/lib/coinpayments/configuration.rb +2 -1
- data/lib/coinpayments/version.rb +1 -1
- data/lib/generators/coinpayments/templates/coinpayments_initializer.rb +1 -0
- data/test/coinpayments_test.rb +29 -0
- data/test/fixtures/create_mass_withdrawal.yml +56 -0
- metadata +17 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 619123c0e28ea6a2afffc82082df90a9d10c217b75ea2695de4ac876dcfda149
|
4
|
+
data.tar.gz: de079ac5d4c295ba8bf7145352b883b4ae59a345e7018fc8478717623268290b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1d96d7c2bfa0db7cc597d9c464eb9aa9eae6173256f4c7c2faedead045a512638f146920aae768717189ac7cd7af6e5c68989bae1ba90df6efc833eb42d3bb6
|
7
|
+
data.tar.gz: 6b73b2809fccf09fa4468bd49f969ca2ed9b3eb5418840118ee551c23047bbc721539dd7a87599c7bdc800708611827cf736e70efb8ddbdd0064903b3cdc527c
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -36,6 +36,7 @@ Coinpayments.configure do |config|
|
|
36
36
|
config.merchant_id = ''
|
37
37
|
config.public_api_key = ''
|
38
38
|
config.private_api_key = ''
|
39
|
+
config.secret_phrase = ''
|
39
40
|
end
|
40
41
|
```
|
41
42
|
|
@@ -66,6 +67,13 @@ For example, to quickly access current BTC/USD exchange rate, use:
|
|
66
67
|
transaction = Coinpayments.create_transaction(10, 'USD', 'BTC')
|
67
68
|
@address = transaction.address
|
68
69
|
```
|
70
|
+
- You can recieve IPN callbacks after payments on API-generated addresses.
|
71
|
+
Coinpayments server generates signature based on your secret phrase and row
|
72
|
+
body of POST request to your custom API. You can easily compare signatures
|
73
|
+
to verify callback using
|
74
|
+
```
|
75
|
+
Coinpayments.sign('IPN POST request row body')
|
76
|
+
```
|
69
77
|
|
70
78
|
## Contributing
|
71
79
|
|
data/coinpayments.gemspec
CHANGED
@@ -17,13 +17,13 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_development_dependency "bundler"
|
20
|
+
spec.add_development_dependency "bundler"
|
21
21
|
spec.add_development_dependency "rake"
|
22
22
|
spec.add_development_dependency "pry"
|
23
23
|
spec.add_development_dependency "minitest"
|
24
24
|
spec.add_development_dependency "vcr"
|
25
25
|
spec.add_development_dependency "webmock"
|
26
26
|
|
27
|
-
spec.add_dependency "httparty"
|
27
|
+
spec.add_dependency "httparty"
|
28
28
|
spec.add_dependency "hashie"
|
29
29
|
end
|
data/lib/coinpayments.rb
CHANGED
@@ -55,6 +55,10 @@ module Coinpayments
|
|
55
55
|
api_call(args)
|
56
56
|
end
|
57
57
|
|
58
|
+
def self.create_mass_withdrawal(withdrawals)
|
59
|
+
api_call(withdrawals)
|
60
|
+
end
|
61
|
+
|
58
62
|
def self.get_tx_info(txid)
|
59
63
|
args = { txid: txid }
|
60
64
|
api_call(args)
|
@@ -70,4 +74,8 @@ module Coinpayments
|
|
70
74
|
api_call(args)
|
71
75
|
end
|
72
76
|
|
77
|
+
def self.sign(callback_body)
|
78
|
+
OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha512'),
|
79
|
+
configuration.secret_phrase,callback_body)
|
80
|
+
end
|
73
81
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Coinpayments
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :version, :base_uri, :merchant_id, :public_api_key, :private_api_key
|
3
|
+
attr_accessor :version, :base_uri, :merchant_id, :public_api_key, :private_api_key, :secret_phrase
|
4
4
|
|
5
5
|
def initialize
|
6
6
|
@version = 1
|
@@ -8,6 +8,7 @@ module Coinpayments
|
|
8
8
|
@merchant_id = ''
|
9
9
|
@public_api_key = ''
|
10
10
|
@private_api_key = ''
|
11
|
+
@secret_phrase = ''
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
data/lib/coinpayments/version.rb
CHANGED
data/test/coinpayments_test.rb
CHANGED
@@ -42,6 +42,28 @@ class CoinpaymentsTest < Minitest::Test
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
def test_create_mass_withdrawal
|
46
|
+
VCR.use_cassette('create_mass_withdrawal') do
|
47
|
+
withdrawals = {wd: {
|
48
|
+
wd1: {
|
49
|
+
amount: 1,
|
50
|
+
address: 'sYo5A4vVBBV2SYbh7jPjocqg9DeNYqkP4U',
|
51
|
+
currency: 'START'
|
52
|
+
},
|
53
|
+
wd2: {
|
54
|
+
amount: 1,
|
55
|
+
address: 'sYo5A4vVBBV2SYbh7jPjocqg9DeNYqkP4U',
|
56
|
+
currency: 'START'
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
r = Coinpayments.create_mass_withdrawal(withdrawals)
|
61
|
+
assert r.kind_of?(Hash)
|
62
|
+
assert r.respond_to?(:wd1)
|
63
|
+
assert r.respond_to?(:wd2)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
45
67
|
def test_get_tx_info
|
46
68
|
VCR.use_cassette('get_tx_info') do
|
47
69
|
r = Coinpayments.get_tx_info('705565b8b8f068566fed1a71977ece30265c6e80cf7dfe854ab4a455701129bc')
|
@@ -65,4 +87,11 @@ class CoinpaymentsTest < Minitest::Test
|
|
65
87
|
assert r.respond_to?(:status_text)
|
66
88
|
end
|
67
89
|
end
|
90
|
+
|
91
|
+
def test_sign
|
92
|
+
VCR.use_cassette('sign') do
|
93
|
+
r = Coinpayments.sign('Secret Phrase')
|
94
|
+
assert r.size == 128
|
95
|
+
end
|
96
|
+
end
|
68
97
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://www.coinpayments.net/api.php
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: version=1&key=8e2d03e5b7778e7ca2bb7299d8480141c9b66849520b40ec23d4d181392831db&cmd=create_mass_withdrawal&wd[wd1][amount]=1&wd[wd1][address]=sYo5A4vVBBV2SYbh7jPjocqg9DeNYqkP4U&wd[wd1][currency]=START&wd[wd2][amount]=2&wd[wd2][address]=sYo5A4vVBBV2SYbh7jPjocqg9DeNYqkP4U&wd[wd2][currency]=START
|
9
|
+
headers:
|
10
|
+
Hmac:
|
11
|
+
- c3df4f4f69b847dbf3035c39f45d94ecdc07a66c326525164028ce4f173ddc168d63e991f607fb7ee36b240b5a502e518733d1453b990347e06a2f3f93704db2
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: OK
|
16
|
+
headers:
|
17
|
+
Date:
|
18
|
+
- Fri, 16 Feb 2018 10:37:41 GMT
|
19
|
+
Server:
|
20
|
+
- Apache
|
21
|
+
X-Frame-Options:
|
22
|
+
- sameorigin
|
23
|
+
Strict-Transport-Security:
|
24
|
+
- max-age=31536000
|
25
|
+
Set-Cookie:
|
26
|
+
- PHPSESSID=20a5h814i2fjhsbckld7o67ob48f1ib7; path=/; secure; HttpOnly
|
27
|
+
- incap_ses_375_992349=AFfAVWXHGBr/giKqmkQ0BXW0hloAAAAAMBlIYON2guIlAfo7x63nSQ==;
|
28
|
+
path=/; Domain=.coinpayments.net
|
29
|
+
- visid_incap_992349=jGNVOmMQT4WlxPNfz1WnpnW0hloAAAAAQUIPAAAAAADp+GUCASaXCO1dg1TjvL+y;
|
30
|
+
expires=Fri, 15 Feb 2019 13:36:21 GMT; path=/; Domain=.coinpayments.net
|
31
|
+
Expires:
|
32
|
+
- Thu, 19 Nov 1981 08:52:00 GMT
|
33
|
+
Cache-Control:
|
34
|
+
- no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
35
|
+
Pragma:
|
36
|
+
- no-cache
|
37
|
+
Access-Control-Allow-Origin:
|
38
|
+
- "*"
|
39
|
+
Content-Disposition:
|
40
|
+
- attachment; filename=coinpayments_api.json
|
41
|
+
Content-Length:
|
42
|
+
- '119'
|
43
|
+
Content-Type:
|
44
|
+
- application/json
|
45
|
+
X-Iinfo:
|
46
|
+
- 13-37462443-37462477 NNNN CT(77 79 0) RT(1518777460968 198) q(0 0 2 -1) r(3
|
47
|
+
3) U6
|
48
|
+
X-Cdn:
|
49
|
+
- Incapsula
|
50
|
+
body:
|
51
|
+
encoding: UTF-8
|
52
|
+
string: '{"error":"ok","result":{"wd1":{"error":"START is currently disabled!"},"wd2":{"error":"START
|
53
|
+
is currently disabled!"}}}'
|
54
|
+
http_version:
|
55
|
+
recorded_at: Fri, 16 Feb 2018 10:37:41 GMT
|
56
|
+
recorded_with: VCR 4.0.0
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coinpayments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Przemysław Janowski
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: httparty
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0
|
103
|
+
version: '0'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0
|
110
|
+
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: hashie
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
-
description:
|
125
|
+
description:
|
126
126
|
email:
|
127
127
|
- p.janowski@outlook.com
|
128
128
|
executables: []
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- lib/generators/coinpayments/templates/coinpayments_initializer.rb
|
144
144
|
- test/coinpayments_test.rb
|
145
145
|
- test/fixtures/balances.yml
|
146
|
+
- test/fixtures/create_mass_withdrawal.yml
|
146
147
|
- test/fixtures/create_transaction.yml
|
147
148
|
- test/fixtures/create_withdrawal.yml
|
148
149
|
- test/fixtures/get_callback_address.yml
|
@@ -153,7 +154,7 @@ homepage: https://github.com/Salet/coinpayments
|
|
153
154
|
licenses:
|
154
155
|
- MIT
|
155
156
|
metadata: {}
|
156
|
-
post_install_message:
|
157
|
+
post_install_message:
|
157
158
|
rdoc_options: []
|
158
159
|
require_paths:
|
159
160
|
- lib
|
@@ -168,14 +169,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
169
|
- !ruby/object:Gem::Version
|
169
170
|
version: '0'
|
170
171
|
requirements: []
|
171
|
-
|
172
|
-
|
173
|
-
signing_key:
|
172
|
+
rubygems_version: 3.1.2
|
173
|
+
signing_key:
|
174
174
|
specification_version: 4
|
175
175
|
summary: Ruby client for the CoinPayments.net API
|
176
176
|
test_files:
|
177
177
|
- test/coinpayments_test.rb
|
178
178
|
- test/fixtures/balances.yml
|
179
|
+
- test/fixtures/create_mass_withdrawal.yml
|
179
180
|
- test/fixtures/create_transaction.yml
|
180
181
|
- test/fixtures/create_withdrawal.yml
|
181
182
|
- test/fixtures/get_callback_address.yml
|