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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: deb853647418c084bd3c0ce9508e1652ca44b34e
4
- data.tar.gz: 1973a1ddaf14c07f957f150be0c6a0d3d8588a75
3
+ metadata.gz: eece8069cc5fd1cf60d3fb09b4a3ffa96d2ffcfa
4
+ data.tar.gz: 6e53bdf67e10e95c0581a4eb5c66f177a4908474
5
5
  SHA512:
6
- metadata.gz: e5b29cc63c9eacf996c301cb69703d0d0bb545e91c28ca0b7ae7e0992fde03ad76a30adec20c7cf1a5ad4a154a2cfd5548f2b6c24568ebbb90281bbd171c1fd3
7
- data.tar.gz: e616ee15165fcd619d8ffc8a055943c1bd9bd2c2b542b44589b30f4a8f2ce38a9f04d3b0209f9b16181b8054df82d2e0a60bdff7502aba239c2f3723560ca2a6
6
+ metadata.gz: 2b8bf9a4a40ad00a8ad69673d35c169b2405b4a09b726e1de79438e382e48bcac3f6ec1ebd57aea24dd34603934cb576492811d9701f0c1f1a45ba366ee4c57d
7
+ data.tar.gz: 37fba46a9992a3e0ea3fa02b32e0172a5ebbb38ebf4572f097f5ef23c9c3086d9b6c36456c0d4f44bf2d46a23f28827e8811399bef6e678f4f608b7142a1c882
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
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.2 ruby lib
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.2"
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: hash)
12
+ ServicePattern::Response.new(result: calculate_hash)
11
13
  end
12
14
 
13
15
  private
14
16
 
15
- def hash
16
- Digest::MD5.hexdigest("#{params.values.join}#{epay_md5_key}")
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" => "edc52b2b2f619551146682061d3a9d0d"
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 "edc52b2b2f619551146682061d3a9d0d"
30
+ expect(service.execute!.result.fetch(:epay_hash)).to eq "394b72dae2714e89222d30cf9a1d649b"
31
31
  end
32
32
  end
33
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epay_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaspernj