authorize_cim 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/authorize_cim.rb +12 -14
- data/spec/lib/authorize_cim_spec.rb +3 -3
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/authorize_cim.rb
CHANGED
@@ -10,7 +10,6 @@ end
|
|
10
10
|
class AuthorizeCim
|
11
11
|
|
12
12
|
def initialize(attrs)
|
13
|
-
|
14
13
|
raise InvalidOrMissingCredentials unless attrs[:key] && attrs[:login]
|
15
14
|
|
16
15
|
@key = attrs[:key]
|
@@ -22,8 +21,6 @@ class AuthorizeCim
|
|
22
21
|
else 'https://api.authorize.net/xml/v1/request.api'
|
23
22
|
end
|
24
23
|
@uri = URI.parse(@endpoint)
|
25
|
-
|
26
|
-
|
27
24
|
end
|
28
25
|
|
29
26
|
# Create a new customer profile
|
@@ -207,13 +204,15 @@ class AuthorizeCim
|
|
207
204
|
# :name => '<name>' (name of tax ie federal, state etc.)
|
208
205
|
# :description => '<description>' (up to 255 characters)
|
209
206
|
# }
|
210
|
-
# :line_items => [ (an array of items on transaction, each array item is a hash
|
207
|
+
# :line_items => [ (an array of items on transaction, each array item is a hash containig \/ (optional))
|
208
|
+
# {
|
211
209
|
# :item_id => '<id>' (up to 31 characters)
|
212
210
|
# :name => '<name>' (up to 31 characters)
|
213
211
|
# :description => '<description>' (up to 255 characters)
|
214
212
|
# :quantity => <number> (up to 4 digits(and 2 decimal places... but how could you have .34 things you sold...))
|
215
213
|
# :unit_price => <number> (up to 4 digits(and 2 decimal places))
|
216
214
|
# :taxable => <boolean> (must be "true" or "false")
|
215
|
+
# }
|
217
216
|
# ]
|
218
217
|
# :customer_profile_id => <id number> (profile Identification number given by authorize.net (required))
|
219
218
|
# :customer_payment_profile_id => <payment id number> (profile payment ID given by authorize.net (required))
|
@@ -268,12 +267,12 @@ class AuthorizeCim
|
|
268
267
|
xml.tag!('lineItems') do
|
269
268
|
arr = input[:transaction][:transaction_type][:line_item]
|
270
269
|
arr.each { |item|
|
271
|
-
xml.itemId item[:item_id]
|
272
|
-
xml.name item[:name]
|
273
|
-
xml.description item[:description]
|
274
|
-
xml.quantity item[:quantity]
|
275
|
-
xml.unitPrice item[:unit_price]
|
276
|
-
xml.taxable item[:taxable]
|
270
|
+
xml.itemId item[:item_id] if item[:item_id]
|
271
|
+
xml.name item[:name] if item[:name]
|
272
|
+
xml.description item[:description] if item[:description]
|
273
|
+
xml.quantity item[:quantity] if item[:quantity]
|
274
|
+
xml.unitPrice item[:unit_price] if item[:unit_price]
|
275
|
+
xml.taxable item[:taxable] if item[:taxable]
|
277
276
|
}
|
278
277
|
end
|
279
278
|
end
|
@@ -322,7 +321,7 @@ class AuthorizeCim
|
|
322
321
|
end
|
323
322
|
end
|
324
323
|
end
|
325
|
-
|
324
|
+
parse send(data)
|
326
325
|
end
|
327
326
|
|
328
327
|
|
@@ -382,7 +381,6 @@ class AuthorizeCim
|
|
382
381
|
xml.customerAddressId input[:customer_address_id] if input[:customer_address_id]
|
383
382
|
end
|
384
383
|
parse send(data)
|
385
|
-
|
386
384
|
end
|
387
385
|
|
388
386
|
# Retrieve all customer profile IDs you have previously created.
|
@@ -403,7 +401,6 @@ class AuthorizeCim
|
|
403
401
|
xml.customerProfileId input[:customer_profile_id] if input[:customer_profile_id]
|
404
402
|
end
|
405
403
|
parse send(data)
|
406
|
-
|
407
404
|
end
|
408
405
|
|
409
406
|
# Retrieve a customer payment profile for an existing customer profile.
|
@@ -422,7 +419,6 @@ class AuthorizeCim
|
|
422
419
|
xml.customerPaymentProfileId input[:customer_payment_profile_id] if input[:customer_payment_profile_id]
|
423
420
|
end
|
424
421
|
parse send(data)
|
425
|
-
|
426
422
|
end
|
427
423
|
|
428
424
|
# Retrieve a customer shipping address for an existing customer profile.
|
@@ -676,6 +672,8 @@ class AuthorizeCim
|
|
676
672
|
def send(xml) # returns xmlDoc of response
|
677
673
|
http = Net::HTTP.new(@uri.host, @uri.port)
|
678
674
|
http.use_ssl = 443 == @uri.port
|
675
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
676
|
+
|
679
677
|
begin
|
680
678
|
resp, body = http.post(@uri.path, xml, {'Content-Type' => 'text/xml'})
|
681
679
|
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, Errno::ECONNREFUSED, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
|
@@ -3,7 +3,7 @@ require "#{File.dirname(__FILE__)}/../base"
|
|
3
3
|
describe AuthorizeCim do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@client = AuthorizeCim.new(:endpoint => :test, :login =>
|
6
|
+
@client = AuthorizeCim.new(:endpoint => :test, :login => '3wFY26cE', :key => '5W22d4Jk4De6v6XJ')
|
7
7
|
end
|
8
8
|
|
9
9
|
before :each do
|
@@ -82,8 +82,8 @@ describe AuthorizeCim do
|
|
82
82
|
|
83
83
|
|
84
84
|
it "create a valid customer profile transaction" do
|
85
|
-
hash = {:ref_id => '2', :transaction => {}
|
86
|
-
hash[:transaction] = {:trans_type => '
|
85
|
+
hash = {:ref_id => '2', :transaction => {}}
|
86
|
+
hash[:transaction] = {:trans_type => 'profileTransAuthCapture', :transaction_type => {}}
|
87
87
|
hash[:transaction][:transaction_type] = {:amount => '101.11', :customer_profile_id => @customer_profile , :customer_payment_profile_id => @customer_payment_profile, :tax => {}}
|
88
88
|
hash[:transaction][:transaction_type][:tax] = {:amount => '23.21', :name => 'state taxes'}
|
89
89
|
transaction = @client.create_customer_profile_transaction(hash)
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Tyler Flint
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-02-01 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|