epay_tools 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/epay_tools.gemspec +2 -2
- data/lib/epay_tools/hash_generator.rb +18 -3
- data/spec/epay_tools/calculator_spec.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eece8069cc5fd1cf60d3fb09b4a3ffa96d2ffcfa
|
4
|
+
data.tar.gz: 6e53bdf67e10e95c0581a4eb5c66f177a4908474
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b8bf9a4a40ad00a8ad69673d35c169b2405b4a09b726e1de79438e382e48bcac3f6ec1ebd57aea24dd34603934cb576492811d9701f0c1f1a45ba366ee4c57d
|
7
|
+
data.tar.gz: 37fba46a9992a3e0ea3fa02b32e0172a5ebbb38ebf4572f097f5ef23c9c3086d9b6c36456c0d4f44bf2d46a23f28827e8811399bef6e678f4f608b7142a1c882
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/epay_tools.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: epay_tools 0.0.
|
5
|
+
# stub: epay_tools 0.0.3 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "epay_tools".freeze
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.3"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
@@ -1,18 +1,33 @@
|
|
1
1
|
class EpayTools::HashGenerator < ServicePattern::Service
|
2
2
|
attr_reader :epay_md5_key, :params
|
3
3
|
|
4
|
+
KEYS_ORDER = %w[txnid orderid amount currency date time txnfee paymenttype cardno hash].freeze
|
5
|
+
|
4
6
|
def initialize(epay_md5_key:, params:)
|
5
7
|
@epay_md5_key = epay_md5_key
|
6
8
|
@params = params.reject { |key, _value| key.to_s == "hash" }
|
7
9
|
end
|
8
10
|
|
9
11
|
def execute!
|
10
|
-
ServicePattern::Response.new(result:
|
12
|
+
ServicePattern::Response.new(result: calculate_hash)
|
11
13
|
end
|
12
14
|
|
13
15
|
private
|
14
16
|
|
15
|
-
def
|
16
|
-
Digest::MD5.hexdigest("#{
|
17
|
+
def calculate_hash
|
18
|
+
@_calculate_hash ||= Digest::MD5.hexdigest("#{params_values.join}#{epay_md5_key}")
|
19
|
+
end
|
20
|
+
|
21
|
+
def params_values
|
22
|
+
unless @_params_values
|
23
|
+
@_params_values = {}
|
24
|
+
KEYS_ORDER.each do |key|
|
25
|
+
@_params_values[key] = params.delete(key) if params.key?(key)
|
26
|
+
end
|
27
|
+
|
28
|
+
@_params_values.merge!(params)
|
29
|
+
end
|
30
|
+
|
31
|
+
@_params_values.values
|
17
32
|
end
|
18
33
|
end
|
@@ -15,7 +15,7 @@ describe EpayTools::Calculator do
|
|
15
15
|
"paymentcollection" => "1",
|
16
16
|
"lockpaymentcollection" => "1",
|
17
17
|
"subscription" => "0",
|
18
|
-
"hash" => "
|
18
|
+
"hash" => "394b72dae2714e89222d30cf9a1d649b"
|
19
19
|
}
|
20
20
|
end
|
21
21
|
let(:service) do
|
@@ -27,7 +27,7 @@ describe EpayTools::Calculator do
|
|
27
27
|
|
28
28
|
describe "#calculated_hash" do
|
29
29
|
it "calculates the right hash" do
|
30
|
-
expect(service.execute!.result.fetch(:epay_hash)).to eq "
|
30
|
+
expect(service.execute!.result.fetch(:epay_hash)).to eq "394b72dae2714e89222d30cf9a1d649b"
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|