agms 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/README.md +51 -0
- data/Rakefile +40 -0
- data/agms.gemspec +29 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/example/hpp.rb +18 -0
- data/example/invoicing.rb +23 -0
- data/example/recurring.rb +23 -0
- data/example/report.rb +16 -0
- data/example/safe.rb +17 -0
- data/example/transaction.rb +17 -0
- data/init.yml +9 -0
- data/lib/agms.rb +59 -0
- data/lib/agms/agms.rb +109 -0
- data/lib/agms/configuration.rb +71 -0
- data/lib/agms/connect.rb +176 -0
- data/lib/agms/error/agms_error.rb +9 -0
- data/lib/agms/error/authentication_error.rb +7 -0
- data/lib/agms/error/authorization_error.rb +7 -0
- data/lib/agms/error/client_error_error.rb +7 -0
- data/lib/agms/error/configuation_error.rb +7 -0
- data/lib/agms/error/down_for_maintenance_error.rb +7 -0
- data/lib/agms/error/forged_query_String_error.rb +7 -0
- data/lib/agms/error/invalid_parameter_error.rb +7 -0
- data/lib/agms/error/invalid_request_error.rb +7 -0
- data/lib/agms/error/invalid_signature_error.rb +7 -0
- data/lib/agms/error/not_found_error.rb +7 -0
- data/lib/agms/error/request_validation_error.rb +7 -0
- data/lib/agms/error/response_error.rb +7 -0
- data/lib/agms/error/server_error_error.rb +7 -0
- data/lib/agms/error/ssl_certificate_error.rb +7 -0
- data/lib/agms/error/unexpected_error.rb +7 -0
- data/lib/agms/error/upgrade_required_error.rb +7 -0
- data/lib/agms/hpp.rb +65 -0
- data/lib/agms/invoicing.rb +63 -0
- data/lib/agms/recurring.rb +76 -0
- data/lib/agms/report.rb +53 -0
- data/lib/agms/request/hpp_request.rb +181 -0
- data/lib/agms/request/invoicing_request.rb +8 -0
- data/lib/agms/request/recurring_request.rb +115 -0
- data/lib/agms/request/report_request.rb +106 -0
- data/lib/agms/request/request.rb +455 -0
- data/lib/agms/request/safe_request.rb +211 -0
- data/lib/agms/request/transaction_request.rb +217 -0
- data/lib/agms/response/hpp_response.rb +39 -0
- data/lib/agms/response/invoicing_response.rb +10 -0
- data/lib/agms/response/recurring_response.rb +28 -0
- data/lib/agms/response/report_response.rb +141 -0
- data/lib/agms/response/response.rb +48 -0
- data/lib/agms/response/safe_response.rb +51 -0
- data/lib/agms/response/transaction_response.rb +50 -0
- data/lib/agms/safe.rb +66 -0
- data/lib/agms/transaction.rb +37 -0
- data/lib/agms/version.rb +3 -0
- metadata +156 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OWVjNDJjMTM0YWJjYWFmNjQ2NTNkMWI0YzlkNjVlNjVhNDQ5NDM4MQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NjI3NmNlZTU2MzkyMWNiYmQ4YzM5ZDc4MDJiNDcxZDJlMzk4NWIxMA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZWY1MTVhZDFkYjZkNmE2MjI2OTRmYTY5Y2ZlMzlmNDQyMmU0MGE3Y2M3NzYx
|
10
|
+
NDFiNGM4MTQ4NGIyYjU2YzRkNjc3M2NiNzZlNGE1ZjNmZjUxMjM2ODNhNzll
|
11
|
+
NzQwYjJiNGZhY2E2YTFjZDg4NzhjZmU5ZjlhMTEyNTRhZWRiMDE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NjVlMjlhODE2ZDQwOWRiZDhkMDA4N2IyMTIyZmNhYjNhZmMwZTc3NDAzOWIw
|
14
|
+
MmUwZGIyZDc4ZDhiYTg1MzJmYzQ0ZGQxZDViYzRhMWExNGU4YzcyNGEwZmIz
|
15
|
+
YWM4YTdiNDUyYTRiZmU0MWZmMWU3ZDMyNGY3NzYxMGMxMWJlOTY=
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# AgmsRuby Library
|
2
|
+
|
3
|
+
The AGMS Ruby library provides integration to the Avant-Garde Gateway.
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'agms'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install agms
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Take a look at example code in the example folder
|
25
|
+
|
26
|
+
|
27
|
+
## Release Notes
|
28
|
+
|
29
|
+
Support for Invoicing and Recurring are not yet completed.
|
30
|
+
|
31
|
+
|
32
|
+
## Documentation
|
33
|
+
|
34
|
+
* [Official documentation](https://www.onlinepaymentprocessing.com/docs/ruby)
|
35
|
+
* [Bug Tracker](http://github.com/agms/agms_ruby/issues)
|
36
|
+
|
37
|
+
Examples can be found as part of this package in example /hpp.rb, example/invoicing.rb, example/recurring.rb, example_report.py, example/safe.rb, example/transaction.rb.
|
38
|
+
|
39
|
+
|
40
|
+
## License
|
41
|
+
|
42
|
+
See the LICENSE file.
|
43
|
+
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork it ( https://github.com/agms_code/agms_ruby/fork )
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
$:.unshift File.expand_path('../lib', __FILE__)
|
2
|
+
require 'agms/version'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'bundler'
|
6
|
+
Bundler.setup
|
7
|
+
rescue LoadError => e
|
8
|
+
puts "Error loading bundler (#{e.message}): \"gem install bundler\" for bundler support."
|
9
|
+
require 'rubygems'
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'rake'
|
13
|
+
require 'rake/testtask'
|
14
|
+
require 'bundler/gem_tasks'
|
15
|
+
|
16
|
+
task :tag_release do
|
17
|
+
system "git tag 'v#{Agms::VERSION}'"
|
18
|
+
system "git push --tags"
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Run the unit test suite"
|
22
|
+
task :default => 'test:units'
|
23
|
+
task :test => 'test:units'
|
24
|
+
|
25
|
+
namespace :test do
|
26
|
+
Rake::TestTask.new(:units) do |t|
|
27
|
+
t.pattern = 'test/unit/**/*_test.rb'
|
28
|
+
t.ruby_opts << '-rubygems -w'
|
29
|
+
t.libs << 'test'
|
30
|
+
t.verbose = true
|
31
|
+
end
|
32
|
+
|
33
|
+
Rake::TestTask.new(:remote) do |t|
|
34
|
+
t.pattern = 'test/remote/**/*_test.rb'
|
35
|
+
t.ruby_opts << '-rubygems -w'
|
36
|
+
t.libs << 'test'
|
37
|
+
t.verbose = true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
data/agms.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'agms/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "agms"
|
8
|
+
spec.version = Agms::VERSION
|
9
|
+
spec.authors = ["Maanas Royy"]
|
10
|
+
spec.email = ["maanas@agms.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{AGMS Ruby Client Library}
|
13
|
+
spec.description = %q{Ruby Library for integrating AGMS Gateway}
|
14
|
+
spec.homepage = "http://www.onlinepaymentprocessing.com"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
if spec.respond_to?(:metadata)
|
22
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.add_development_dependency 'nokogiri', '~> 0'
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.8'
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
+
spec.add_development_dependency 'mocha', '~> 0'
|
29
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "agms_ruby"
|
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
|
data/bin/setup
ADDED
data/example/hpp.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require './lib/agms'
|
2
|
+
|
3
|
+
Agms::Configuration.init('init.yml')
|
4
|
+
|
5
|
+
hpp = Agms::HPP.new
|
6
|
+
|
7
|
+
params = {
|
8
|
+
:transaction_type => { :value => 'sale'},
|
9
|
+
:amount => { :value => '20.00'},
|
10
|
+
:first_name => { :setting => 'required'},
|
11
|
+
:last_name => { :setting => 'required'},
|
12
|
+
:zip => { :setting => 'required'},
|
13
|
+
:email => { :setting => 'required'},
|
14
|
+
:hpp_format => { :value => '1'}
|
15
|
+
}
|
16
|
+
|
17
|
+
result = hpp.generate(params)
|
18
|
+
print result
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require './lib/agms'
|
2
|
+
|
3
|
+
Agms::Configuration.init('init.yml')
|
4
|
+
Agms::Configuration.verbose = true
|
5
|
+
recur = Agms::Invoicing.new
|
6
|
+
|
7
|
+
params = {
|
8
|
+
:invoice_number => {:value => '12'},
|
9
|
+
:invoice_date => { :value => '2014-11-20'},
|
10
|
+
:bill_to_first_name => {:value => '0520'},
|
11
|
+
:cc_cvv => {:value => '123'},
|
12
|
+
:first_name => {:value => 'Test'},
|
13
|
+
:last_name => {:value => 'Recurring'},
|
14
|
+
:start_date => {:value => '2014-11-09'},
|
15
|
+
:end_date => {:value => '2018-11-09'},
|
16
|
+
:frequency => {:value => 'months'},
|
17
|
+
:number_of_retries => {:value => '2'},
|
18
|
+
:email => {:value => 'maanas@agms.com'}
|
19
|
+
}
|
20
|
+
|
21
|
+
result = recur.add(params)
|
22
|
+
|
23
|
+
print result
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require './lib/agms'
|
2
|
+
|
3
|
+
Agms::Configuration.init('init.yml')
|
4
|
+
Agms::Configuration.verbose = true
|
5
|
+
recur = Agms::Recurring.new
|
6
|
+
|
7
|
+
params = {
|
8
|
+
:recurring_amount => {:value => '20.00'},
|
9
|
+
:cc_number => { :value => '4111111111111111'},
|
10
|
+
:cc_exp_date => {:value => '0520'},
|
11
|
+
:cc_cvv => {:valuRe => '123'},
|
12
|
+
:first_name => {:value => 'Test'},
|
13
|
+
:last_name => {:value => 'Recurring'},
|
14
|
+
:start_date => {:value => '2014-11-09'},
|
15
|
+
:end_date => {:value => '2018-11-09'},
|
16
|
+
:frequency => {:value => 'months'},
|
17
|
+
:number_of_retries => {:value => '2'},
|
18
|
+
:email => {:value => 'maanas@agms.com'}
|
19
|
+
}
|
20
|
+
|
21
|
+
result = recur.add(params)
|
22
|
+
|
23
|
+
print result
|
data/example/report.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require './lib/agms'
|
2
|
+
|
3
|
+
Agms::Configuration.init('init.yml')
|
4
|
+
|
5
|
+
rep = Agms::Report.new
|
6
|
+
|
7
|
+
params = {
|
8
|
+
:start_date => { :value => '2015-01-01'},
|
9
|
+
:end_date => { :value => '2015-03-28'}
|
10
|
+
}
|
11
|
+
|
12
|
+
result = rep.listTransactions(params)
|
13
|
+
print result
|
14
|
+
|
15
|
+
result = rep.listSAFEs(params)
|
16
|
+
print result
|
data/example/safe.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require './lib/agms'
|
2
|
+
|
3
|
+
Agms::Configuration.init('init.yml')
|
4
|
+
|
5
|
+
safe = Agms::SAFE.new
|
6
|
+
|
7
|
+
params = {
|
8
|
+
:payment_type => { :value => 'creditcard'},
|
9
|
+
:first_name => { :value => 'Joe'},
|
10
|
+
:last_name => { :value => 'Smith'},
|
11
|
+
:cc_number => { :value => '4111111111111111'},
|
12
|
+
:cc_exp_date => { :value => '0500'},
|
13
|
+
:cc_cvv => { :value => '123'}
|
14
|
+
}
|
15
|
+
|
16
|
+
safe_result = safe.add(params)
|
17
|
+
print safe_result
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require './lib/agms'
|
2
|
+
|
3
|
+
Agms::Configuration.init('init.yml')
|
4
|
+
|
5
|
+
trans = Agms::Transaction.new
|
6
|
+
|
7
|
+
params = {
|
8
|
+
:transaction_type => { :value => 'sale'},
|
9
|
+
:amount => { :value => '100.00'},
|
10
|
+
:cc_number => { :value => '4111111111111111'},
|
11
|
+
:cc_exp_date => { :value => '0520'},
|
12
|
+
:cc_cvv => { :value => '123'}
|
13
|
+
}
|
14
|
+
|
15
|
+
result = trans.process(params)
|
16
|
+
|
17
|
+
print result
|
data/init.yml
ADDED
data/lib/agms.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Add current directory in library load path
|
2
|
+
$:.unshift(File.expand_path(File.dirname(__FILE__))) unless
|
3
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
4
|
+
|
5
|
+
require 'net/http'
|
6
|
+
require 'net/https'
|
7
|
+
require 'openssl'
|
8
|
+
|
9
|
+
require 'nokogiri'
|
10
|
+
|
11
|
+
|
12
|
+
require 'agms/version'
|
13
|
+
|
14
|
+
require 'agms/configuration'
|
15
|
+
require 'agms/agms'
|
16
|
+
|
17
|
+
require 'agms/transaction'
|
18
|
+
require 'agms/safe'
|
19
|
+
require 'agms/report'
|
20
|
+
require 'agms/recurring'
|
21
|
+
require 'agms/invoicing'
|
22
|
+
require 'agms/hpp'
|
23
|
+
|
24
|
+
require 'agms/error/agms_error'
|
25
|
+
require 'agms/error/authentication_error'
|
26
|
+
require 'agms/error/authorization_error'
|
27
|
+
require 'agms/error/client_error_error'
|
28
|
+
require 'agms/error/configuation_error'
|
29
|
+
require 'agms/error/down_for_maintenance_error'
|
30
|
+
require 'agms/error/forged_query_String_error'
|
31
|
+
require 'agms/error/invalid_parameter_error'
|
32
|
+
require 'agms/error/invalid_request_error'
|
33
|
+
require 'agms/error/invalid_signature_error'
|
34
|
+
require 'agms/error/not_found_error'
|
35
|
+
require 'agms/error/request_validation_error'
|
36
|
+
require 'agms/error/response_error'
|
37
|
+
require 'agms/error/server_error_error'
|
38
|
+
require 'agms/error/ssl_certificate_error'
|
39
|
+
require 'agms/error/unexpected_error'
|
40
|
+
require 'agms/error/upgrade_required_error'
|
41
|
+
|
42
|
+
require 'agms/request/request'
|
43
|
+
require 'agms/request/transaction_request'
|
44
|
+
require 'agms/request/safe_request'
|
45
|
+
require 'agms/request/report_request'
|
46
|
+
require 'agms/request/recurring_request'
|
47
|
+
require 'agms/request/invoicing_request'
|
48
|
+
require 'agms/request/hpp_request'
|
49
|
+
|
50
|
+
require 'agms/response/response'
|
51
|
+
require 'agms/response/transaction_response'
|
52
|
+
require 'agms/response/safe_response'
|
53
|
+
require 'agms/response/report_response'
|
54
|
+
require 'agms/response/recurring_response'
|
55
|
+
require 'agms/response/invoicing_response'
|
56
|
+
require 'agms/response/hpp_response'
|
57
|
+
|
58
|
+
require 'agms/connect'
|
59
|
+
|
data/lib/agms/agms.rb
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
module Agms
|
2
|
+
|
3
|
+
class Agms
|
4
|
+
# A class representing base AGMS objects.
|
5
|
+
|
6
|
+
# Version data
|
7
|
+
MAJOR = 0
|
8
|
+
MINOR = 2
|
9
|
+
TINY = 1
|
10
|
+
|
11
|
+
API = 3
|
12
|
+
|
13
|
+
def self.getLibraryVersion()
|
14
|
+
return Agms::MAJOR.to_s + '.' + Agms::MINOR.to_s + '.' + Agms::TINY.to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.getAPIVersion()
|
18
|
+
return Agms::API.to_s
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.whatCardType(truncated, card_format='name')
|
22
|
+
card_abb = {
|
23
|
+
'3' => 'AX',
|
24
|
+
'4' => 'VX',
|
25
|
+
'5' => 'MC',
|
26
|
+
'6' => 'DS',
|
27
|
+
}
|
28
|
+
|
29
|
+
card_name = {
|
30
|
+
'3' => 'American Express',
|
31
|
+
'4' => 'Visa',
|
32
|
+
'5' => 'Mastercard',
|
33
|
+
'6' => 'Discover',
|
34
|
+
}
|
35
|
+
|
36
|
+
first_digit = truncated[0]
|
37
|
+
|
38
|
+
if card_format == 'abbreviation'
|
39
|
+
begin
|
40
|
+
return card_abb[first_digit]
|
41
|
+
rescue
|
42
|
+
return 'Unknown'
|
43
|
+
end
|
44
|
+
else
|
45
|
+
begin
|
46
|
+
return card_name[first_digit]
|
47
|
+
rescue
|
48
|
+
return 'Unknown'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
def initialize(username=nil, password=nil, account=nil, api_key=nil)
|
55
|
+
if username and password
|
56
|
+
@username = username
|
57
|
+
@password = password
|
58
|
+
@account = account
|
59
|
+
@api_key = api_key
|
60
|
+
else
|
61
|
+
@username = Configuration.gateway_username
|
62
|
+
@password = Configuration.gateway_password
|
63
|
+
@account = Configuration.gateway_account
|
64
|
+
@api_key = Configuration.gateway_api_key
|
65
|
+
end
|
66
|
+
@op = nil
|
67
|
+
@api_url = nil
|
68
|
+
@request = nil
|
69
|
+
@response = nil
|
70
|
+
end
|
71
|
+
|
72
|
+
def doConnect(request_method, response_object)
|
73
|
+
# Get requestObject class name
|
74
|
+
requestClass = Object.const_get('Agms').const_get(@requestObject)
|
75
|
+
if @request.instance_of?(requestClass.class)
|
76
|
+
raise RequestValidationError('No request has been created, please define request parameters.')
|
77
|
+
else
|
78
|
+
connect = Connect.new(Configuration.instantiate())
|
79
|
+
request_body = @request.get(@username, @password, @account, @api_key)
|
80
|
+
request_body = @request.getParams(request_body)
|
81
|
+
response = connect.connect(@api_url, request_body, request_method, response_object)
|
82
|
+
responseClass = Object.const_get('Agms').const_get(@responseObject)
|
83
|
+
@response = responseClass.new(response, @op)
|
84
|
+
return true
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def setParameter(field, opts)
|
89
|
+
if not @request
|
90
|
+
self.resetParameters()
|
91
|
+
end
|
92
|
+
if opts.class == Hash and opts.length > 0
|
93
|
+
opts.each do |param, value|
|
94
|
+
@request.setField(field, param, value)
|
95
|
+
end
|
96
|
+
return true
|
97
|
+
else
|
98
|
+
raise InvalidParameterError('Provided options are not in valid array format.')
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def resetParameters()
|
103
|
+
@request = nil
|
104
|
+
requestClass = Object.const_get('Agms').const_get(@requestObject)
|
105
|
+
@request = requestClass.new(@op)
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
end
|