fortenet 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b71ea69ccc48c74e5dd0a71d9930971949b2a2f3
4
+ data.tar.gz: 6101b04ebab977dbfcf1b29ec2d53d85d08100d7
5
+ SHA512:
6
+ metadata.gz: 024aaaa19ff3f660676b2cb9e2fe645d62be70cbc77b15dfb9a0c0083291ea53ff1e2baf33a45857aba4b29ea7fc46f2fca10027f2cc687f6a51a86b978fa4ca
7
+ data.tar.gz: 24c5e1faf8f3e5ff43b6f76367917b7d9179fa7d6e7fb2f8e42d36db5de70f43c49005be2c54474e09bcf53b51cc5cd72d70d929c32559976cd6f6dbc51680d6
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fortenet.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Iwo Dziechciarow
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,77 @@
1
+ # Fortenet
2
+
3
+ Simple Ruby wrapper for Forte Payments REST API
4
+
5
+ Learn about the Forte Payments REST API at https://www.forte.net/devdocs/api_resources/forte_api_v3.htm
6
+
7
+ ### Installation
8
+ Add this line to your application's Gemfile:
9
+ ```ruby
10
+ # in your Gemfile
11
+ gem 'fortenet', '3.0.1', git: 'https://github.com/iiwo/fortenet'
12
+
13
+ # then...
14
+ bundle install
15
+ ```
16
+
17
+ ### Usage
18
+ Create an initializer
19
+ ```ruby
20
+ # config/initializers/fortenet.rb
21
+ Fortenet.configure do |config|
22
+ # required configuration
23
+ config.endpoint = ENV['FORTE_ENDPOINT']
24
+ config.api_login_id = ENV['FORTE_API_LOGIN_ID']
25
+ config.secure_transaction_key = ENV['FORTE_SECURE_TRANSACTION_KEY']
26
+ # use the ID values without the prefixes ie. 123456 and not org_123456
27
+ config.account_id = ENV['FORTE_ACCOUNT_ID'] # this is also called organization ID
28
+ config.location_id = ENV['FORTE_LOCATION_ID']
29
+
30
+ # optionally configure debug
31
+ config.debug = Rails.env.development?
32
+ config.debug_output = $stdout
33
+
34
+ # optionally configure proxy
35
+ config.proxy_host = ENV['FORTE_PROXY_HOST']
36
+ config.proxy_port = ENV['FORTE_PROXY_PORT']
37
+ config.proxy_user =ENV['FORTE_PROXY_USER']
38
+ config.proxy_password = ENV['FORTE_PROXY_PASSWORD']
39
+ end
40
+ ```
41
+
42
+ Perform a request
43
+ ```ruby
44
+ client = Fortenet::Client.new
45
+
46
+ # sample GET request
47
+ client.find('/customers/CUSTOMER_TOKEN')
48
+
49
+ # sample POST request
50
+ request = {
51
+ action: 'force',
52
+ authorization_amount: 240.52,
53
+ billing_address: {
54
+ first_name: 'Test',
55
+ last_name: 'Force'
56
+ },
57
+ echeck: {
58
+ sec_code: 'WEB',
59
+ account_type: 'Checking',
60
+ routing_number: '021000021',
61
+ account_number: '00044422',
62
+ account_holder: 'Marty McFly'
63
+ }
64
+ }
65
+ client.create('transactions', request)
66
+
67
+ # sample PUT request
68
+ client.update('transactions', request)
69
+ ```
70
+
71
+ ## Contributing
72
+
73
+ 1. Fork it ( https://github.com/[my-github-username]/fortenet/fork )
74
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
75
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
76
+ 4. Push to the branch (`git push origin my-new-feature`)
77
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fortenet/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fortenet"
8
+ spec.version = Fortenet::VERSION
9
+ spec.authors = ["Iwo Dziechciarow"]
10
+ spec.email = ["iiwo@o2.pl"]
11
+ spec.summary = %q{Simple wrapper for Forte.net REST API}
12
+ spec.description = %q{Simple wrapper for Forte.net REST API (work in progress) }
13
+ spec.homepage = "https://github.com/ArcadiaPower/fortenet"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency 'httparty', '~> 0.13'
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "rake", '~> 12.0'
25
+ end
@@ -0,0 +1,37 @@
1
+ require 'httparty'
2
+ require 'fortenet/version'
3
+
4
+ module Fortenet
5
+ mattr_accessor :api_login_id, :secure_transaction_key, :account_id, :location_id, :proxy_host, :proxy_user, :proxy_password
6
+
7
+ mattr_accessor :endpoint
8
+ @@endpoint = 'https://sandbox.forte.net/api/v3'
9
+
10
+ mattr_accessor :debug
11
+ @@debug = true
12
+
13
+ def self.debug=(flag)
14
+ @@debug = flag
15
+ Fortenet::Request.default_options.delete(:debug_output) unless flag
16
+ end
17
+
18
+ def self.debug_output=(output)
19
+ return unless debug
20
+ Fortenet::Request.debug_output(output)
21
+ end
22
+
23
+ mattr_accessor :proxy_port
24
+ @@proxy_port = 80
25
+
26
+ def self.configure
27
+ yield self
28
+ end
29
+
30
+ end
31
+
32
+ require 'fortenet/request'
33
+ require 'fortenet/client'
34
+
35
+
36
+ # default starting point
37
+ Fortenet.debug_output = $stdout
@@ -0,0 +1,36 @@
1
+ module Fortenet
2
+ class Client < Fortenet::Request
3
+
4
+ def initialize(account_id = Fortenet.account_id, location_id = Fortenet.location_id, attrs = {})
5
+ @location_id = location_id
6
+ @account_id = account_id
7
+ end
8
+
9
+ def base_path
10
+ "/organizations/org_#{@account_id}/locations/loc_#{@location_id}/"
11
+ end
12
+
13
+ def find(relative_path, data = nil)
14
+ self.get(base_path+relative_path, query: data)
15
+ end
16
+
17
+ def create(relative_path, data = nil)
18
+ self.post(base_path+relative_path, body: data_to_json(data))
19
+ end
20
+
21
+ def update(relative_path, data = nil)
22
+ self.put(base_path+relative_path, body: data_to_json(data))
23
+ end
24
+
25
+ def destroy(relative_path)
26
+ self.delete(base_path+relative_path)
27
+ end
28
+
29
+ private
30
+
31
+ def data_to_json(data)
32
+ data.is_a?(Hash) ? data.to_json : data
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,56 @@
1
+ require 'httparty'
2
+ require 'json'
3
+
4
+ module Fortenet
5
+ class Request
6
+ include HTTParty
7
+ format :json
8
+ headers 'Accept' => 'application/json'
9
+
10
+ def get(path, options={})
11
+ set_auth(options)
12
+ @response = self.class.get(Fortenet.endpoint + path, options)
13
+ end
14
+
15
+ def post(path, options={})
16
+ set_auth(options)
17
+ @response = self.class.post(Fortenet.endpoint + path, options)
18
+ end
19
+
20
+ def put(path, options={})
21
+ set_auth(options)
22
+ @response = self.class.put(Fortenet.endpoint + path, options)
23
+ end
24
+
25
+ def delete(path, options={})
26
+ set_auth(options)
27
+ @response = self.class.delete(Fortenet.endpoint + path, options)
28
+ end
29
+
30
+ def response
31
+ @response
32
+ end
33
+
34
+ def parsed_response
35
+ self.response.parsed_response if self.response.present?
36
+ end
37
+
38
+ private
39
+
40
+ def set_auth(options)
41
+ client_id_and_secret = Base64.strict_encode64("#{Fortenet.api_login_id}:#{Fortenet.secure_transaction_key}")
42
+ #options[:ssl_version] = :TLSv1
43
+ options[:headers] ||= {}
44
+ options[:headers]['X-Forte-Auth-Organization-Id'] = "org_#{Fortenet.account_id}"
45
+ options[:headers]["Content-Type"] = "application/json"
46
+ options[:headers]['Authorization'] = "Basic #{client_id_and_secret}"
47
+
48
+ options[:http_proxyaddr] = Fortenet.proxy_host if Fortenet.proxy_host.present?
49
+ options[:http_proxyport] = Fortenet.proxy_port if Fortenet.proxy_port.present?
50
+ options[:http_proxyuser] = Fortenet.proxy_user if Fortenet.proxy_user.present?
51
+ options[:http_proxypass] = Fortenet.proxy_password if Fortenet.proxy_user.present?
52
+ end
53
+
54
+ end
55
+
56
+ end
@@ -0,0 +1,3 @@
1
+ module Fortenet
2
+ VERSION = "3.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fortenet
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Iwo Dziechciarow
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.13'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '12.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '12.0'
55
+ description: 'Simple wrapper for Forte.net REST API (work in progress) '
56
+ email:
57
+ - iiwo@o2.pl
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - fortenet.gemspec
68
+ - lib/fortenet.rb
69
+ - lib/fortenet/client.rb
70
+ - lib/fortenet/request.rb
71
+ - lib/fortenet/version.rb
72
+ homepage: https://github.com/ArcadiaPower/fortenet
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.5.1
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Simple wrapper for Forte.net REST API
96
+ test_files: []