authorize_net 0.1.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/authorize_net/api.rb +11 -15
  3. metadata +9 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b5cdec68c5a0227090b0a075ec6e878bf8fdb9b
4
- data.tar.gz: 235f499be6000dcd0f367a9fc50981a62938abfe
3
+ metadata.gz: b54a3c7b71d85f74a31ddc1536618b20a5e6091c
4
+ data.tar.gz: c0cfa47156d61008d8771b6052f1ea4abf620d7c
5
5
  SHA512:
6
- metadata.gz: c58a95c0d03f517109d2bdecd2cf7876700e25a7e1b91b88dc4f5842eda41387d13f56178a28afcc291922a9da13a80ee644ceb7064d192a4a13bd45eb46c29c
7
- data.tar.gz: 04497a6a05e80f074aeaa5cd465384b78625255a44623960717c99d08d96185ad928c5706c45132d43b8d13d14ca5bee8d4ad7e02c944265d4b33707460fcf8a
6
+ metadata.gz: d58bb0fc0b972b48d1f64060ea71eb787000d73320636e082e78873fa49d77a20b7d39efec3b13e035197d36deb3370f6563e694659f3cac996f16517f95a619
7
+ data.tar.gz: 9c546765a0a9cee9d6a56084ff81123acb2fcad37b66baefec4f656246a15864a8bdfc81bdc57e9bdd7c97a7d64d1e71b4940e4054366025b73e8962dd967191
@@ -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
- @md5_hash = options[:md5_hash]
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, use_api_login: true)
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, use_api_login: true)
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, use_api_login: false)
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, options={})
284
- if @md5_hash.nil?
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
- if options[:use_api_login]
294
- calculated_hash = digest.hexdigest("#{@md5_hash}#{@api_login_id}#{transaction_id}#{formatted_amount}")
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.1.2
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.6.7.2
19
+ version: '1.10'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 1.6.7.2
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.6.7.2
29
+ version: '1.10'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 1.6.7.2
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: '0'
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.6.3
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