rubyrave 0.1.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/.gitignore +8 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +26 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/rubyrave.rb +4 -0
- data/lib/rubyrave/client.rb +119 -0
- data/lib/rubyrave/version.rb +3 -0
- data/rubyrave.gemspec +28 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 91eb050ecb65ffc7367cbe0485edb2865c7b0ded
|
4
|
+
data.tar.gz: eac6208fed50da3be8e26668619054191e117bf3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ac8a85857a7196874550f5a39b4050dc606f68cc04afdb0bbb06b07c06dde5294d3e6e556b60dc72706bc642d8d504404358034a0892fb02e52bfa739d2bd5d7
|
7
|
+
data.tar.gz: 25b37b3643bbaec559512815a6e2c3174fb5e00c22c8c5bcd2dd95d9eff74e708d9b296d7b955c5d0d6841770cc57a9a45fceab013c4bb4e85a2caac983f2408
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rubyrave (0.1.0)
|
5
|
+
httparty (~> 0.16.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
httparty (0.16.0)
|
11
|
+
multi_xml (>= 0.5.2)
|
12
|
+
minitest (5.11.3)
|
13
|
+
multi_xml (0.6.0)
|
14
|
+
rake (10.5.0)
|
15
|
+
|
16
|
+
PLATFORMS
|
17
|
+
x64-mingw32
|
18
|
+
|
19
|
+
DEPENDENCIES
|
20
|
+
bundler (~> 1.16)
|
21
|
+
minitest (~> 5.0)
|
22
|
+
rake (~> 10.0)
|
23
|
+
rubyrave!
|
24
|
+
|
25
|
+
BUNDLED WITH
|
26
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Michael Bluman
|
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,39 @@
|
|
1
|
+
# Rubyrave
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rubyrave`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'rubyrave'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install rubyrave
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
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.
|
30
|
+
|
31
|
+
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).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rubyrave.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rubyrave"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/rubyrave.rb
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
module Rubyrave
|
2
|
+
class Client
|
3
|
+
|
4
|
+
include HTTParty
|
5
|
+
format :json
|
6
|
+
|
7
|
+
RAVE_SANDBOX_URL = "http://flw-pms-dev.eu-west-1.elasticbeanstalk.com/"
|
8
|
+
RAVE_LIVE_URL = "https://api.ravepay.co/"
|
9
|
+
|
10
|
+
base_uri RAVE_SANDBOX_URL
|
11
|
+
|
12
|
+
attr_accessor :public_key, :secret_key, :http_timeout, :mode, :payment_method, :pbfpubkey
|
13
|
+
|
14
|
+
def initialize(public_key, secret_key, pbfpubkey, mode = "test", payment_method = 'sas', http_timeout = 25)
|
15
|
+
self.public_key = public_key
|
16
|
+
self.secret_key = secret_key
|
17
|
+
self.pbfpubkey = pbfpubkey
|
18
|
+
self.http_timeout = http_timeout
|
19
|
+
self.mode = mode
|
20
|
+
if mode == "test"
|
21
|
+
self.class.base_uri RAVE_SANDBOX_URL
|
22
|
+
else
|
23
|
+
self.class.base_uri RAVE_LIVE_URL
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
# Functions to have
|
29
|
+
# 1. initialize() pass live or test keys to this function. DONE
|
30
|
+
# 2. SetMode() switch between live mode and test mode. DONE
|
31
|
+
# 3. Encrypt3DES() performs 3DES encryption on key and payload DONE
|
32
|
+
# 4. getKey() This generates the key using the secret key DONE
|
33
|
+
# 5. DirectCharge() required param is client, the rest is in the library DONE
|
34
|
+
# 6. ValidateCardCharge() transacionReference and OTP required
|
35
|
+
# 7. ValidateAccountCharge() same as above
|
36
|
+
# 8. VerifyTransaction() flw_ref, seckey, normalize=1 required tx_ref optional
|
37
|
+
# 9. VerifyTransactionXrequery() flw_ref, seckey, tx_ref, last_attemp, only_successful
|
38
|
+
# 10. ListBanks() DONE
|
39
|
+
# 11. ConversionRate() requires seckey origin_currency destination_currency optional amount
|
40
|
+
# 12. StopRecurringPayment() id of recurring payment and seckey
|
41
|
+
# 13. ListRecurringTransactions() seckey only
|
42
|
+
# 14. ListSingleRecurringPayment() seckey tx_id
|
43
|
+
# 15. PreautorizeCard() client seckey alg
|
44
|
+
# 16. CapturePayment() seckey ref
|
45
|
+
# 17. RefundPayment() seckey ref action=refund
|
46
|
+
# 18. VoidPayment() seckey ref action=void
|
47
|
+
# 19. ChargeWithToken() long list of body params
|
48
|
+
# 20. SetPaymentMethod()
|
49
|
+
# 21. CreateIntegrityChecksum() DONE
|
50
|
+
|
51
|
+
def set_mode(mode)
|
52
|
+
self.mode = mode
|
53
|
+
end
|
54
|
+
|
55
|
+
def set_payment_method(payment_meethod)
|
56
|
+
self.payment_method = payment_method
|
57
|
+
end
|
58
|
+
|
59
|
+
def encrypt(key, data)
|
60
|
+
cipher = OpenSSL::Cipher::Cipher.new(“des3”)
|
61
|
+
cipher.encrypt # Call this before setting key or iv
|
62
|
+
cipher.key = key
|
63
|
+
ciphertext = cipher.update(data)
|
64
|
+
ciphertext << cipher.final
|
65
|
+
return Base64.encode64(ciphertext)
|
66
|
+
end
|
67
|
+
|
68
|
+
def get_key(stuff)
|
69
|
+
hash = Digest::MD5.hexdigest("this is a test")
|
70
|
+
last_twelve = hash[hash.length-13..hash.length-1]
|
71
|
+
private_secret_key = self.secret_key
|
72
|
+
private_secret_key['FLWSECK-'] = ''
|
73
|
+
first_twelve = private_secret_key[0..11]
|
74
|
+
return first_twelve + last_twelve
|
75
|
+
end
|
76
|
+
|
77
|
+
def checksum(payload)
|
78
|
+
payload.sort_by { |k,v| k.to_s }
|
79
|
+
hashed_payload = ''
|
80
|
+
family.each { |k,v|
|
81
|
+
hashed_payload << v
|
82
|
+
}
|
83
|
+
return Digest::SHA256.hexdigest(hashed_payload + self.secret_key)
|
84
|
+
end
|
85
|
+
|
86
|
+
def list_banks()
|
87
|
+
perform_get('flwv3-pug/getpaidx/api/flwpbf-banks.js', {:json => 1})
|
88
|
+
end
|
89
|
+
|
90
|
+
def direct_charge(client_data)
|
91
|
+
payload = {
|
92
|
+
"PBFPubKey": self.pbfpubkey,
|
93
|
+
"client": client_data,
|
94
|
+
"alg": "3DES-24"
|
95
|
+
}
|
96
|
+
perform_post('flwv3-pug/getpaidx/api/charge', payload)
|
97
|
+
end
|
98
|
+
|
99
|
+
def perform_get(endpoint, params = {})
|
100
|
+
http_params = {}
|
101
|
+
unless params.empty?
|
102
|
+
http_params[:query] = params
|
103
|
+
end
|
104
|
+
unless self.http_timeout.nil?
|
105
|
+
http_params[:timeout] = self.http_timeout
|
106
|
+
end
|
107
|
+
self.class.get("/#{endpoint}", http_params)
|
108
|
+
end
|
109
|
+
|
110
|
+
def perform_post(endpoint, data)
|
111
|
+
self.class.post(endpoint,
|
112
|
+
{
|
113
|
+
:body => data.to_json,
|
114
|
+
:headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json'}
|
115
|
+
})
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
end
|
data/rubyrave.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "rubyrave/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rubyrave"
|
8
|
+
spec.version = Rubyrave::VERSION
|
9
|
+
spec.authors = ["Michael Bluman"]
|
10
|
+
spec.email = ["reasonsbluman@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{This library is a wrapper of Rave API}
|
13
|
+
spec.description = %q{This is a ruby gem that priovides API access to Rave.}
|
14
|
+
spec.homepage = "https://github.com/bluman1/rubyrave/"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
27
|
+
spec.add_dependency "httparty", "~>0.16.0"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubyrave
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Bluman
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-03-01 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: httparty
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.16.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.16.0
|
69
|
+
description: This is a ruby gem that priovides API access to Rave.
|
70
|
+
email:
|
71
|
+
- reasonsbluman@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- lib/rubyrave.rb
|
86
|
+
- lib/rubyrave/client.rb
|
87
|
+
- lib/rubyrave/version.rb
|
88
|
+
- rubyrave.gemspec
|
89
|
+
homepage: https://github.com/bluman1/rubyrave/
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.6.14
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: This library is a wrapper of Rave API
|
113
|
+
test_files: []
|