cryptocoin_payable 1.4.3 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/console +1 -0
- data/features/step_definitions/coin_payment_steps.rb +2 -2
- data/lib/cryptocoin_payable/adapters/base.rb +2 -2
- data/lib/cryptocoin_payable/adapters.rb +10 -4
- data/lib/cryptocoin_payable/coin_payment.rb +1 -0
- data/lib/cryptocoin_payable/currency_conversion.rb +1 -0
- data/lib/cryptocoin_payable/version.rb +1 -1
- data/spec/acceptance/adapters/bitcoin_cash_spec.rb +2 -2
- data/spec/acceptance/adapters/bitcoin_spec.rb +4 -4
- data/spec/acceptance/adapters/ethereum_spec.rb +4 -4
- data/spec/acceptance/coin_payment_spec.rb +19 -0
- data/spec/acceptance/commands/payment_processor_spec.rb +2 -3
- data/spec/acceptance/commands/pricing_processor_spec.rb +0 -6
- data/spec/fixtures/vcr_cassettes/CryptocoinPayable_Adapters_Bitcoin/returns_zero_estimated_value_for_zero-value_transactions.yml +70 -0
- data/spec/fixtures/vcr_cassettes/CryptocoinPayable_PricingProcessor/when_updating_stale_payments/can_update.yml +121 -20
- data/spec/spec_helper.rb +8 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e8ee910240c9364019d58075f3822390414af89
|
4
|
+
data.tar.gz: 630fe67e170cfc62acc2553208a9165a88635b65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d2a3eac566f31ee6d26e82d73560b053ffb552c44cc83e6946971489be2c3a86ab26bd24cf99537b6ede0231d88c7049a9df0faeefdf899e81e86fc9b17d613
|
7
|
+
data.tar.gz: aa54453fe746d2543baed91ba8a59d65d95afe3a19c4031ce113024783a88606ceb4d8fbc03decf405c1c9a9512f617865d2ef5fa9acc4f702e0b7f7148426a9
|
data/bin/console
CHANGED
@@ -24,8 +24,8 @@ Given(/^a payment is made for (\d+) percent$/) do |percentage|
|
|
24
24
|
[{
|
25
25
|
transaction_hash: SecureRandom.uuid,
|
26
26
|
block_hash: '00000000000000606aa74093ed91d657192a3772732ee4d99a7b7be8075eafa2',
|
27
|
-
block_time:
|
28
|
-
estimated_time:
|
27
|
+
block_time: Time.iso8601('2017-12-26T21:38:44.000+00:00'),
|
28
|
+
estimated_time: Time.iso8601('2017-12-26T21:30:19.858+00:00'),
|
29
29
|
estimated_value: @coin_amount_due * (percentage.to_f / 100.0),
|
30
30
|
confirmations: 1
|
31
31
|
}]
|
@@ -77,11 +77,11 @@ module CryptocoinPayable
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def parse_timestamp(timestamp)
|
80
|
-
timestamp.nil? ? nil :
|
80
|
+
timestamp.nil? ? nil : Time.strptime(timestamp.to_s, '%s')
|
81
81
|
end
|
82
82
|
|
83
83
|
def parse_time(time)
|
84
|
-
time.nil? ? nil :
|
84
|
+
time.nil? ? nil : Time.iso8601(time)
|
85
85
|
end
|
86
86
|
|
87
87
|
private
|
@@ -2,22 +2,28 @@ module CryptocoinPayable
|
|
2
2
|
module Adapters
|
3
3
|
def self.for(coin_type)
|
4
4
|
case coin_type.to_sym
|
5
|
-
when :
|
6
|
-
|
5
|
+
when :bch
|
6
|
+
bitcoin_cash_adapter
|
7
7
|
when :btc
|
8
8
|
bitcoin_adapter
|
9
|
+
when :eth
|
10
|
+
ethereum_adapter
|
9
11
|
else
|
10
12
|
raise "Invalid coin type #{coin_type}"
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
14
|
-
def self.
|
15
|
-
@
|
16
|
+
def self.bitcoin_cash_adapter
|
17
|
+
@bitcoin_cash_adapter ||= BitcoinCash.new
|
16
18
|
end
|
17
19
|
|
18
20
|
def self.bitcoin_adapter
|
19
21
|
@bitcoin_adapter ||= Bitcoin.new
|
20
22
|
end
|
23
|
+
|
24
|
+
def self.ethereum_adapter
|
25
|
+
@ethereum_adapter ||= Ethereum.new
|
26
|
+
end
|
21
27
|
end
|
22
28
|
end
|
23
29
|
|
@@ -10,8 +10,8 @@ describe CryptocoinPayable::Adapters::BitcoinCash, :vcr do
|
|
10
10
|
{
|
11
11
|
transaction_hash: '10d9d3927a21d90c573a5fbbb347f409af37219ceb93f7475d6c4cca4231d29f',
|
12
12
|
block_hash: '0000000000000000015493ab50fde669130f9b64f0918031a5b6dcc44f14698f',
|
13
|
-
block_time:
|
14
|
-
estimated_time:
|
13
|
+
block_time: Time.iso8601('2018-10-12T07:28:21.000000000+00:00'),
|
14
|
+
estimated_time: Time.iso8601('2018-10-12T07:28:21.000000000+00:00'),
|
15
15
|
estimated_value: 4_128_450,
|
16
16
|
confirmations: 2
|
17
17
|
}
|
@@ -8,16 +8,16 @@ describe CryptocoinPayable::Adapters::Bitcoin, :vcr do
|
|
8
8
|
{
|
9
9
|
transaction_hash: '5bdeaf7829148d7e0e1e7b5233512a2c5ae54ef7ccbc8e68b2f85b7e49c917a0',
|
10
10
|
block_hash: '0000000000000000048e8ea3fdd2c3a59ddcbcf7575f82cb96ce9fd17da9f2f4',
|
11
|
-
block_time:
|
12
|
-
estimated_time: be_within(1.day).of(
|
11
|
+
block_time: Time.iso8601('2016-09-13T15:41:00.000000000+00:00'),
|
12
|
+
estimated_time: be_within(1.day).of(Time.iso8601('2016-09-13T15:41:00.000000000+00:00')),
|
13
13
|
estimated_value: 499_000_000,
|
14
14
|
confirmations: 116_077
|
15
15
|
},
|
16
16
|
{
|
17
17
|
transaction_hash: 'e7bcdb13d9c903973bd8a740054d4c056a559bae67d4e8f6d0a42b4bab552623',
|
18
18
|
block_hash: '000000000000000001af27feb303ad97af81a5882157f166781784c639f8e896',
|
19
|
-
block_time:
|
20
|
-
estimated_time: be_within(1.day).of(
|
19
|
+
block_time: Time.iso8601('2016-09-13T15:22:42.000000000+00:00'),
|
20
|
+
estimated_time: be_within(1.day).of(Time.iso8601('2016-09-13T15:22:42.000000000+00:00')),
|
21
21
|
estimated_value: 1_000_000,
|
22
22
|
confirmations: 116_080
|
23
23
|
}
|
@@ -9,7 +9,7 @@ describe CryptocoinPayable::Adapters::Ethereum, :vcr do
|
|
9
9
|
transaction_hash: '0xa88b799514e9621962e3d0de25e7e0bc7a123e33085f322c7acdb99cc2585c6d',
|
10
10
|
block_hash: '0x752c50e426f65820f5bf6fd49acbb08d79464f8e7e8ea5b77e2299b69fd6398b',
|
11
11
|
block_time: nil,
|
12
|
-
estimated_time: be_within(1.day).of(
|
12
|
+
estimated_time: be_within(1.day).of(Time.iso8601('2018-07-05T12:58:33.000000000+07:00')),
|
13
13
|
estimated_value: 33_753_640_000_000_000,
|
14
14
|
confirmations: 569_771
|
15
15
|
},
|
@@ -17,7 +17,7 @@ describe CryptocoinPayable::Adapters::Ethereum, :vcr do
|
|
17
17
|
transaction_hash: '0xb325a8cf241f332bca92c7f715987e4d34be9a6b3bb78d2425c83086b4aced26',
|
18
18
|
block_hash: '0x1c2b73a16fd8c4d25feeccaa2f0bf5c82b8f415f1beaf4d34aaf870daf89689d',
|
19
19
|
block_time: nil,
|
20
|
-
estimated_time: be_within(1.day).of(
|
20
|
+
estimated_time: be_within(1.day).of(Time.iso8601('2018-07-05T13:35:07.000000000+07:00')),
|
21
21
|
estimated_value: 2_190_144_444_444_444,
|
22
22
|
confirmations: 569_629
|
23
23
|
},
|
@@ -25,7 +25,7 @@ describe CryptocoinPayable::Adapters::Ethereum, :vcr do
|
|
25
25
|
transaction_hash: '0xcd874917be5ad177e7ebd88b5c4a7d4283796e00e43345da5b63fb4f78130b37',
|
26
26
|
block_hash: '0x4ce71d11146445f123680ea9beba7db968b04dc675caddf60248c9d9d6f5739e',
|
27
27
|
block_time: nil,
|
28
|
-
estimated_time: be_within(1.day).of(
|
28
|
+
estimated_time: be_within(1.day).of(Time.iso8601('2018-07-05T13:55:53.000000000+07:00')),
|
29
29
|
estimated_value: 1_007_518_888_888_888,
|
30
30
|
confirmations: 569_549
|
31
31
|
},
|
@@ -33,7 +33,7 @@ describe CryptocoinPayable::Adapters::Ethereum, :vcr do
|
|
33
33
|
transaction_hash: '0x799ec2aaafbddbc2e746334f96f59f6127dec62e5693480576db351aaf840bfb',
|
34
34
|
block_hash: '0xc1361b19b2266e2259ac433b9e18b4fbc81339304988bbc62dd93aa24fac6449',
|
35
35
|
block_time: nil,
|
36
|
-
estimated_time: be_within(1.day).of(
|
36
|
+
estimated_time: be_within(1.day).of(Time.iso8601('2018-08-26T16:05:44.000000000+07:00')),
|
37
37
|
estimated_value: 15_678_420_000_000_000,
|
38
38
|
confirmations: 261_969
|
39
39
|
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require 'cryptocoin_payable'
|
3
|
+
require 'cryptocoin_payable/orm/activerecord'
|
4
|
+
|
5
|
+
describe CryptocoinPayable::CoinPayment do
|
6
|
+
context 'when creating a Bitcoin Cash payment' do
|
7
|
+
subject { CryptocoinPayable::CoinPayment.new(coin_type: :bch, reason: 'test', price: 1) }
|
8
|
+
|
9
|
+
it 'can save a payment' do
|
10
|
+
expect { subject.save! }.not_to raise_error
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'can update the coin amount due' do
|
14
|
+
subject.update_coin_amount_due
|
15
|
+
expect(subject.coin_amount_due).to eq(100_000_000)
|
16
|
+
expect(subject.coin_conversion).to eq(1)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -9,8 +9,8 @@ describe CryptocoinPayable::PaymentProcessor do
|
|
9
9
|
transactions << {
|
10
10
|
transaction_hash: Digest::SHA2.new(256).hexdigest(i.to_s),
|
11
11
|
block_hash: '0000000000000000048e8ea3fdd2c3a59ddcbcf7575f82cb96ce9fd17da9f2f4',
|
12
|
-
block_time:
|
13
|
-
estimated_time:
|
12
|
+
block_time: Time.iso8601('2016-09-13T15:41:00.000000000+00:00'),
|
13
|
+
estimated_time: Time.iso8601('2016-09-13T15:41:00.000000000+00:00'),
|
14
14
|
estimated_value: 499_000_000,
|
15
15
|
confirmations: 116_077
|
16
16
|
}
|
@@ -23,7 +23,6 @@ describe CryptocoinPayable::PaymentProcessor do
|
|
23
23
|
after(:all) { GC.enable }
|
24
24
|
|
25
25
|
before do
|
26
|
-
CryptocoinPayable::CurrencyConversion.create!(coin_type: :btc, currency: 1, price: 1)
|
27
26
|
adapter = CryptocoinPayable::Adapters.bitcoin_adapter
|
28
27
|
allow(adapter).to receive(:fetch_transactions) { build_fake_transactions_data }
|
29
28
|
end
|
@@ -6,12 +6,6 @@ describe CryptocoinPayable::PricingProcessor, vcr: true do
|
|
6
6
|
# Ensure we have a stale payment.
|
7
7
|
Timecop.freeze(3.days.from_now)
|
8
8
|
|
9
|
-
CryptocoinPayable::CurrencyConversion.create!(
|
10
|
-
coin_type: :btc,
|
11
|
-
currency: 1,
|
12
|
-
price: 1
|
13
|
-
)
|
14
|
-
|
15
9
|
CryptocoinPayable::CoinPayment.create!(
|
16
10
|
state: :pending,
|
17
11
|
coin_type: :btc,
|
@@ -0,0 +1,70 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://blockexplorer.com/api/txs/?address=1PKKkNRPPfPjrPiufHzuLFX2gMAVJbcN8H
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Thu, 08 Nov 2018 17:34:48 GMT
|
23
|
+
Content-Type:
|
24
|
+
- application/json; charset=utf-8
|
25
|
+
Transfer-Encoding:
|
26
|
+
- chunked
|
27
|
+
Connection:
|
28
|
+
- keep-alive
|
29
|
+
Set-Cookie:
|
30
|
+
- BE=f6fe53688c017ff7; path=/
|
31
|
+
- __cfduid=dd04ba3e33bea3f20633eebd13320dc081541698486; expires=Fri, 08-Nov-19
|
32
|
+
17:34:46 GMT; path=/; domain=.blockexplorer.com; HttpOnly; Secure
|
33
|
+
X-Powered-By:
|
34
|
+
- Express
|
35
|
+
Access-Control-Allow-Origin:
|
36
|
+
- "*"
|
37
|
+
Access-Control-Allow-Methods:
|
38
|
+
- GET, HEAD, PUT, POST, OPTIONS
|
39
|
+
Access-Control-Allow-Headers:
|
40
|
+
- Origin, X-Requested-With, Content-Type, Accept, Content-Length, Cache-Control,
|
41
|
+
cf-connecting-ip
|
42
|
+
Cache-Control:
|
43
|
+
- public, max-age=30
|
44
|
+
X-Content-Type-Options:
|
45
|
+
- nosniff
|
46
|
+
Etag:
|
47
|
+
- W/"10a9-4+a9umI+STIlOj3adv7w8ZfOGog"
|
48
|
+
Vary:
|
49
|
+
- Accept-Encoding
|
50
|
+
Cf-Cache-Status:
|
51
|
+
- BYPASS
|
52
|
+
Expect-Ct:
|
53
|
+
- max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
|
54
|
+
Server:
|
55
|
+
- cloudflare
|
56
|
+
Cf-Ray:
|
57
|
+
- 4769cad68b06a49d-PNH
|
58
|
+
body:
|
59
|
+
encoding: ASCII-8BIT
|
60
|
+
string: '{"pagesTotal":1,"txs":[{"txid":"1c085fb7180d35736dae4d1526f18c71fb551173c7471a70251bff88d38d559d","version":1,"locktime":0,"vin":[{"txid":"5dd89fb2f9a2adfe6f4918db6a203b7c8c91c25c7cb0cd9bfb8a250e3c25abdd","vout":0,"sequence":4294967295,"n":0,"scriptSig":{"hex":"483045022100b029679930b80ce4c067b9c903571c6a935983d7beecaeb902ad1fffa9dba21502204e542e193b74acf68ab17cb13f821d339244aea9cb339bede4b195b3c3b35c6c0121028005d0d0b1c96d549f0eb5e18fb9f7b35ed5a28fb2f3c55842ab9dc9a9218976","asm":"3045022100b029679930b80ce4c067b9c903571c6a935983d7beecaeb902ad1fffa9dba21502204e542e193b74acf68ab17cb13f821d339244aea9cb339bede4b195b3c3b35c6c[ALL]
|
61
|
+
028005d0d0b1c96d549f0eb5e18fb9f7b35ed5a28fb2f3c55842ab9dc9a9218976"},"addr":"1PKKkNRPPfPjrPiufHzuLFX2gMAVJbcN8H","valueSat":55965,"value":0.00055965,"doubleSpentTxID":null},{"txid":"5dd89fb2f9a2adfe6f4918db6a203b7c8c91c25c7cb0cd9bfb8a250e3c25abdd","vout":1,"sequence":4294967295,"n":1,"scriptSig":{"hex":"473044022048fad34851bc49c267386186df590ac12390172669f5612b2c28dc09d517223c02203fe2ecf934c10cfaa3d27d1e739ec3413fd16612ba16eaa15ba7a2cfbf0b3a790121034994bba249dc54ed3651595dab6c5c6e3c177032495e00a3fe53874adf565a34","asm":"3044022048fad34851bc49c267386186df590ac12390172669f5612b2c28dc09d517223c02203fe2ecf934c10cfaa3d27d1e739ec3413fd16612ba16eaa15ba7a2cfbf0b3a79[ALL]
|
62
|
+
034994bba249dc54ed3651595dab6c5c6e3c177032495e00a3fe53874adf565a34"},"addr":"15Gmaq5M8cMD4mAy1Gh6dVtnoDX3XAazwf","valueSat":503191,"value":0.00503191,"doubleSpentTxID":null}],"vout":[{"value":"0.00062184","n":0,"scriptPubKey":{"hex":"a91484fd6a85eb6cb335e0b8641717f3cf7f392f897587","asm":"OP_HASH160
|
63
|
+
84fd6a85eb6cb335e0b8641717f3cf7f392f8975 OP_EQUAL","addresses":["3DpChXQfjya6zQdUcgpA5tQFfqv9KgRXMP"],"type":"scripthash"},"spentTxId":"0a4c5507fe17f62d698f4ad30843909320770fd5b7159a925a0df289ed77c38e","spentIndex":1,"spentHeight":547179},{"value":"0.00495855","n":1,"scriptPubKey":{"hex":"76a9142edbf57347f7f56a2975c4c5c147680a781e32a988ac","asm":"OP_DUP
|
64
|
+
OP_HASH160 2edbf57347f7f56a2975c4c5c147680a781e32a9 OP_EQUALVERIFY OP_CHECKSIG","addresses":["15Gmaq5M8cMD4mAy1Gh6dVtnoDX3XAazwf"],"type":"pubkeyhash"},"spentTxId":"6f4f788586ba84ec1bea20b0063fff671c39f85a246b161188980fd13d8203f3","spentIndex":0,"spentHeight":547444}],"blockhash":"00000000000000000008d05a3b4530691dcfe048fa046bc1c95cbf7ae6c60ff0","blockheight":547177,"confirmations":2057,"time":1540413667,"blocktime":1540413667,"valueOut":0.00558039,"size":371,"valueIn":0.00559156,"fees":0.00001117},{"txid":"5dd89fb2f9a2adfe6f4918db6a203b7c8c91c25c7cb0cd9bfb8a250e3c25abdd","version":1,"locktime":0,"vin":[{"txid":"040d0d19654c2fa3e5dbea6654849339261c0bc5f4540173bf87ad0c9d1b2726","vout":1,"sequence":4294967295,"n":0,"scriptSig":{"hex":"483045022100d74af226278b3eaa850f12ccbbdc005796da6172b4b4664d1769586a361982a60220227b54175f2989cbceb4795997381c4b7a3f99d579431bf74294fcde8317ac8c0121034994bba249dc54ed3651595dab6c5c6e3c177032495e00a3fe53874adf565a34","asm":"3045022100d74af226278b3eaa850f12ccbbdc005796da6172b4b4664d1769586a361982a60220227b54175f2989cbceb4795997381c4b7a3f99d579431bf74294fcde8317ac8c[ALL]
|
65
|
+
034994bba249dc54ed3651595dab6c5c6e3c177032495e00a3fe53874adf565a34"},"addr":"15Gmaq5M8cMD4mAy1Gh6dVtnoDX3XAazwf","valueSat":559835,"value":0.00559835,"doubleSpentTxID":null}],"vout":[{"value":"0.00055965","n":0,"scriptPubKey":{"hex":"76a914f4c9e785dbe753f59b98c082d793b2e1312c558788ac","asm":"OP_DUP
|
66
|
+
OP_HASH160 f4c9e785dbe753f59b98c082d793b2e1312c5587 OP_EQUALVERIFY OP_CHECKSIG","addresses":["1PKKkNRPPfPjrPiufHzuLFX2gMAVJbcN8H"],"type":"pubkeyhash"},"spentTxId":"1c085fb7180d35736dae4d1526f18c71fb551173c7471a70251bff88d38d559d","spentIndex":0,"spentHeight":547177},{"value":"0.00503191","n":1,"scriptPubKey":{"hex":"76a9142edbf57347f7f56a2975c4c5c147680a781e32a988ac","asm":"OP_DUP
|
67
|
+
OP_HASH160 2edbf57347f7f56a2975c4c5c147680a781e32a9 OP_EQUALVERIFY OP_CHECKSIG","addresses":["15Gmaq5M8cMD4mAy1Gh6dVtnoDX3XAazwf"],"type":"pubkeyhash"},"spentTxId":"1c085fb7180d35736dae4d1526f18c71fb551173c7471a70251bff88d38d559d","spentIndex":1,"spentHeight":547177}],"blockhash":"0000000000000000001e7b7b2bf28d3e3813e0a37354f95288fe05fa18a0bc8a","blockheight":547126,"confirmations":2108,"time":1540380059,"blocktime":1540380059,"valueOut":0.00559156,"size":226,"valueIn":0.00559835,"fees":0.00000679}]}'
|
68
|
+
http_version:
|
69
|
+
recorded_at: Thu, 08 Nov 2018 17:34:53 GMT
|
70
|
+
recorded_with: VCR 4.0.0
|
@@ -1,5 +1,106 @@
|
|
1
1
|
---
|
2
2
|
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.coinbase.com/v2/prices/BCH-USD/spot
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Thu, 08 Nov 2018 17:53:56 GMT
|
23
|
+
Content-Type:
|
24
|
+
- application/json; charset=utf-8
|
25
|
+
Content-Length:
|
26
|
+
- '81'
|
27
|
+
Connection:
|
28
|
+
- keep-alive
|
29
|
+
Set-Cookie:
|
30
|
+
- __cfduid=d5f901b0febd4880997885e4cdc0882561541699635; expires=Fri, 08-Nov-19
|
31
|
+
17:53:55 GMT; path=/; domain=.coinbase.com; HttpOnly
|
32
|
+
Cache-Control:
|
33
|
+
- public, max-age=30
|
34
|
+
Content-Disposition:
|
35
|
+
- attachment; filename=response.json
|
36
|
+
Content-Security-Policy:
|
37
|
+
- 'default-src ''self'' https://www.coinbase.com; child-src ''self'' https://www.coinbase.com
|
38
|
+
https://*.online-metrix.net https://*.wpstn.com https://netverify.com https://platform.twitter.com
|
39
|
+
https://www.google.com/recaptcha/ https://cdn.plaid.com/link/ https://*.doubleclick.net/
|
40
|
+
blob: https://coinbase.ada.support; connect-src ''self'' https://www.coinbase.com
|
41
|
+
https://api.coinbase.com https://api.mixpanel.com https://*.online-metrix.net
|
42
|
+
https://api.cloudinary.com https://ott9.wpstn.com/live https://api.amplitude.com/
|
43
|
+
static.coinbase.com wss://ws.coinbase.com wss://ws.coinbase.com:443 https://www.coinbase.com/api
|
44
|
+
https://coinbase.ada.support/api/; font-src ''self'' https://www.coinbase.com
|
45
|
+
https://assets.coinbase.com/ static.coinbase.com; img-src ''self'' data: https://www.coinbase.com
|
46
|
+
https://images.coinbase.com https://exceptions.coinbase.com https://coinbase-uploads.s3.amazonaws.com
|
47
|
+
https://s3.amazonaws.com/app-public/ https://maps.gstatic.com https://ssl.google-analytics.com
|
48
|
+
https://www.google.com https://maps.googleapis.com https://csi.gstatic.com
|
49
|
+
https://www.google-analytics.com https://res.cloudinary.com https://secure.gravatar.com
|
50
|
+
https://i2.wp.com https://*.online-metrix.net https://assets.coinbase.com/
|
51
|
+
https://hexagon-analytics.com https://api.mixpanel.com https://cb-brand.s3.amazonaws.com
|
52
|
+
https://googleads.g.doubleclick.net https://stats.g.doubleclick.net/r/collect
|
53
|
+
blob: static.coinbase.com https://d124s1zbdqkqqe.cloudfront.net https://www.facebook.com/tr;
|
54
|
+
media-src ''self'' https://www.coinbase.com blob:; object-src ''self'' data:
|
55
|
+
blob: https://www.coinbase.com https://cdn.siftscience.com https://*.online-metrix.net
|
56
|
+
https://www.gstatic.com https://www.google.com/recaptcha/api/; script-src
|
57
|
+
''self'' ''unsafe-inline'' ''unsafe-eval'' https://www.coinbase.com https://cdn.siftscience.com
|
58
|
+
https://*.newrelic.com https://bam.nr-data.net https://*.google-analytics.com
|
59
|
+
https://www.google.com https://www.gstatic.com https://*.online-metrix.net
|
60
|
+
https://code.jquery.com https://chart.googleapis.com https://maps.googleapis.com
|
61
|
+
https://maps.gstatic.com https://netverify.com https://ajax.cloudflare.com
|
62
|
+
https://cdn.plaid.com/link/v2/stable/ https://www.googletagmanager.com/gtag/js
|
63
|
+
https://www.googletagmanager.com/gtm.js https://www.googleadservices.com https://googleads.g.doubleclick.net
|
64
|
+
https://assets.coinbase.com/ static.coinbase.com; style-src ''self'' ''unsafe-inline''
|
65
|
+
https://www.coinbase.com https://assets.coinbase.com/ static.coinbase.com;
|
66
|
+
report-uri /csp-report'
|
67
|
+
Etag:
|
68
|
+
- W/"b660661171f1c14502e61d57793828bd"
|
69
|
+
Expect-Ct:
|
70
|
+
- enforce; max-age=86400; report-uri="https://coinbase.report-uri.io/r/default/ct/reportOnly"
|
71
|
+
Referrer-Policy:
|
72
|
+
- strict-origin-when-cross-origin
|
73
|
+
Strict-Transport-Security:
|
74
|
+
- max-age=31536000; includeSubDomains; preload
|
75
|
+
Vary:
|
76
|
+
- Origin,Accept-Encoding
|
77
|
+
X-Content-Type-Options:
|
78
|
+
- nosniff
|
79
|
+
X-Download-Options:
|
80
|
+
- noopen
|
81
|
+
X-Frame-Options:
|
82
|
+
- DENY
|
83
|
+
X-Permitted-Cross-Domain-Policies:
|
84
|
+
- none
|
85
|
+
X-Powered-By:
|
86
|
+
- Proof-of-Work
|
87
|
+
X-Request-Id:
|
88
|
+
- 875e27b8-fda6-465f-b629-d783863ee485
|
89
|
+
X-Xss-Protection:
|
90
|
+
- 1; mode=block
|
91
|
+
Cf-Cache-Status:
|
92
|
+
- HIT
|
93
|
+
Expires:
|
94
|
+
- Thu, 08 Nov 2018 17:54:26 GMT
|
95
|
+
Server:
|
96
|
+
- cloudflare
|
97
|
+
Cf-Ray:
|
98
|
+
- 4769e6e35bd0a491-PNH
|
99
|
+
body:
|
100
|
+
encoding: ASCII-8BIT
|
101
|
+
string: '{"data":{"base":"BCH","currency":"USD","amount":"587.97"}}'
|
102
|
+
http_version:
|
103
|
+
recorded_at: Sun, 11 Nov 2018 17:54:00 GMT
|
3
104
|
- request:
|
4
105
|
method: get
|
5
106
|
uri: https://api.coinbase.com/v2/prices/BTC-USD/spot
|
@@ -19,16 +120,16 @@ http_interactions:
|
|
19
120
|
message: OK
|
20
121
|
headers:
|
21
122
|
Date:
|
22
|
-
-
|
123
|
+
- Thu, 08 Nov 2018 17:53:57 GMT
|
23
124
|
Content-Type:
|
24
125
|
- application/json; charset=utf-8
|
25
|
-
|
26
|
-
-
|
126
|
+
Content-Length:
|
127
|
+
- '82'
|
27
128
|
Connection:
|
28
129
|
- keep-alive
|
29
130
|
Set-Cookie:
|
30
|
-
- __cfduid=
|
31
|
-
|
131
|
+
- __cfduid=d04b2b46c8cd0d0c16375884efe5462451541699636; expires=Fri, 08-Nov-19
|
132
|
+
17:53:56 GMT; path=/; domain=.coinbase.com; HttpOnly
|
32
133
|
Cache-Control:
|
33
134
|
- public, max-age=30
|
34
135
|
Content-Disposition:
|
@@ -65,7 +166,7 @@ http_interactions:
|
|
65
166
|
https://www.coinbase.com https://assets.coinbase.com/ static.coinbase.com;
|
66
167
|
report-uri /csp-report'
|
67
168
|
Etag:
|
68
|
-
- W/"
|
169
|
+
- W/"4f5f2ad82a3963f92662806d45ab3edf"
|
69
170
|
Expect-Ct:
|
70
171
|
- enforce; max-age=86400; report-uri="https://coinbase.report-uri.io/r/default/ct/reportOnly"
|
71
172
|
Referrer-Policy:
|
@@ -85,22 +186,22 @@ http_interactions:
|
|
85
186
|
X-Powered-By:
|
86
187
|
- Proof-of-Work
|
87
188
|
X-Request-Id:
|
88
|
-
-
|
189
|
+
- d16c1c0c-26ea-4fc7-a1ef-b02abfa8bf80
|
89
190
|
X-Xss-Protection:
|
90
191
|
- 1; mode=block
|
91
192
|
Cf-Cache-Status:
|
92
193
|
- HIT
|
93
194
|
Expires:
|
94
|
-
-
|
195
|
+
- Thu, 08 Nov 2018 17:54:27 GMT
|
95
196
|
Server:
|
96
197
|
- cloudflare
|
97
198
|
Cf-Ray:
|
98
|
-
-
|
199
|
+
- 4769e6ea49b4a485-PNH
|
99
200
|
body:
|
100
201
|
encoding: ASCII-8BIT
|
101
|
-
string: '{"data":{"base":"BTC","currency":"USD","amount":"
|
202
|
+
string: '{"data":{"base":"BTC","currency":"USD","amount":"6424.00"}}'
|
102
203
|
http_version:
|
103
|
-
recorded_at:
|
204
|
+
recorded_at: Sun, 11 Nov 2018 17:54:00 GMT
|
104
205
|
- request:
|
105
206
|
method: get
|
106
207
|
uri: https://api.coinbase.com/v2/prices/ETH-USD/spot
|
@@ -120,7 +221,7 @@ http_interactions:
|
|
120
221
|
message: OK
|
121
222
|
headers:
|
122
223
|
Date:
|
123
|
-
-
|
224
|
+
- Thu, 08 Nov 2018 17:53:59 GMT
|
124
225
|
Content-Type:
|
125
226
|
- application/json; charset=utf-8
|
126
227
|
Content-Length:
|
@@ -128,8 +229,8 @@ http_interactions:
|
|
128
229
|
Connection:
|
129
230
|
- keep-alive
|
130
231
|
Set-Cookie:
|
131
|
-
- __cfduid=
|
132
|
-
|
232
|
+
- __cfduid=d233c228c665e49647bb663088827d07f1541699638; expires=Fri, 08-Nov-19
|
233
|
+
17:53:58 GMT; path=/; domain=.coinbase.com; HttpOnly
|
133
234
|
Cache-Control:
|
134
235
|
- public, max-age=30
|
135
236
|
Content-Disposition:
|
@@ -166,7 +267,7 @@ http_interactions:
|
|
166
267
|
https://www.coinbase.com https://assets.coinbase.com/ static.coinbase.com;
|
167
268
|
report-uri /csp-report'
|
168
269
|
Etag:
|
169
|
-
- W/"
|
270
|
+
- W/"3f88f9ab53d68d44e3364543ddfdb274"
|
170
271
|
Expect-Ct:
|
171
272
|
- enforce; max-age=86400; report-uri="https://coinbase.report-uri.io/r/default/ct/reportOnly"
|
172
273
|
Referrer-Policy:
|
@@ -186,20 +287,20 @@ http_interactions:
|
|
186
287
|
X-Powered-By:
|
187
288
|
- Proof-of-Work
|
188
289
|
X-Request-Id:
|
189
|
-
-
|
290
|
+
- bc27a504-585e-4550-98f5-a71b699a954b
|
190
291
|
X-Xss-Protection:
|
191
292
|
- 1; mode=block
|
192
293
|
Cf-Cache-Status:
|
193
294
|
- HIT
|
194
295
|
Expires:
|
195
|
-
-
|
296
|
+
- Thu, 08 Nov 2018 17:54:29 GMT
|
196
297
|
Server:
|
197
298
|
- cloudflare
|
198
299
|
Cf-Ray:
|
199
|
-
-
|
300
|
+
- 4769e6f1aa45a4af-PNH
|
200
301
|
body:
|
201
302
|
encoding: ASCII-8BIT
|
202
|
-
string: '{"data":{"base":"ETH","currency":"USD","amount":"
|
303
|
+
string: '{"data":{"base":"ETH","currency":"USD","amount":"211.81"}}'
|
203
304
|
http_version:
|
204
|
-
recorded_at:
|
305
|
+
recorded_at: Sun, 11 Nov 2018 17:54:00 GMT
|
205
306
|
recorded_with: VCR 4.0.0
|
data/spec/spec_helper.rb
CHANGED
@@ -107,6 +107,14 @@ RSpec.configure do |config|
|
|
107
107
|
|
108
108
|
ActiveRecord::Base.establish_connection(adapter: 'postgresql', database: 'cryptocoin_payable_test')
|
109
109
|
create_tables
|
110
|
+
|
111
|
+
CryptocoinPayable::CurrencyConversion.coin_types.keys.each do |coin_type|
|
112
|
+
CryptocoinPayable::CurrencyConversion.create!(
|
113
|
+
coin_type: coin_type,
|
114
|
+
currency: 1,
|
115
|
+
price: 1
|
116
|
+
)
|
117
|
+
end
|
110
118
|
end
|
111
119
|
|
112
120
|
config.after(:suite) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cryptocoin_payable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Salis
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-11-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -339,6 +339,7 @@ files:
|
|
339
339
|
- spec/acceptance/adapters/bitcoin_cash_spec.rb
|
340
340
|
- spec/acceptance/adapters/bitcoin_spec.rb
|
341
341
|
- spec/acceptance/adapters/ethereum_spec.rb
|
342
|
+
- spec/acceptance/coin_payment_spec.rb
|
342
343
|
- spec/acceptance/commands/payment_processor_spec.rb
|
343
344
|
- spec/acceptance/commands/pricing_processor_spec.rb
|
344
345
|
- spec/dummy/README.rdoc
|
@@ -393,6 +394,7 @@ files:
|
|
393
394
|
- spec/fixtures/vcr_cassettes/CryptocoinPayable_Adapters_Bitcoin/gives_zero_instead_of_null_for_zero-value_transactions.yml
|
394
395
|
- spec/fixtures/vcr_cassettes/CryptocoinPayable_Adapters_Bitcoin/handles_nil.yml
|
395
396
|
- spec/fixtures/vcr_cassettes/CryptocoinPayable_Adapters_Bitcoin/raises_an_error_when_an_invalid_address_is_passed.yml
|
397
|
+
- spec/fixtures/vcr_cassettes/CryptocoinPayable_Adapters_Bitcoin/returns_zero_estimated_value_for_zero-value_transactions.yml
|
396
398
|
- spec/fixtures/vcr_cassettes/CryptocoinPayable_Adapters_Bitcoin/when_the_Block_Explorer_API_fails/falls_back_to_using_the_BlockCypher_API.yml
|
397
399
|
- spec/fixtures/vcr_cassettes/CryptocoinPayable_Adapters_BitcoinCash/gets_an_empty_result_when_no_transactions_found.yml
|
398
400
|
- spec/fixtures/vcr_cassettes/CryptocoinPayable_Adapters_BitcoinCash/gets_transactions_for_a_given_address.yml
|
@@ -438,6 +440,7 @@ test_files:
|
|
438
440
|
- spec/acceptance/adapters/bitcoin_cash_spec.rb
|
439
441
|
- spec/acceptance/adapters/bitcoin_spec.rb
|
440
442
|
- spec/acceptance/adapters/ethereum_spec.rb
|
443
|
+
- spec/acceptance/coin_payment_spec.rb
|
441
444
|
- spec/acceptance/commands/payment_processor_spec.rb
|
442
445
|
- spec/acceptance/commands/pricing_processor_spec.rb
|
443
446
|
- spec/dummy/README.rdoc
|
@@ -492,6 +495,7 @@ test_files:
|
|
492
495
|
- spec/fixtures/vcr_cassettes/CryptocoinPayable_Adapters_Bitcoin/gives_zero_instead_of_null_for_zero-value_transactions.yml
|
493
496
|
- spec/fixtures/vcr_cassettes/CryptocoinPayable_Adapters_Bitcoin/handles_nil.yml
|
494
497
|
- spec/fixtures/vcr_cassettes/CryptocoinPayable_Adapters_Bitcoin/raises_an_error_when_an_invalid_address_is_passed.yml
|
498
|
+
- spec/fixtures/vcr_cassettes/CryptocoinPayable_Adapters_Bitcoin/returns_zero_estimated_value_for_zero-value_transactions.yml
|
495
499
|
- spec/fixtures/vcr_cassettes/CryptocoinPayable_Adapters_Bitcoin/when_the_Block_Explorer_API_fails/falls_back_to_using_the_BlockCypher_API.yml
|
496
500
|
- spec/fixtures/vcr_cassettes/CryptocoinPayable_Adapters_BitcoinCash/gets_an_empty_result_when_no_transactions_found.yml
|
497
501
|
- spec/fixtures/vcr_cassettes/CryptocoinPayable_Adapters_BitcoinCash/gets_transactions_for_a_given_address.yml
|