sagepayadminapi 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +39 -0
- data/Rakefile +12 -0
- data/lib/sagepayadminapi/version.rb +3 -0
- data/lib/sagepayadminapi.rb +45 -0
- data/sagepayadminapi.gemspec +18 -0
- data/test/test_helper.rb +3 -0
- metadata +71 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Colin Burn-Murdoch
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# SagePay Admin & Reporting API for Ruby
|
2
|
+
|
3
|
+
This is a port of [the PHP version](https://github.com/colinbm/sagepay-php). Mainly written to play with making a gem.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'sagepayadminapi'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install sagepayadminapi
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
You can use any command specified in the [Reporting and Admin API documentation](https://www.sagepay.com/sites/default/files/pdf/brochures/ReportingAndAdminAPIProtocol_1_02_0.pdf) as a method.
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
adminapi = SagePayAdminAPI.new('vendor', 'username', 'password')
|
25
|
+
transaction = adminapi.getTransactionDetail(vendortxcode: '12345678')
|
26
|
+
puts "Third Man Status: #{transaction['t3maction']} (#{transaction['t3mscore']})"
|
27
|
+
```
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create new Pull Request
|
36
|
+
|
37
|
+
## Todo
|
38
|
+
|
39
|
+
- Tests
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
|
4
|
+
require 'rake/testtask'
|
5
|
+
|
6
|
+
Rake::TestTask.new do |t|
|
7
|
+
t.libs << 'lib/sagepayadminapi'
|
8
|
+
t.test_files = FileList['test/lib/sagepayadminapi/*_test.rb']
|
9
|
+
t.verbose = true
|
10
|
+
end
|
11
|
+
|
12
|
+
task :default => :test
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative "./sagepayadminapi/version"
|
2
|
+
|
3
|
+
class SagePayAdminAPI
|
4
|
+
|
5
|
+
VERSION = '0.0.1'
|
6
|
+
|
7
|
+
def initialize(vendor, username, password, live=true, sslverify=true)
|
8
|
+
@vendor = vendor
|
9
|
+
@username = username
|
10
|
+
@password = password
|
11
|
+
@url = "https://#{ live ? 'live' : 'test' }.sagepay.com/access/access.htm"
|
12
|
+
@sslverify = sslverify
|
13
|
+
end
|
14
|
+
|
15
|
+
def method_missing(method_id, *arguments)
|
16
|
+
|
17
|
+
uri = URI.parse(@url)
|
18
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
19
|
+
http.use_ssl = true
|
20
|
+
if @sslverify == false
|
21
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
22
|
+
end
|
23
|
+
|
24
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
25
|
+
request.body = 'XML=' + to_xml(method_id, arguments[0])
|
26
|
+
|
27
|
+
response = http.request(request)
|
28
|
+
|
29
|
+
XmlSimple.xml_in(response.body, { ForceArray: false })
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def to_xml(command, elements={})
|
36
|
+
xml = "<command>#{command}</command><vendor>#{@vendor}</vendor><user>#{@username}</user>"
|
37
|
+
elements.each do |key, value|
|
38
|
+
xml += "<#{key}>#{value}</#{key}>"
|
39
|
+
end
|
40
|
+
signature = Digest::MD5.hexdigest(xml + "<password>#{@password}</password>")
|
41
|
+
xml += "<signature>#{signature}</signature>"
|
42
|
+
"<vspaccess>#{xml}</vspaccess>"
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/sagepayadminapi', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Colin Burn-Murdoch"]
|
6
|
+
gem.email = ["colin@burn-murdoch.com"]
|
7
|
+
gem.description = "Ruby interface to the SagePay Admin & Rporting API"
|
8
|
+
gem.summary = "SagePay Admin & Reporting API"
|
9
|
+
gem.homepage = "http://github.com/colinbm/sagepayadminapi-ruby"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "sagepayadminapi"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = SagePayAdminAPI::VERSION
|
17
|
+
gem.add_dependency 'xml-simple'
|
18
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sagepayadminapi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Colin Burn-Murdoch
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: xml-simple
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: Ruby interface to the SagePay Admin & Rporting API
|
31
|
+
email:
|
32
|
+
- colin@burn-murdoch.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- lib/sagepayadminapi.rb
|
43
|
+
- lib/sagepayadminapi/version.rb
|
44
|
+
- sagepayadminapi.gemspec
|
45
|
+
- test/test_helper.rb
|
46
|
+
homepage: http://github.com/colinbm/sagepayadminapi-ruby
|
47
|
+
licenses: []
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.8.23
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: SagePay Admin & Reporting API
|
70
|
+
test_files:
|
71
|
+
- test/test_helper.rb
|