azericard 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +11 -1
- data/lib/azericard/request.rb +11 -8
- data/lib/azericard/version.rb +1 -1
- data/test/configuration_test.rb +44 -0
- data/test/request_test.rb +47 -0
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a132019609fc9f7ce4a4488544b8facec82b1207
|
4
|
+
data.tar.gz: 255ac557ebad84acc13e6f78ccdfd43b437c9c26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70fbac47c1a0e09c9329e35cc2116a39cfc88c1a6ff62b641e1fdd44ae2279303497aa54dc59fa0b8d41b1deef63efd94f2976016bc5b6d6da7c40fda9be235f
|
7
|
+
data.tar.gz: ea24bb4d7c2626b33aadb08888c4f9afd47428371c308a2bd391aeeb4ea3abbdac19d5c0df5b0779315d5fd7f70b2a82f40b4d723ad570a0a9f51f03359de118
|
data/Rakefile
CHANGED
data/lib/azericard/request.rb
CHANGED
@@ -14,6 +14,9 @@ module Azericard
|
|
14
14
|
ssl_verifypeer: false,
|
15
15
|
ssl_verifyhost: 2,
|
16
16
|
cainfo: 'a.cer',
|
17
|
+
headers: {
|
18
|
+
"User-Agent" => Azericard.user_agent
|
19
|
+
},
|
17
20
|
body: {
|
18
21
|
"AMOUNT" => request_options.amount,
|
19
22
|
"CURRENCY" => request_options.currency,
|
@@ -44,14 +47,14 @@ module Azericard
|
|
44
47
|
# @param [Hash] options
|
45
48
|
# @return [Azericard::AzericardOptions]
|
46
49
|
def self.options_for_request(options={})
|
47
|
-
nonce = SecureRandom.hex(8)
|
48
|
-
timestamp = Time.now.utc.strftime('%Y%m%d%H%M%S')
|
49
|
-
merch_name = Azericard.merchant_name
|
50
|
-
merch_url = Azericard.merchant_url
|
51
|
-
terminal = Azericard.terminal.to_s
|
52
|
-
email = Azericard.merchant_email
|
53
|
-
country = Azericard.country_code
|
54
|
-
merch_gmt = Azericard.gmt_offset
|
50
|
+
nonce = options.fetch :nonce , SecureRandom.hex(8)
|
51
|
+
timestamp = options.fetch :timestamp , Time.now.utc.strftime('%Y%m%d%H%M%S')
|
52
|
+
merch_name = options.fetch :merch_name , Azericard.merchant_name
|
53
|
+
merch_url = options.fetch :merch_url , Azericard.merchant_url
|
54
|
+
terminal = options.fetch :terminal , Azericard.terminal.to_s
|
55
|
+
email = options.fetch :email , Azericard.merchant_email
|
56
|
+
country = options.fetch :country , Azericard.country_code
|
57
|
+
merch_gmt = options.fetch :merch_gmt , Azericard.gmt_offset
|
55
58
|
|
56
59
|
desc = backref = rrn = intref = nil
|
57
60
|
|
data/lib/azericard/version.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'azericard'
|
3
|
+
|
4
|
+
class ConfigurationTest < Test::Unit::TestCase
|
5
|
+
def teardown
|
6
|
+
Azericard.reset
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_config_options
|
10
|
+
Azericard.endpoint = 'https://example.com/cgi-bin/cgi_link'
|
11
|
+
Azericard.terminal = '12345678'
|
12
|
+
Azericard.secret_key = '00112233445566778899AABBCCDDEEFF'
|
13
|
+
Azericard.merchant_name = 'Merchant'
|
14
|
+
Azericard.merchant_email = 'merchant@example.com'
|
15
|
+
Azericard.merchant_url = 'https://merchant.example.com'
|
16
|
+
Azericard.country_code = 'AZ'
|
17
|
+
Azericard.gmt_offset = '+4'
|
18
|
+
|
19
|
+
assert_equal 'https://example.com/cgi-bin/cgi_link', Azericard.endpoint
|
20
|
+
assert_equal '12345678', Azericard.terminal
|
21
|
+
assert_equal '00112233445566778899AABBCCDDEEFF', Azericard.secret_key
|
22
|
+
assert_equal 'Merchant', Azericard.merchant_name
|
23
|
+
assert_equal 'merchant@example.com', Azericard.merchant_email
|
24
|
+
assert_equal 'https://merchant.example.com', Azericard.merchant_url
|
25
|
+
assert_equal 'AZ', Azericard.country_code
|
26
|
+
assert_equal '+4', Azericard.gmt_offset
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_user_agent
|
30
|
+
assert_equal "Azericard Ruby Gem #{Azericard::VERSION}", Azericard.user_agent
|
31
|
+
|
32
|
+
Azericard.user_agent = 'Custom User Agent'
|
33
|
+
assert_equal 'Custom User Agent', Azericard.user_agent
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_config_block
|
37
|
+
Azericard::Configuration::VALID_OPTIONS_KEYS.each do |key|
|
38
|
+
Azericard.configure do |config|
|
39
|
+
config.send("#{key}=", key)
|
40
|
+
assert_equal key, Azericard.send(key)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'azericard'
|
3
|
+
|
4
|
+
class RequestTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
Azericard.endpoint = 'https://example.com/cgi-bin/cgi_link'
|
7
|
+
Azericard.terminal = '12345678'
|
8
|
+
Azericard.secret_key = '1234ABC'
|
9
|
+
Azericard.merchant_name = 'Merchant'
|
10
|
+
Azericard.merchant_email = 'merchant@example.com'
|
11
|
+
Azericard.merchant_url = 'https://merchant.example.com'
|
12
|
+
Azericard.country_code = 'AZ'
|
13
|
+
Azericard.gmt_offset = '+4'
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_hex2bin
|
17
|
+
assert_equal 'example hex data', Azericard::Request.hex2bin('6578616d706c65206865782064617461')
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_generate_mac
|
21
|
+
assert_equal '115110f072f734a729ebd0e7b65cfd8662fef682', Azericard::Request.generate_mac('text')
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_options_for_request
|
25
|
+
options = {
|
26
|
+
amount: '22.5',
|
27
|
+
currency: 'AZN',
|
28
|
+
order: '453284023',
|
29
|
+
tr_type: 0,
|
30
|
+
desc: 'Description',
|
31
|
+
backref: 'https://shop.example.com'
|
32
|
+
}
|
33
|
+
request_options = Azericard::Request.options_for_request(options)
|
34
|
+
assert (/422\.53AZN945328402311Description8Merchant28https:\/\/merchant\.example\.com-81234567820merchant@example\.com102AZ2\+4/).match request_options.text_to_sign
|
35
|
+
|
36
|
+
options = {
|
37
|
+
amount: '22.5',
|
38
|
+
currency: 'AZN',
|
39
|
+
order: '453284023',
|
40
|
+
tr_type: 21,
|
41
|
+
rrn: 'RRN',
|
42
|
+
intref: '12345'
|
43
|
+
}
|
44
|
+
request_options = Azericard::Request.options_for_request(options)
|
45
|
+
assert (/9453284023422\.53AZN3RRN512345221812345678/).match request_options.text_to_sign
|
46
|
+
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: azericard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nihad Abbasov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -56,6 +56,8 @@ files:
|
|
56
56
|
- lib/azericard/error.rb
|
57
57
|
- lib/azericard/request.rb
|
58
58
|
- lib/azericard/version.rb
|
59
|
+
- test/configuration_test.rb
|
60
|
+
- test/request_test.rb
|
59
61
|
homepage: https://github.com/narkoz/azericard
|
60
62
|
licenses: []
|
61
63
|
metadata: {}
|
@@ -75,8 +77,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
77
|
version: '0'
|
76
78
|
requirements: []
|
77
79
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.
|
80
|
+
rubygems_version: 2.0.6
|
79
81
|
signing_key:
|
80
82
|
specification_version: 4
|
81
83
|
summary: A gem to provide a ruby interface for Azericard electronic payment system
|
82
|
-
test_files:
|
84
|
+
test_files:
|
85
|
+
- test/configuration_test.rb
|
86
|
+
- test/request_test.rb
|