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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b853dad3a4d492e17410701a6457644042ed291
4
- data.tar.gz: 652bc4ab9636aca7f2c53fa2d2d1619957e56920
3
+ metadata.gz: a132019609fc9f7ce4a4488544b8facec82b1207
4
+ data.tar.gz: 255ac557ebad84acc13e6f78ccdfd43b437c9c26
5
5
  SHA512:
6
- metadata.gz: 032d8cd4eeed7999567457298f078cc965f85381794d07941ebbb65f097e020d79c7341002576d4acdeb9b67624e9cdfb2743d294b153a9853b8efad39e25b78
7
- data.tar.gz: 6a99d497e3a53925fb3e85c6951a8d7641763326a0b4fb2cc6dad5b6b0542cc80af522e7867b88fbfa274ef3184c0b3a0448ea34a870f2b82b99ff2de86cbd73
6
+ metadata.gz: 70fbac47c1a0e09c9329e35cc2116a39cfc88c1a6ff62b641e1fdd44ae2279303497aa54dc59fa0b8d41b1deef63efd94f2976016bc5b6d6da7c40fda9be235f
7
+ data.tar.gz: ea24bb4d7c2626b33aadb08888c4f9afd47428371c308a2bd391aeeb4ea3abbdac19d5c0df5b0779315d5fd7f70b2a82f40b4d723ad570a0a9f51f03359de118
data/Rakefile CHANGED
@@ -1 +1,11 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'lib'
6
+ t.pattern = 'test/**/*_test.rb'
7
+ t.verbose = false
8
+ t.warning = true
9
+ end
10
+
11
+ task :default => :test
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Azericard
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -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.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-01 00:00:00.000000000 Z
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.1.7
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