coin_payments 0.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 +7 -0
- data/.env.sample +5 -0
- data/.gitignore +21 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +108 -0
- data/Rakefile +10 -0
- data/bin/console +16 -0
- data/bin/setup +8 -0
- data/coin_payments.gemspec +50 -0
- data/lib/coin_payments.rb +12 -0
- data/lib/coin_payments/api.rb +241 -0
- data/lib/coin_payments/version.rb +3 -0
- metadata +199 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 328016487034b3deba1192c926090f3b87422aae
|
4
|
+
data.tar.gz: 411256ac94d734378b1265c0878d2b511ff25e1d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c40d12aa8f77e4abd8ad64b1f3093e5dcef93b89a1b8cfaf65fa6c49aebc2ddcbf204b9d423e5b4b055d8bcd5d1891d8bdf56110358f7c87d5f433747fab42a4
|
7
|
+
data.tar.gz: 1f6e943a6a5ff6cc7d252c713105e2ac824d7bd926d8b2ac02d3dbbd9281687e6de831a19d43696428bc4199d8416f245ef8a8c1693d4a386546349a4ac8ac80
|
data/.env.sample
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/Gemfile.lock
|
4
|
+
/_yardoc/
|
5
|
+
/coverage/
|
6
|
+
/doc/
|
7
|
+
/pkg/
|
8
|
+
/spec/reports/
|
9
|
+
/tmp/
|
10
|
+
*.bundle
|
11
|
+
*.so
|
12
|
+
*.o
|
13
|
+
*.a
|
14
|
+
mkmf.log
|
15
|
+
*.sublime-project
|
16
|
+
*.sublime-workspace
|
17
|
+
|
18
|
+
.DS_Store
|
19
|
+
.env
|
20
|
+
.ruby-version
|
21
|
+
.ruby-gemset
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at beneggett@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Ben Eggett
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
# CoinPayments
|
2
|
+
|
3
|
+
Fully Implements the CoinPayments API in Ruby.
|
4
|
+
|
5
|
+
CoinPayments is an integrated payment gateway for cryptocurrencies such as Bitcoin and Litecoin. There are Over 1040 Supported Coins available. You can accept all 1040 supported coins or just one.
|
6
|
+
|
7
|
+
This gem will make it dead simple to work with CoinPayments API set & integrate it into any Ruby Project.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'coin_payments'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install coin_payments
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
You'll first need to create a CoinPayments.net account to get started. If you don't have one, please consider creating one through my affiliate link: https://www.coinpayments.net/index.php?ref=1bf1c996fd6781bd4aabec78dda6250c
|
28
|
+
|
29
|
+
Or if you don't want to sign up through my link, feel free to sign up at https://www.coinpayments.net
|
30
|
+
|
31
|
+
There are many [tools for Merchants available](https://www.coinpayments.net/merchant-tools). We are going to focus on the API integrations.
|
32
|
+
|
33
|
+
There are two sides we'll need to concern ourselves:
|
34
|
+
1. Utilizing the API to manage payments & accounts
|
35
|
+
2. Creating a webhook or Instant Payment Notification (IPN)
|
36
|
+
|
37
|
+
### Utilizing the API
|
38
|
+
|
39
|
+
The only setup needed is to go to the [API Keys page and generate an API key](https://www.coinpayments.net/index.php?cmd=acct_api_keys). You will be given a private and public key used to authenticate your API calls. Make sure you don't share your private key with any 3rd parties!
|
40
|
+
|
41
|
+
Note: You must click 'Edit Permissions' to enable most commands
|
42
|
+
|
43
|
+
You will need to set the following environment variables in your app, and the rest will work automatically
|
44
|
+
|
45
|
+
```
|
46
|
+
COIN_PAYMENTS_PUBLIC_KEY: "your-public-api-key"
|
47
|
+
COIN_PAYMENTS_PRIVATE_KEY: "your-private-api-key"
|
48
|
+
```
|
49
|
+
|
50
|
+
Once those are set, you are now ready to utilize the API.
|
51
|
+
Available features have been implemented per the Features chart below
|
52
|
+
|
53
|
+
|
54
|
+
## Features
|
55
|
+
|
56
|
+
Implemented APIs from [CoinPayments API Docs](https://www.coinpayments.net/apidoc-intro)
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
| API | Docs | Implemented? | Priority |
|
61
|
+
| --- | --- | --- | --- |
|
62
|
+
| **Informational Commands** |
|
63
|
+
| Get Basic Account Info | [📚](https://www.coinpayments.net/apidoc-get-basic-info) | ✅ | 👍 |
|
64
|
+
| Get Exchange Rates / Supported Coins | [📚](https://www.coinpayments.net/apidoc-rates) | ✅ | 👍 |
|
65
|
+
| Get Coin Balances | [📚](https://www.coinpayments.net/apidoc-balances) | ✅ | 👍 |
|
66
|
+
| Get Deposit Address | [📚](https://www.coinpayments.net/apidoc-get-deposit-address) | ✅ | 👍 |
|
67
|
+
| **Receiving Payments** |
|
68
|
+
| Create Transaction | [📚](https://www.coinpayments.net/apidoc-create-transaction) | ✅ | 👍 |
|
69
|
+
| Callback Addresses | [📚](https://www.coinpayments.net/apidoc-get-callback-address) | ✅ | 👍 |
|
70
|
+
| Get TX Info | [📚](https://www.coinpayments.net/apidoc-get-tx-info) | ✅ | 👍 |
|
71
|
+
| Get TX List | [📚](https://www.coinpayments.net/apidoc-get-tx-ids) | ✅ | 👍 |
|
72
|
+
| **Withdrawals/Transfers** |
|
73
|
+
| Create Transfer | [📚](https://www.coinpayments.net/apidoc-create-transfer) | ❌ | 👌 |
|
74
|
+
| Create Withdrawal / Mass Withdrawal | [📚](https://www.coinpayments.net/apidoc-create-withdrawal) | ❌ | 👌 |
|
75
|
+
| Convert Coins | [📚](https://www.coinpayments.net/apidoc-convert) | ❌ | 👌 |
|
76
|
+
| Conversion Limits | [📚](https://www.coinpayments.net/apidoc-convert-limits) | ❌ | 👌 |
|
77
|
+
| Get Withdrawal History | [📚](https://www.coinpayments.net/apidoc-get-withdrawal-history) | ❌ | 👌 |
|
78
|
+
| Get Withdrawal Info | [📚](https://www.coinpayments.net/apidoc-get-withdrawal-info) | ❌ | 👌 |
|
79
|
+
| Get Conversion Info | [📚](https://www.coinpayments.net/apidoc-get-conversion-info) | ❌ | 👌 |
|
80
|
+
| **$PayByName** |
|
81
|
+
| Get Profile Information | [📚](https://www.coinpayments.net/apidoc-get-pbn-info) | ❌ | 👎 |
|
82
|
+
| Get Tag List | [📚](https://www.coinpayments.net/apidoc-get-pbn-list) | ❌ | 👎 |
|
83
|
+
| Update Tag Profile | [📚](https://www.coinpayments.net/apidoc-update-pbn-tag) | ❌ | 👎 |
|
84
|
+
| Claim Tag | [📚](https://www.coinpayments.net/apidoc-claim-pbn-tag) | ❌ | 👎 |
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
## Development
|
93
|
+
|
94
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
95
|
+
|
96
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
97
|
+
|
98
|
+
## Contributing
|
99
|
+
|
100
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/beneggett/coin_payments. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
101
|
+
|
102
|
+
## License
|
103
|
+
|
104
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
105
|
+
|
106
|
+
## Code of Conduct
|
107
|
+
|
108
|
+
Everyone interacting in the CoinPayments project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/beneggett/coin_payments/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "dotenv"
|
3
|
+
Dotenv.load
|
4
|
+
require "bundler/setup"
|
5
|
+
require "coin_payments"
|
6
|
+
|
7
|
+
|
8
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
9
|
+
# with your gem easier. You can also use a different console, if you like.
|
10
|
+
|
11
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
12
|
+
require "pry"
|
13
|
+
Pry.start
|
14
|
+
|
15
|
+
# require "irb"
|
16
|
+
# IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "coin_payments/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "coin_payments"
|
8
|
+
spec.version = CoinPayments::VERSION
|
9
|
+
spec.authors = ["Ben Eggett"]
|
10
|
+
spec.email = ["beneggett@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Coinpayments.net API wrapper}
|
13
|
+
spec.description = %q{Fully implements CoinPayments.net API}
|
14
|
+
spec.homepage = "https://github.com/beneggett/coin_payments"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
# Specify which files should be added to the gem when it is released.
|
28
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
29
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
30
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
31
|
+
end
|
32
|
+
spec.bindir = "exe"
|
33
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
|
+
spec.require_paths = ["lib"]
|
35
|
+
|
36
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
37
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
38
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
39
|
+
# spec.add_development_dependency "vcr"
|
40
|
+
# spec.add_development_dependency "webmock"
|
41
|
+
spec.add_development_dependency "pry"
|
42
|
+
spec.add_development_dependency "guard"
|
43
|
+
spec.add_development_dependency "guard-minitest"
|
44
|
+
# spec.add_development_dependency "coveralls"
|
45
|
+
spec.add_development_dependency "simplecov"
|
46
|
+
spec.add_development_dependency "dotenv"
|
47
|
+
spec.add_dependency "httparty", ">= 0.14.0"
|
48
|
+
# spec.add_dependency "activesupport"
|
49
|
+
spec.add_dependency "builder"
|
50
|
+
end
|
@@ -0,0 +1,241 @@
|
|
1
|
+
module CoinPayments
|
2
|
+
class Api
|
3
|
+
URL_ENDPOINT = ENV.fetch("COIN_PAYMENTS_BASE_URL", "https://www.coinpayments.net/api.php")
|
4
|
+
API_VERSION = ENV.fetch("COIN_PAYMENTS_API_VERSION", "1")
|
5
|
+
|
6
|
+
include HTTParty
|
7
|
+
|
8
|
+
def post(body, openstruct: true)
|
9
|
+
response = self.class.post(URL_ENDPOINT, body: modify_body(body), timeout: 30, headers: modify_headers(body))
|
10
|
+
if response["error"] == "ok"
|
11
|
+
if openstruct
|
12
|
+
JSON::parse(response["result"].to_json, object_class: OpenStruct)
|
13
|
+
else
|
14
|
+
response
|
15
|
+
end
|
16
|
+
else
|
17
|
+
OpenStruct.new response
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
### Informational Commands
|
22
|
+
|
23
|
+
|
24
|
+
## Get Basic Account Info
|
25
|
+
# CoinPayments::Api.new.get_basic_account_info
|
26
|
+
def get_basic_account_info
|
27
|
+
body = {cmd: "get_basic_info"}
|
28
|
+
post body
|
29
|
+
end
|
30
|
+
# Convert epoch time, fwiw: Time.at response.time_joined
|
31
|
+
|
32
|
+
## Get Exchange Rates / Supported Coins
|
33
|
+
# CoinPayments::Api.new.get_exchange_rates
|
34
|
+
# CoinPayments::Api.new.get_exchange_rates accepted: true
|
35
|
+
# CoinPayments::Api.new.get_exchange_rates accepted: true, accepted_only: true
|
36
|
+
def get_exchange_rates(options = {})
|
37
|
+
body = {
|
38
|
+
cmd: "rates"
|
39
|
+
}
|
40
|
+
body[:short] = 1 if options[:short]
|
41
|
+
body[:accepted] = 1 if options[:accepted]
|
42
|
+
response = post body, openstruct: false
|
43
|
+
if options[:accepted_only]
|
44
|
+
response.to_h.delete_if { |_k, v| v[:accepted] == 0 }
|
45
|
+
else
|
46
|
+
response.to_h
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
## Get Coin Balances
|
51
|
+
# CoinPayments::Api.new.get_coin_balances
|
52
|
+
# CoinPayments::Api.new.get_coin_balances all: true
|
53
|
+
def get_coin_balances(options = {})
|
54
|
+
body = {
|
55
|
+
cmd: "balances"
|
56
|
+
}
|
57
|
+
body[:all] = 1 if options[:all]
|
58
|
+
post body
|
59
|
+
end
|
60
|
+
|
61
|
+
## Get Deposit Address
|
62
|
+
# CoinPayments::Api.new.get_deposit_address
|
63
|
+
def get_deposit_address(currency = "BTC")
|
64
|
+
body = {
|
65
|
+
cmd: "get_deposit_address",
|
66
|
+
currency: currency
|
67
|
+
}
|
68
|
+
post body
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
### Receiving Payments
|
74
|
+
## Create Transaction
|
75
|
+
# CoinPayments::Api.new.create_transaction amount: 10, currency1: "USD", currency2: "BTC", buyer_email: "john@doe.com", buyer_name: "John Doe"
|
76
|
+
def create_transaction(options = {})
|
77
|
+
required_params = %i( amount currency1 currency2 buyer_email)
|
78
|
+
required_params_present = required_params.all? { |e| options.keys.include?(e) }
|
79
|
+
raise "Required Argument Error. Must include #{required_params.join(', ')}" unless required_params_present
|
80
|
+
body = {
|
81
|
+
cmd: "create_transaction",
|
82
|
+
amount: options[:amount],
|
83
|
+
currency1: options[:currency1],
|
84
|
+
currency2: options[:currency2],
|
85
|
+
buyer_email: options[:buyer_email],
|
86
|
+
}
|
87
|
+
body[:buyer_name] = options[:buyer_name] if options[:buyer_name]
|
88
|
+
body[:item_name] = options[:item_name] if options[:item_name]
|
89
|
+
body[:item_number] = options[:item_number] if options[:item_number]
|
90
|
+
body[:invoice] = options[:invoice] if options[:invoice]
|
91
|
+
body[:custom] = options[:custom] if options[:custom]
|
92
|
+
body[:address] = options[:address] if options[:address]
|
93
|
+
body[:ipn_url] = options[:ipn_url] if options[:ipn_url]
|
94
|
+
post body
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
## Callback Addresses
|
99
|
+
# CoinPayments::Api.new.callback_addresses
|
100
|
+
def callback_addresses(options = {})
|
101
|
+
body = {
|
102
|
+
cmd: "get_callback_address",
|
103
|
+
currency: options.fetch(:currency, "BTC")
|
104
|
+
}
|
105
|
+
body[:ipn_url] = options[:ipn_url] if options[:ipn_url]
|
106
|
+
post body
|
107
|
+
end
|
108
|
+
|
109
|
+
## Get TX Info
|
110
|
+
# CoinPayments::Api.new.get_tx_info "CPCK5DNHP28DYY3GMWBTWLOIZM"
|
111
|
+
# CoinPayments::Api.new.get_tx_info "CPCK5DNHP28DYY3GMWBTWLOIZM", "CPCK5OLFDULWTYNDW7UQ0LYE2D" # Multiple lookup, don't recommend as it returns funny & they don't like more than 25
|
112
|
+
def get_tx_info(*transaction_ids)
|
113
|
+
cmd = if transaction_ids.size > 1
|
114
|
+
"get_tx_info_multi"
|
115
|
+
else
|
116
|
+
"get_tx_info"
|
117
|
+
end
|
118
|
+
body = {
|
119
|
+
cmd: cmd,
|
120
|
+
txid: transaction_ids.join('|'),
|
121
|
+
# full: 0 # I don't see any practical use for this
|
122
|
+
}
|
123
|
+
post body, openstruct: cmd != "get_tx_info_multi"
|
124
|
+
end
|
125
|
+
|
126
|
+
## Get TX List
|
127
|
+
# CoinPayments::Api.new.get_tx_list
|
128
|
+
# CoinPayments::Api.new.get_tx_list limit: 5
|
129
|
+
# CoinPayments::Api.new.get_tx_list limit: 5, start: 5
|
130
|
+
# CoinPayments::Api.new.get_tx_list newer: (Time.now - 1800).to_i
|
131
|
+
def get_tx_list(options = {})
|
132
|
+
body = {
|
133
|
+
cmd: "get_tx_ids"
|
134
|
+
}
|
135
|
+
body[:limit] = [options[:limit].to_i, 100].min if options[:limit] # limit The maximum number of transaction IDs to return from 1-100. (default: 25)
|
136
|
+
body[:start] = options[:start] if options[:start] # start What transaction # to start from (for iteration/pagination.) (default: 0, starts with your newest transactions.)
|
137
|
+
body[:newer] = options[:newer] if options[:newer] # newer Return transactions started at the given Unix timestamp or later. (default: 0)
|
138
|
+
body[:all] = options[:all] if options[:all] # By default we return an array of TX IDs where you are the seller for use with get_tx_info_multi or get_tx_info. If all is set to 1 returns an array with TX IDs and whether you are the seller or buyer for the transaction.
|
139
|
+
post body
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
### Withdrawals/Transfers
|
144
|
+
## Create Transfer
|
145
|
+
# CoinPayments::Api.new.create_transfer
|
146
|
+
def create_transfer
|
147
|
+
|
148
|
+
end
|
149
|
+
|
150
|
+
## Create Withdrawal / Mass Withdrawal
|
151
|
+
# CoinPayments::Api.new.create_withdrawal
|
152
|
+
def create_withdrawal
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
## Convert Coins
|
157
|
+
# CoinPayments::Api.new.convert_coins
|
158
|
+
def convert_coins
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
## Conversion Limits
|
163
|
+
# CoinPayments::Api.new.conversion_limits
|
164
|
+
def conversion_limits
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
## Get Withdrawal History
|
169
|
+
# CoinPayments::Api.new.get_withdrawal_history
|
170
|
+
def get_withdrawal_history
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
## Get Withdrawal Info
|
175
|
+
# CoinPayments::Api.new.get_withdrawal_info
|
176
|
+
def get_withdrawal_info
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
## Get Conversion Info
|
181
|
+
# CoinPayments::Api.new.get_conversion_info
|
182
|
+
def get_conversion_info
|
183
|
+
|
184
|
+
end
|
185
|
+
|
186
|
+
|
187
|
+
### PayByName
|
188
|
+
## Get Profile Information
|
189
|
+
# CoinPayments::Api.new.get_profile_information
|
190
|
+
def get_profile_information
|
191
|
+
|
192
|
+
end
|
193
|
+
|
194
|
+
## Get Tag List
|
195
|
+
# CoinPayments::Api.new.get_tag_list
|
196
|
+
def get_tag_list
|
197
|
+
|
198
|
+
end
|
199
|
+
|
200
|
+
## Update Tag Profile
|
201
|
+
# CoinPayments::Api.new.update_tag_profile
|
202
|
+
def update_tag_profile
|
203
|
+
|
204
|
+
end
|
205
|
+
|
206
|
+
## Claim Tag
|
207
|
+
# CoinPayments::Api.new.claim_tag
|
208
|
+
def claim_tag
|
209
|
+
|
210
|
+
end
|
211
|
+
|
212
|
+
|
213
|
+
private
|
214
|
+
|
215
|
+
def modify_body(body)
|
216
|
+
default_params = {
|
217
|
+
version: API_VERSION,
|
218
|
+
key: ENV.fetch("COIN_PAYMENTS_PUBLIC_KEY", 'not-implemented')
|
219
|
+
}
|
220
|
+
default_params.merge body
|
221
|
+
end
|
222
|
+
|
223
|
+
def modify_headers(body)
|
224
|
+
required_params = {
|
225
|
+
version: API_VERSION,
|
226
|
+
key: ENV.fetch("COIN_PAYMENTS_PUBLIC_KEY", 'not-implemented'),
|
227
|
+
}.merge(body)
|
228
|
+
headers = {
|
229
|
+
'Content-Type' => "application/x-www-form-urlencoded",
|
230
|
+
'Content-transfer-encoding' => 'text',
|
231
|
+
}
|
232
|
+
headers["HMAC"] = hmac_encrypt(required_params)
|
233
|
+
headers
|
234
|
+
end
|
235
|
+
|
236
|
+
def hmac_encrypt(required_params)
|
237
|
+
OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha512'), ENV.fetch("COIN_PAYMENTS_PRIVATE_KEY", 'not-implemented'), HTTParty::HashConversions.to_params(required_params))
|
238
|
+
end
|
239
|
+
|
240
|
+
end
|
241
|
+
end
|
metadata
ADDED
@@ -0,0 +1,199 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: coin_payments
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Eggett
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-11-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard-minitest
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: dotenv
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: httparty
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.14.0
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.14.0
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: builder
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description: Fully implements CoinPayments.net API
|
154
|
+
email:
|
155
|
+
- beneggett@gmail.com
|
156
|
+
executables: []
|
157
|
+
extensions: []
|
158
|
+
extra_rdoc_files: []
|
159
|
+
files:
|
160
|
+
- ".env.sample"
|
161
|
+
- ".gitignore"
|
162
|
+
- ".travis.yml"
|
163
|
+
- CODE_OF_CONDUCT.md
|
164
|
+
- Gemfile
|
165
|
+
- LICENSE.txt
|
166
|
+
- README.md
|
167
|
+
- Rakefile
|
168
|
+
- bin/console
|
169
|
+
- bin/setup
|
170
|
+
- coin_payments.gemspec
|
171
|
+
- lib/coin_payments.rb
|
172
|
+
- lib/coin_payments/api.rb
|
173
|
+
- lib/coin_payments/version.rb
|
174
|
+
homepage: https://github.com/beneggett/coin_payments
|
175
|
+
licenses:
|
176
|
+
- MIT
|
177
|
+
metadata:
|
178
|
+
allowed_push_host: https://rubygems.org
|
179
|
+
post_install_message:
|
180
|
+
rdoc_options: []
|
181
|
+
require_paths:
|
182
|
+
- lib
|
183
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
190
|
+
- - ">="
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '0'
|
193
|
+
requirements: []
|
194
|
+
rubyforge_project:
|
195
|
+
rubygems_version: 2.6.12
|
196
|
+
signing_key:
|
197
|
+
specification_version: 4
|
198
|
+
summary: Coinpayments.net API wrapper
|
199
|
+
test_files: []
|