an 0.0.1.rc5 → 0.0.1.rc6
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.
- data/README +18 -0
- data/an.gemspec +1 -1
- data/lib/an.rb +19 -0
- data/test/an.rb +42 -34
- metadata +9 -9
data/README
CHANGED
@@ -32,6 +32,24 @@ USAGE
|
|
32
32
|
# display an error.
|
33
33
|
end
|
34
34
|
|
35
|
+
RUNNING TESTS
|
36
|
+
|
37
|
+
If you haven't signed up for an Authorize.NET developer
|
38
|
+
account yet, please do at http://developer.authorize.net
|
39
|
+
|
40
|
+
After signing up, you should get your login id and
|
41
|
+
transaction key. You can then set the environment variable
|
42
|
+
|
43
|
+
AUTHORIZE_NET_URL=https://login:key@apitest.authorize.net/xml/v1/request.api
|
44
|
+
|
45
|
+
To install the development dependencies, you have to install dep.
|
46
|
+
|
47
|
+
$ gem install dep
|
48
|
+
$ cd ~/path/to/an
|
49
|
+
$ dep install
|
50
|
+
|
51
|
+
That's it!
|
52
|
+
|
35
53
|
TODOS
|
36
54
|
|
37
55
|
ARB Integration
|
data/an.gemspec
CHANGED
data/lib/an.rb
CHANGED
@@ -161,4 +161,23 @@ private
|
|
161
161
|
new(URI.parse(url))
|
162
162
|
end
|
163
163
|
end
|
164
|
+
|
165
|
+
# @see http://en.wikipedia.org/wiki/Luhn_algorithm
|
166
|
+
# @credit https://gist.github.com/1182499
|
167
|
+
module Luhn
|
168
|
+
RELATIVE_NUM = { '0' => 0, '1' => 2, '2' => 4, '3' => 6, '4' => 8,
|
169
|
+
'5' => 1, '6' => 3, '7' => 5, '8' => 7, '9' => 9 }
|
170
|
+
|
171
|
+
def self.check(number)
|
172
|
+
number = number.to_s.gsub(/\D/, "").reverse
|
173
|
+
|
174
|
+
sum = 0
|
175
|
+
|
176
|
+
number.split("").each_with_index do |n, i|
|
177
|
+
sum += (i % 2 == 0) ? n.to_i : RELATIVE_NUM[n]
|
178
|
+
end
|
179
|
+
|
180
|
+
sum % 10 == 0
|
181
|
+
end
|
182
|
+
end
|
164
183
|
end
|
data/test/an.rb
CHANGED
@@ -1,42 +1,50 @@
|
|
1
1
|
require_relative "helper"
|
2
2
|
|
3
|
-
|
4
|
-
AN.
|
3
|
+
test "luhn check" do
|
4
|
+
assert AN::Luhn.check("4111111111111111")
|
5
|
+
assert ! AN::Luhn.check("4111111111111112")
|
5
6
|
end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
amount: "10.00",
|
13
|
-
invoice_number: SecureRandom.hex(10)
|
14
|
-
)
|
15
|
-
|
16
|
-
assert resp.success?
|
17
|
-
assert resp["transactionResponse"].kind_of?(Hash)
|
18
|
-
assert_equal "XXXX1111", resp["transactionResponse"]["accountNumber"]
|
19
|
-
assert_equal "Visa", resp["transactionResponse"]["accountType"]
|
20
|
-
end
|
8
|
+
# AIM (Advanced Integration Method)
|
9
|
+
scope do
|
10
|
+
setup do
|
11
|
+
AN.connect
|
12
|
+
end
|
21
13
|
|
22
|
-
test "AIM
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
14
|
+
test "AIM most basic transaction" do |gateway|
|
15
|
+
resp = gateway.transact(
|
16
|
+
card_number: "4111111111111111",
|
17
|
+
card_code: "123",
|
18
|
+
expiration_date: "2015-01",
|
19
|
+
amount: "10.00",
|
20
|
+
invoice_number: SecureRandom.hex(10)
|
21
|
+
)
|
22
|
+
|
23
|
+
assert resp.success?
|
24
|
+
assert resp["transactionResponse"].kind_of?(Hash)
|
25
|
+
assert_equal "XXXX1111", resp["transactionResponse"]["accountNumber"]
|
26
|
+
assert_equal "Visa", resp["transactionResponse"]["accountType"]
|
27
|
+
end
|
28
|
+
|
29
|
+
test "AIM transaction with billing info" do |gateway|
|
30
|
+
resp = gateway.transact(
|
31
|
+
card_number: "4111111111111111",
|
32
|
+
card_code: "123",
|
33
|
+
expiration_date: "2015-01",
|
34
|
+
amount: "10.00",
|
35
|
+
invoice_number: SecureRandom.hex(10),
|
36
|
+
description: "Aeutsahoesuhtaeu",
|
37
|
+
first_name: "John",
|
38
|
+
last_name: "Doe",
|
39
|
+
address: "12345 foobar street",
|
40
|
+
zip: "90210"
|
41
|
+
)
|
42
|
+
|
43
|
+
assert resp.success?
|
44
|
+
assert resp["transactionResponse"].kind_of?(Hash)
|
45
|
+
assert_equal "XXXX1111", resp["transactionResponse"]["accountNumber"]
|
46
|
+
assert_equal "Visa", resp["transactionResponse"]["accountType"]
|
47
|
+
end
|
40
48
|
end
|
41
49
|
|
42
50
|
# CIM (Customer Information Manager)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: an
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.rc6
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mote
|
16
|
-
requirement: &
|
16
|
+
requirement: &70151521340420 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70151521340420
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: xml-simple
|
27
|
-
requirement: &
|
27
|
+
requirement: &70151521350520 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70151521350520
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: cutest
|
38
|
-
requirement: &
|
38
|
+
requirement: &70151521359820 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70151521359820
|
47
47
|
description: AN is a simplified client for integration with Authorize.NET.
|
48
48
|
email:
|
49
49
|
- me@cyrildavid.com
|
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
81
|
version: 1.3.1
|
82
82
|
requirements: []
|
83
83
|
rubyforge_project:
|
84
|
-
rubygems_version: 1.8.
|
84
|
+
rubygems_version: 1.8.11
|
85
85
|
signing_key:
|
86
86
|
specification_version: 3
|
87
87
|
summary: A thin Authorize.NET client.
|