securenet 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8cd39cd19f0b738c03066fb048051dc4c78b4ba1
4
+ data.tar.gz: e36c1e141ce7057d2f16efdadf43b8f8e146cf2a
5
+ SHA512:
6
+ metadata.gz: c3237c6a1b89225050bf6cdd9f379d37d3915f36fd3026c8e281c5b5b81540627f7e49802a039d2720de00c18b85b5f1666b1460a25d0ccd076012133e44f049
7
+ data.tar.gz: ed9a785a821060ae969977a5899b92097faf8182b612d3a5e975ca9b91e7dc6693131854d0119c2644dff3ca67a7331a17a5ecb26f992193ecd79d1fde548db7
@@ -0,0 +1,34 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
@@ -0,0 +1,29 @@
1
+ # Securenet
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'securenet'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install securenet
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/securenet/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
@@ -0,0 +1,203 @@
1
+ require "securenet/version"
2
+ require "rest_client"
3
+ require "json"
4
+
5
+ require "securenet/util"
6
+
7
+ module SecureNet
8
+
9
+ def self.init(id, key, url = "https://gwapi.demo.securenet.com/api")
10
+ @util = SecurenetUtil.new(id, key, url)
11
+ end
12
+
13
+ ################################################################################
14
+ # Batch Routines
15
+ ################################################################################
16
+
17
+ def self.getCurrentBatch
18
+ return @util.get("/batches/Current", nil)
19
+ end
20
+
21
+ def self.getBatch(batchid)
22
+ return @util.get("/batches/#{batchid}", nil)
23
+ end
24
+
25
+ def self.closeBatch
26
+ return @util.post("/batches/Close", nil)
27
+ end
28
+
29
+ ################################################################################
30
+ # Transaction Processing
31
+ ################################################################################
32
+
33
+ def self.authorize(data)
34
+ return @util.post("/Payments/Authorize", data)
35
+ end
36
+
37
+ def self.capture(data)
38
+ return @util.post("/Payments/Capture", data)
39
+ end
40
+
41
+ def self.charge(data)
42
+ return @util.post("/Payments/Charge", data)
43
+ end
44
+
45
+ ################################################################################
46
+ # Vault
47
+ ################################################################################
48
+
49
+ def self.createCustomer(data)
50
+ return @util.post("/Customers", data)
51
+ end
52
+
53
+ def self.getCustomer(data)
54
+ if data.class == Hash
55
+ if ! data.has_key?("customerId".to_sym)
56
+ return @util.error("customerId is required")
57
+ end
58
+ customerId = data[:customerId]
59
+ else
60
+ customerId = data
61
+ end
62
+ return @util.get("/Customers/#{customerId}", nil)
63
+ end
64
+
65
+ def self.updateCustomer(data)
66
+ if ! data.has_key?("customerId".to_sym)
67
+ return @util.error("customerId is required")
68
+ end
69
+ return @util.put("/Customers/#{data[:customerId]}", data)
70
+ end
71
+
72
+
73
+ def self.createCustomerPaymentMethod(data)
74
+ if ! data.has_key?("customerId".to_sym)
75
+ return @util.error("customerId is required")
76
+ end
77
+ return @util.post("/Customers/#{customerId}", data)
78
+ end
79
+
80
+ def self.getCustomerPaymentMethod(data)
81
+ if ! data.has_key?("customerId".to_sym)
82
+ return @util.error("customerId is required")
83
+ end
84
+ if ! data.has_key?("paymentMethodId".to_sym)
85
+ return @util.error("paymentMethodId is required")
86
+ end
87
+ return @util.get("/Customers/#{data[:customerId]}/PaymentMethod/#{data[:paymentMethodId]}", data)
88
+ end
89
+
90
+ def self.deleteCustomerPaymentMethod(data)
91
+ if ! data.has_key?("customerId".to_sym)
92
+ return @util.error("customerId is required")
93
+ end
94
+ if ! data.has_key?("paymentMethodId".to_sym)
95
+ return @util.error("paymentMethodId is required")
96
+ end
97
+ return @util.delete("/Customers/#{data[:customerId]}/PaymentMethod/#{data[:paymentMethodId]}", data)
98
+ end
99
+
100
+ ################################################################################
101
+ # Installment Plans
102
+ ################################################################################
103
+
104
+ def self.createInstallmentPlan(data)
105
+ if ! data.has_key?("customerId".to_sym)
106
+ return @util.error("customerId is required")
107
+ end
108
+ return @util.post("/Customers/#{customerId}/PaymentSchedules/Installment", data)
109
+ end
110
+
111
+ def self.createVariablePlan(data)
112
+ if ! data.has_key?("customerId".to_sym)
113
+ return @util.error("customerId is required")
114
+ end
115
+ return @util.post("/Customers/#{customerId}/PaymentSchedules/Variable", data)
116
+ end
117
+
118
+ def self.createRecurringPlan(data)
119
+ if ! data.has_key?("customerId".to_sym)
120
+ return @util.error("customerId is required")
121
+ end
122
+ return @util.post("/Customers/#{customerId}/PaymentSchedules/Recurring", data)
123
+ end
124
+
125
+ def self.getPlan(data)
126
+ if ! data.has_key?("customerId".to_sym)
127
+ return @util.error("customerId is required")
128
+ end
129
+ if ! data.has_key?("planId".to_sym)
130
+ return @util.error("planId is required")
131
+ end
132
+ return @util.get("/Customers/#{data[:customerId]}/PaymentSchedules/#{data[:planId]}", data)
133
+ end
134
+
135
+ def self.deletePlan(data)
136
+ if ! data.has_key?("customerId".to_sym)
137
+ return @util.error("customerId is required")
138
+ end
139
+ if ! data.has_key?("planId".to_sym)
140
+ return @util.error("planId is required")
141
+ end
142
+ return @util.delete("/Customers/#{data[:customerId]}/PaymentSchedules/#{data[:planId]}", data)
143
+ end
144
+
145
+ ################################################################################
146
+ ## Credits
147
+ ################################################################################
148
+
149
+ def self.credit(data)
150
+ return @util.post("/Payments/Credit", data)
151
+ end
152
+
153
+ ################################################################################
154
+ ## Refunds and Voids
155
+ ################################################################################
156
+
157
+ def self.refund(data)
158
+ if data.class == Hash
159
+ return @util.post("/Payments/Refund", data)
160
+ else
161
+ return @util.post("/Payments/Refund", { :transactionId => data })
162
+ end
163
+ end
164
+
165
+ def self.void(data)
166
+ if data.class == Hash
167
+ return @util.post("/Payments/Void", data)
168
+ else
169
+ return @util.post("/Payments/Void", { :transactionId => data })
170
+ end
171
+ end
172
+
173
+ ################################################################################
174
+ ## Transactions
175
+ ################################################################################
176
+
177
+ def self.getTransactions(data)
178
+ if data.class == Hash
179
+ return @util.post("/Transactions/Search", data)
180
+ else
181
+ return @util.get("/Transactions/#{data}", nil)
182
+ end
183
+ end
184
+
185
+ def self.getTransaction(data)
186
+ if data.class == Hash
187
+ if ! data.has_key?("transactionId".to_sym)
188
+ return @util.error("transactionId is required")
189
+ end
190
+ return @util.get("/Transactions/#{data[:transactionId]}", nil)
191
+ else
192
+ return @util.get("/Transactions/#{data}", nil)
193
+ end
194
+ end
195
+
196
+ def self.updateTransaction(data)
197
+ if ! data.has_key?("referenceTransactionId".to_sym)
198
+ return @util.error("referenceTransactionId is required")
199
+ end
200
+ return @util.put("/Transactions/#{data[:referenceTransactionId]}", data)
201
+ end
202
+
203
+ end
@@ -0,0 +1,72 @@
1
+ class SecurenetUtil
2
+
3
+ def initialize(id, key, url = "https://gwapi.demo.securenet.com/api")
4
+ @id = id
5
+ @key = key
6
+ @url = url
7
+ end
8
+
9
+ def get(path, content)
10
+ url = "#{@url}#{path}"
11
+ response = RestClient::Request.new(
12
+ :method => :get,
13
+ :url => url,
14
+ :user => @id,
15
+ :password => @key,
16
+ :headers => { :accept => :json, :content_type => :json }
17
+ ).execute
18
+ results = JSON.parse(response.to_str)
19
+ return results
20
+ end
21
+
22
+ def post(path, content)
23
+ url = "#{@url}#{path}"
24
+ response = RestClient::Request.new(
25
+ :method => :post,
26
+ :url => url,
27
+ :payload => content.to_json,
28
+ :user => @id,
29
+ :password => @key,
30
+ :headers => { :accept => :json, :content_type => :json }
31
+ ).execute
32
+ results = JSON.parse(response.to_str)
33
+ return results
34
+ end
35
+
36
+ def put(path, content)
37
+ url = "#{@url}#{path}"
38
+ response = RestClient::Request.new(
39
+ :method => :put,
40
+ :url => url,
41
+ :payload => content.to_json,
42
+ :user => @id,
43
+ :password => @key,
44
+ :headers => { :accept => :json, :content_type => :json }
45
+ ).execute
46
+ results = JSON.parse(response.to_str)
47
+ return results
48
+ end
49
+
50
+ def delete(path, content)
51
+ url = "#{@url}#{path}"
52
+ response = RestClient::Request.new(
53
+ :method => :delete,
54
+ :url => url,
55
+ :payload => content.to_json,
56
+ :user => @id,
57
+ :password => @key,
58
+ :headers => { :accept => :json, :content_type => :json }
59
+ ).execute
60
+ results = JSON.parse(response.to_str)
61
+ return results
62
+ end
63
+
64
+ def error(message)
65
+ return {
66
+ :message => message,
67
+ :success => false,
68
+ :result => "COMMUNICATION_ERROR"
69
+ }
70
+ end
71
+
72
+ end
@@ -0,0 +1,3 @@
1
+ module Securenet
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: securenet
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - rjstanford
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-24 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.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rest-client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: json
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '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'
69
+ description: A library to process ACH and credit card transactions through the SecureNet
70
+ gateway
71
+ email:
72
+ - richard@richardstanford.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - README.md
79
+ - lib/securenet.rb
80
+ - lib/securenet/util.rb
81
+ - lib/securenet/version.rb
82
+ homepage: ''
83
+ licenses:
84
+ - MIT
85
+ metadata: {}
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 2.3.0
103
+ signing_key:
104
+ specification_version: 4
105
+ summary: SecureNet Payments Gateway
106
+ test_files: []