authorize_net 0.1.2 → 1.0.0
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.
- checksums.yaml +4 -4
- data/lib/authorize_net/api.rb +11 -15
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b54a3c7b71d85f74a31ddc1536618b20a5e6091c
|
4
|
+
data.tar.gz: c0cfa47156d61008d8771b6052f1ea4abf620d7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d58bb0fc0b972b48d1f64060ea71eb787000d73320636e082e78873fa49d77a20b7d39efec3b13e035197d36deb3370f6563e694659f3cac996f16517f95a619
|
7
|
+
data.tar.gz: 9c546765a0a9cee9d6a56084ff81123acb2fcad37b66baefec4f656246a15864a8bdfc81bdc57e9bdd7c97a7d64d1e71b4940e4054366025b73e8962dd967191
|
data/lib/authorize_net/api.rb
CHANGED
@@ -9,11 +9,11 @@ require 'openssl'
|
|
9
9
|
# ===============================================================
|
10
10
|
class AuthorizeNet::Api
|
11
11
|
|
12
|
-
def initialize(api_login_id, api_transaction_key, options
|
12
|
+
def initialize(api_login_id, api_transaction_key, **options)
|
13
13
|
@api_login_id = api_login_id
|
14
14
|
@api_transaction_key = api_transaction_key
|
15
15
|
@is_sandbox = options[:sandbox]
|
16
|
-
@
|
16
|
+
@signature_key = options[:signature_key]
|
17
17
|
@logger = nil
|
18
18
|
@log_full_request = false
|
19
19
|
end
|
@@ -47,7 +47,7 @@ class AuthorizeNet::Api
|
|
47
47
|
end
|
48
48
|
|
49
49
|
response = sendRequest("createTransactionRequest", xml_obj)
|
50
|
-
validate_hash(response, amount
|
50
|
+
validate_hash(response, amount)
|
51
51
|
if !response.nil?
|
52
52
|
return AuthorizeNet::Transaction.parse(response)
|
53
53
|
end
|
@@ -85,7 +85,7 @@ class AuthorizeNet::Api
|
|
85
85
|
}
|
86
86
|
|
87
87
|
response = sendRequest("createTransactionRequest", xml_obj)
|
88
|
-
validate_hash(response, amount
|
88
|
+
validate_hash(response, amount)
|
89
89
|
if !response.nil?
|
90
90
|
return {
|
91
91
|
:transaction => AuthorizeNet::Transaction.parse(response),
|
@@ -118,7 +118,7 @@ class AuthorizeNet::Api
|
|
118
118
|
}
|
119
119
|
|
120
120
|
response = sendRequest("createTransactionRequest", xml_obj)
|
121
|
-
validate_hash(response, amount
|
121
|
+
validate_hash(response, amount)
|
122
122
|
if !response.nil?
|
123
123
|
return AuthorizeNet::Transaction.parse(response)
|
124
124
|
end
|
@@ -280,21 +280,17 @@ class AuthorizeNet::Api
|
|
280
280
|
#
|
281
281
|
# @throws AuthorizeNet::Exception
|
282
282
|
# =============================================
|
283
|
-
def validate_hash(response_xml, amount
|
284
|
-
if @
|
283
|
+
def validate_hash(response_xml, amount)
|
284
|
+
if @signature_key.nil?
|
285
285
|
return
|
286
286
|
end
|
287
287
|
|
288
|
-
digest = OpenSSL::Digest.new('md5')
|
289
|
-
transaction_id = AuthorizeNet::Util.getXmlValue(response_xml, "transId")
|
290
|
-
trans_hash = AuthorizeNet::Util.getXmlValue(response_xml, "transHash").downcase
|
291
288
|
formatted_amount = "%.2f" % amount
|
289
|
+
transaction_id = AuthorizeNet::Util.getXmlValue(response_xml, "transId")
|
290
|
+
hash_text = "^#{@api_login_id}^#{transaction_id}^#{formatted_amount}^"
|
292
291
|
|
293
|
-
|
294
|
-
|
295
|
-
else
|
296
|
-
calculated_hash = digest.hexdigest("#{@md5_hash}#{transaction_id}#{formatted_amount}")
|
297
|
-
end
|
292
|
+
calculated_hash = OpenSSL::HMAC.hexdigest('sha512', [@signature_key].pack('H*'), hash_text).downcase
|
293
|
+
trans_hash = AuthorizeNet::Util.getXmlValue(response_xml, "transHashSha2").downcase
|
298
294
|
|
299
295
|
if calculated_hash != trans_hash
|
300
296
|
if @logger.respond_to? :error
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authorize_net
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Avenir Interactive LLC
|
@@ -14,22 +14,22 @@ dependencies:
|
|
14
14
|
name: nokogiri
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: '1.10'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 1.
|
22
|
+
version: 1.10.2
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.
|
29
|
+
version: '1.10'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 1.
|
32
|
+
version: 1.10.2
|
33
33
|
description: A RubyGem that interfaces with the Authorize.net payment gateway
|
34
34
|
email:
|
35
35
|
- info@avenirhq.com
|
@@ -62,7 +62,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
62
|
requirements:
|
63
63
|
- - ">="
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version:
|
65
|
+
version: 2.3.0
|
66
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
68
|
- - ">="
|
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
72
|
rubyforge_project:
|
73
|
-
rubygems_version: 2.
|
73
|
+
rubygems_version: 2.4.5.1
|
74
74
|
signing_key:
|
75
75
|
specification_version: 4
|
76
76
|
summary: API interface for Authorize.net payment gateway
|