samurai 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/README.md +9 -0
- data/Rakefile +2 -0
- data/lib/samurai/base.rb +9 -0
- data/lib/samurai/gateway.rb +26 -0
- data/lib/samurai/payment_method.rb +22 -0
- data/lib/samurai/transaction.rb +23 -0
- data/lib/samurai/version.rb +3 -0
- data/lib/samurai.rb +36 -0
- data/samurai.gemspec +22 -0
- metadata +97 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
data/lib/samurai/base.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
class Samurai::Gateway < Samurai::Base
|
2
|
+
|
3
|
+
def self.the_gateway
|
4
|
+
Ubergateway::Gateway.new(:id => Samurai.gateway_token)
|
5
|
+
end
|
6
|
+
|
7
|
+
def purchase(payment_method_token, amount)
|
8
|
+
# send a purchase request
|
9
|
+
resp = post(:purchase,
|
10
|
+
:transaction => {
|
11
|
+
:amount => amount,
|
12
|
+
:type => 'purchase',
|
13
|
+
:payment_method_token => payment_method_token,
|
14
|
+
:currency_code => 'USD'
|
15
|
+
}
|
16
|
+
)
|
17
|
+
# return the response, wrapped in a Samurai::Transaction
|
18
|
+
Samurai::Transaction.new.load_attributes_from_response(resp)
|
19
|
+
end
|
20
|
+
|
21
|
+
# TODO implement this functionality
|
22
|
+
# def authorize
|
23
|
+
# post(:authorize)
|
24
|
+
# end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class Samurai::PaymentMethod < Samurai::Base
|
2
|
+
|
3
|
+
def id
|
4
|
+
self.token
|
5
|
+
end
|
6
|
+
|
7
|
+
def token
|
8
|
+
self.payment_method_token
|
9
|
+
end
|
10
|
+
|
11
|
+
def retain
|
12
|
+
self.post(:retain)
|
13
|
+
end
|
14
|
+
|
15
|
+
def redact
|
16
|
+
self.post(:redact)
|
17
|
+
end
|
18
|
+
|
19
|
+
def custom_data
|
20
|
+
@custom_data ||= self.custom && (JSON.parse(self.custom) rescue {}).symbolize_keys
|
21
|
+
end
|
22
|
+
end
|
data/lib/samurai.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
module Samurai
|
2
|
+
|
3
|
+
mattr_accessor :site
|
4
|
+
@@site = case Rails.env
|
5
|
+
when 'development'
|
6
|
+
'http://localhost:3002'
|
7
|
+
when 'staging'
|
8
|
+
'http://staging.api.ubergateway.com'
|
9
|
+
else
|
10
|
+
'http://api.ubergateway.com'
|
11
|
+
end << '/v1/'
|
12
|
+
|
13
|
+
mattr_accessor :merchant_key
|
14
|
+
@@merchant_key = nil
|
15
|
+
|
16
|
+
mattr_accessor :merchant_password
|
17
|
+
@@merchant_password = nil
|
18
|
+
|
19
|
+
mattr_accessor :gateway_token
|
20
|
+
@@gateway_token = nil
|
21
|
+
|
22
|
+
def self.setup_site(site, merchant_key, merchant_password, gateway_token = nil)
|
23
|
+
site += '/v1/' unless site =~ /\/v1\/$/
|
24
|
+
@@site = site
|
25
|
+
@@merchant_key = merchant_key
|
26
|
+
@@merchant_password = merchant_password
|
27
|
+
@@gateway_token = gateway_token if gateway_token
|
28
|
+
Samurai::Base.setup_site!
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
require 'samurai/base'
|
34
|
+
require 'samurai/gateway'
|
35
|
+
require 'samurai/payment_method'
|
36
|
+
require 'samurai/transaction'
|
data/samurai.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path("../lib/samurai/version", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "samurai"
|
6
|
+
s.version = Samurai::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Graeme Rouse", "Derek Zak"]
|
9
|
+
s.email = ["graeme@ubergateway.com", "derek@ubergateway.com"]
|
10
|
+
s.homepage = "http://rubygems.org/gems/samurai"
|
11
|
+
s.summary = "Integration gem for samurai.feefighters.com"
|
12
|
+
s.description = "If you are an online merchant and using samurai.feefighers.com, this gem will make your life easy. Integrate with the samuari.feefighters.com portal and process transaction."
|
13
|
+
|
14
|
+
s.required_rubygems_version = ">= 1.3.6"
|
15
|
+
s.rubyforge_project = "samurai"
|
16
|
+
|
17
|
+
s.add_development_dependency "bundler", ">= 1.0.0"
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
21
|
+
s.require_path = 'lib'
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: samurai
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Graeme Rouse
|
14
|
+
- Derek Zak
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2011-07-13 00:00:00 -07:00
|
20
|
+
default_executable:
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: bundler
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 23
|
31
|
+
segments:
|
32
|
+
- 1
|
33
|
+
- 0
|
34
|
+
- 0
|
35
|
+
version: 1.0.0
|
36
|
+
type: :development
|
37
|
+
version_requirements: *id001
|
38
|
+
description: If you are an online merchant and using samurai.feefighers.com, this gem will make your life easy. Integrate with the samuari.feefighters.com portal and process transaction.
|
39
|
+
email:
|
40
|
+
- graeme@ubergateway.com
|
41
|
+
- derek@ubergateway.com
|
42
|
+
executables: []
|
43
|
+
|
44
|
+
extensions: []
|
45
|
+
|
46
|
+
extra_rdoc_files: []
|
47
|
+
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/samurai.rb
|
54
|
+
- lib/samurai/base.rb
|
55
|
+
- lib/samurai/gateway.rb
|
56
|
+
- lib/samurai/payment_method.rb
|
57
|
+
- lib/samurai/transaction.rb
|
58
|
+
- lib/samurai/version.rb
|
59
|
+
- samurai.gemspec
|
60
|
+
has_rdoc: true
|
61
|
+
homepage: http://rubygems.org/gems/samurai
|
62
|
+
licenses: []
|
63
|
+
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 3
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
hash: 23
|
84
|
+
segments:
|
85
|
+
- 1
|
86
|
+
- 3
|
87
|
+
- 6
|
88
|
+
version: 1.3.6
|
89
|
+
requirements: []
|
90
|
+
|
91
|
+
rubyforge_project: samurai
|
92
|
+
rubygems_version: 1.3.7
|
93
|
+
signing_key:
|
94
|
+
specification_version: 3
|
95
|
+
summary: Integration gem for samurai.feefighters.com
|
96
|
+
test_files: []
|
97
|
+
|